Incorrectly ignores single-line code blocks when escaping Swig and HTML 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 versionto 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><!--test--></code>.
I tested with hexo g on both Hexo 7.3.0 and 8.1.1, and both versions correctly rendered the output as <code><!--test--></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 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 -->`
@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 -->`.
@D-Sketon @chanwj Thank you. I understand now. I've commented on the PR.