Skip to content
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

Highlighting broken for multi-line constructs #4

Closed
yyx990803 opened this issue Oct 25, 2015 · 0 comments
Closed

Highlighting broken for multi-line constructs #4

yyx990803 opened this issue Oct 25, 2015 · 0 comments

Comments

@yyx990803
Copy link

When highlighting multi-line constructs, e.g. block comments or ES2015 template strings, highlight.js outputs a single <span> that contains newlines. For example:

var string = `
  I am multiline
`

Is converted to:

<span class="keyword">var</span> string = <span class="string">`
  i am multilne
`</span>

In https:/hexojs/hexo-util/blob/master/lib/highlight.js#L32, hexo wraps each line with an extra <span>, which closes the <span class="string"> early, and causes the rest of that string to be highlighted incorrectly:

<span class="line"><span class="keyword">var</span> string = <span class="string">`</span><br>
<span class="line">  i am multilne</span><br>
<span class="line">`</span></span><br>

In addition, it also creates a .line span that is in fact multiple lines high.

I personally use a custom theme that does not make use of the .line class at all, so I simply removed that wrapping span and everything works properly. However it seems many existing themes rely on the .line class for styling :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant