You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to above API document, highlight() throws an exception in case of detecting illegal syntax for the language.
But actually not throw any exception (regardless ignore_illegals parameter).
Instead, illegal property of the return value is set to true and language property of the return value does not exist.
Current code of lib/highlight.js considers the exception halfway.
And the lack of lanaguage property is not expected.
Anyway the code should be modified to keep consistency.
Generally the result of
highlight()
contains lauguage name as HTML class name.If code is illegal syntax for the specified language,
the HTML class name is added or not (inconsistent).
lang
hljs
<figure>
<code>
java
false
highlight java
java
true
highlight java
hljs java
java
false
highlight
java
true
highlight
hljs java
false
highlight plain
true
highlight plain
hljs plain
I think we have three options:
plain
if illegal syntax.I think Option 1 might be best because users will intend to be.
Please advice!
I think this inconsistency is caused by undocumented behavior of
highlight()
ofhighlightjs
package.The API document of
highlightjs
package is:https://highlightjs.readthedocs.io/en/latest/api.html#highlight-languagename-code-ignore-illegals-continuation
According to above API document,
highlight()
throws an exception in case of detecting illegal syntax for the language.But actually not throw any exception (regardless
ignore_illegals
parameter).Instead,
illegal
property of the return value is set totrue
andlanguage
property of the return value does not exist.Current code of
lib/highlight.js
considers the exception halfway.And the lack of
lanaguage
property is not expected.Anyway the code should be modified to keep consistency.
p.s. This issue is derived from hexojs/hexo#3984
The text was updated successfully, but these errors were encountered: