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

fix: nunjucks/code blocks in HTML comments were incorrectly converted #5616

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

D-Sketon
Copy link
Member

@D-Sketon D-Sketon commented Jan 18, 2025

What does it do?

fix #5433

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

How to test

git clone -b fix/comment https://github.com/D-Sketon/hexo.git
cd hexo
npm install
npm test

@coveralls
Copy link

coveralls commented Jan 18, 2025

Pull Request Test Coverage Report for Build 12931122833

Details

  • 50 of 50 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 99.494%

Totals Coverage Status
Change from base Build 12902994421: 0.002%
Covered Lines: 9638
Relevant Lines: 9687

💛 - Coveralls

data.content.should.eql([
'<p>foo</p>',
'<!--',
`<hexoPostRenderCodeBlock>${highlighted}</hexoPostRenderCodeBlock>`,

This comment was marked as off-topic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can solve it in backtick_code_block.ts

@D-Sketon
Copy link
Member Author

The negative lookbehind and negative lookahead /(?<!<!--[^(?:\-\->)]*?)^((?:[^\S\r\n]*>){0,3}[^\S\r\n]*)(`{3,}|~{3,})[^\S\r\n]*((?:.*?[^`\s])?)[^\S\r\n]*\n((?:[\s\S]*?\n)?)(?:(?:[^\S\r\n]*>){0,3}[^\S\r\n]*)\2[^\S\r\n]?(\n+|$)(?![^(?:<!\-\-)]*?-->)/gm caused a performance regression 😓

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

Successfully merging this pull request may close these issues.

Code blocks in HTML comments were incorrectly converted
3 participants