Coder Social home page Coder Social logo

Comments (2)

FZQ0003 avatar FZQ0003 commented on July 24, 2024

I have found the reason.
This issue (typing markdown fenced code blocks in html comments) only appears when I enable one of built-in syntax highlight libraries. In my old environment, I disabled them and use Prettify instead, and it worked well.
I'll use another highlighter.

By the way, I have read an article about code blocks https://hexo.io/docs/syntax-highlight.html#How-to-use-code-block-in-posts. It says code block syntax will always be available, so I did additional tests.

Syntax highlighting is disabled.

Source:

Text 1

<!--

Commented text 1

{% codeblock %}
A commented code block
{% endcodeblock %}

Commented text 2

-->

Text 2

Output:

<p>Text 1</p>
<!--

Commented text 1

<pre><code>A commented code block</code></pre>

<p>Commented text 2</p>
<p>–&gt;</p>
<p>Text 2</p>

...
</html>-->

I should edit the title.

from hexo.

D-Sketon avatar D-Sketon commented on July 24, 2024

hexo wraps the highlighting code in <! -- --> and passes it into the markdown renderer, making it difficult to deal with nested comments.

return `<!--${flag}\uFFFC${cache.push(str) - 1}-->`;

Notice that the end of the comment is escaped as <p>-&gt;</p>, causing a comment tag pairing failure.

from hexo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.