-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax Highlight does not split string as expected #4178
Comments
I tracked it down to this piece of the code where the following input is transformed wrongly to the following output. Somehow, the Text Input
Input after call to hljs.highlight()<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> Output of recursive highlight(){
"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
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: