Custom classes tag breaks/errors when code contains function with a parameter (php)Β #166
Open
Description
Environment:
- OS: MacOS Sequoia
- PHP version: 8.3
What happens:
When there is a function with a parameter in the code surrounded by custom classes tag, I either get an error, or the argument gets cut weirdly.
For example, if I have this: {:_:function ($test) {:}
, it will return this:
<span class="_"><span class="hl-keyword">function</span> ($te<span class="hl-injection">$test</span></span>) {
Which visually looks like this: function ($te$test) {
And if I add the second bracket like so {:_:function ($test) {}:}
, I get this error:
What should happen
I expect to get this output:
<span class="_"><span class="hl-keyword">function</span> (<span class="hl-injection">$test</span>) {}</span>
Steps to reproduce:
- Create a new Tempest project with
composer create-project tempest/app my-app --stability alpha
- Copy this in
HomeController
<?php
declare(strict_types=1);
namespace App;
use Tempest\Highlight\Highlighter;
use Tempest\Http\Get;
use function Tempest\view;
use Tempest\View\View;
final readonly class HomeController
{
#[Get('/')]
public function __invoke(): View
{
// To show the error, put this in the 'CODE' string: `{:_:function ($test) {}:}`
$code = (new Highlighter())->parse(
<<<'CODE'
{:_:function ($test) {:}
CODE,
'php'
);
return view('home.view.php')->data(code: $code);
}
}
- Copy this in
home.view.php
<html lang="en">
<head>
<title>Tempest</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/main.css" rel="stylesheet">
</head>
<body class="flex justify-center items-center">
<div>
{!! $code !!}
</div>
</body>
</html>
- Run
./tempest serve
Additional context:
- Everything works fine when you remove the custom classes tags
Metadata
Assignees
Labels
No labels