hexo icon indicating copy to clipboard operation
hexo copied to clipboard

Incorrectly ignores single-line code blocks when escaping Swig and HTML comments

Open D-Sketon opened this issue 5 months ago • 4 comments

Check List

  • [x] I have already read Docs page & Troubleshooting page.
  • [x] I have already searched existing issues and they are not help to me.
  • [x] I examined error or warning messages and it's difficult to solve.
  • [x] I am using the latest version of Hexo. (run hexo version to check)
  • [x] My Node.js is matched the required version.

Expected behavior

ref: https://github.com/hexojs/hexo/issues/5716#issuecomment-3479388663

Since v8.1.0, `<!--test-->` has been incorrectly rendered as <code><!--test--></code>. It should be rendered as <code>&lt;!--test--&gt;</code>.

D-Sketon avatar Nov 04 '25 14:11 D-Sketon

I tested with hexo g on both Hexo 7.3.0 and 8.1.1, and both versions correctly rendered the output as <code>&lt;!--test--&gt;</code>.

Before reviewing the PR, I believe we should clarify the reproduction conditions, including:

  • Which renderer is being used
  • Renderer configuration
  • The actual Markdown content that triggers the issue (if possible)

@chanwj Could you provide these details to help us reproduce the issue if possible?

yoshinorin avatar Nov 11 '25 15:11 yoshinorin

@yoshinorin Your post needs to include the swig tag because the current logic does not trigger the escape process when the swig tag is absent. e.g.

{{ 1 }}
`<!-- comment -->`

D-Sketon avatar Nov 11 '25 16:11 D-Sketon

@chanwj Could you provide these details to help us reproduce the issue if possible?

@yoshinorin Sure, I will post my use case below.

  • Post's markdown file:
{% timeline 2025 %}

<!-- timeline 0625 -->

Any Content.

<!-- endtimeline -->

{% endtimeline %}

Every timeline block content should be written between `<!-- timeline title -->` and `<!-- endtimeline -->`.

chanwj avatar Nov 12 '25 06:11 chanwj

@D-Sketon @chanwj Thank you. I understand now. I've commented on the PR.

yoshinorin avatar Nov 22 '25 10:11 yoshinorin