ppoffice / hexo-theme-minos

A simple and retro styled Hexo theme, concentrated more on your ideas.
http://ppoffice.github.io/hexo-theme-minos
MIT License
767 stars 200 forks source link

'<' and '>' in code blocks will occur an error #107

Closed alienzhou closed 4 years ago

alienzhou commented 4 years ago

When using < and > characters in code blocks, the HTML is displayed unexpectedly.

markdown source:

```HTML \<abbr>12312\</abbr> ```

result:

image

expected:

image


After debugging, I find maybe the method for adding highlight classnames cause it.

Characters < and > in markdowns' code block (as below)

<abbr>12312</abbr>

will be transformed to &lt; and &gt; by default so that it can be rendered in HTML correctly.

However, minos uses cheerio for appending hljs classname for highlighting (in the patchCodeHighlight function). As a result $.html() returns the final HTML string without &lt; and &gt;.