Open PJUllrich opened 4 months ago
I tracked it down to this piece of the code where the following input is transformed wrongly to the following output.
Somehow, the hljs-class
-keyword confuses the highlight(text, language)
function and it skips the inner keywords hljs-keyword
and hljs-title
.
defmodule Test do
def foo(bar) do
bar + 2
end
end
<span class="hljs-class"><span class="hljs-keyword">defmodule</span> <span class="hljs-title">Test</span></span> <span class="hljs-keyword">do</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">foo</span></span>(bar) <span class="hljs-keyword">do</span>
bar + <span class="hljs-number">2</span>
<span class="hljs-keyword">end</span>
<span class="hljs-keyword">end</span>
{
"ops": [
{
"insert": "defmodule Test",
"attributes": {
"code-token": "class"
}
},
{
"insert": " "
},
{
"insert": "do",
"attributes": {
"code-token": "keyword"
}
},
{
"insert": "\n",
"attributes": {
"code-block": "elixir"
}
},
{
"insert": " "
},
{
"insert": "def foo",
"attributes": {
"code-token": "function"
}
},
{
"insert": "(bar) "
},
{
"insert": "do",
"attributes": {
"code-token": "keyword"
}
},
{
"insert": "\n",
"attributes": {
"code-block": "elixir"
}
},
{
"insert": " bar + "
},
{
"insert": "2",
"attributes": {
"code-token": "number"
}
},
{
"insert": "\n",
"attributes": {
"code-block": "elixir"
}
},
{
"insert": " "
},
{
"insert": "end",
"attributes": {
"code-token": "keyword"
}
},
{
"insert": "\n",
"attributes": {
"code-block": "elixir"
}
},
{
"insert": "end",
"attributes": {
"code-token": "keyword"
}
},
{
"insert": "\n",
"attributes": {
"code-block": "elixir"
}
}
]
}
I recreated it in the playground.
Just enter the input text and select Elixir
as a language:
defmodule Test do
def foo(bar) do
bar + 2
end
end
I'm getting the same behavior with C# code:
Yes, how can I solve it?
This is basically a new issue for #3041 which was closed by the quill-bot.
Steps for Reproduction
Example code
Expected behavior:
The
defmodule Test do
string is split into three partshljs-keyword
,hljs-title
, andhljs-keyword
and is highlighted correctly:Actual behavior:
The string is only split into two parts:
hljs-class
andhljs-keyword
and is not highlighted correctly:Platforms:
Version:
2.0.1