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(post): swig tag inside post #4352

Merged
merged 3 commits into from
Jun 13, 2020
Merged

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Jun 10, 2020

What does it do?

The PR fixes #3259, #3346 & #3346 (comment)

How to test

git clone -b test-post-render-swig https://github.com/sukkaw/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

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

@SukkaW
Copy link
Member Author

SukkaW commented Jun 10, 2020

The fixes for #3543 is not included.

Maybe I will open an another PR.

@SukkaW SukkaW added this to the 5.0.0 milestone Jun 10, 2020
@@ -669,13 +669,13 @@ describe('Post', () => {
});

it('render() - recover escaped nunjucks blocks which is html escaped', () => {
const content = '`{% raw %}{{ test }}{% endraw %}`';
const content = '`{% raw %}{{ test }}{% endraw %}`, {%raw%}{{ test }}{%endraw%}';
Copy link
Member Author

Choose a reason for hiding this comment

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

The alter of the test case here is to test my newly added rSwigRawFullBlock

@stevenjoezhang stevenjoezhang linked an issue Jun 10, 2020 that may be closed by this pull request
@SukkaW SukkaW merged commit 2b70b82 into hexojs:master Jun 13, 2020
engine: 'markdown'
});

data.content.trim().should.eql('<p>In Go’s templates, blocks look like this: <code>&amp;#123;&amp;#123;block &quot;template name&quot; .&amp;#125;&amp;#125; (content) &amp;#123;&amp;#123;end&amp;#125;&amp;#125;</code>.</p>');
Copy link
Member

Choose a reason for hiding this comment

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

It seems that &amp;#123; is escaped twice and it's displayed as &#123; instead of { in the browser. Is this expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will update the test case using escapeHTML to make it clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

@stevenjoezhang

The marked.js will escape code by default, thus caused double escape.

@SukkaW SukkaW mentioned this pull request Jul 25, 2020
22 tasks
curbengh added a commit to curbengh/hexo-site that referenced this pull request Aug 22, 2020
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.

{% %} should not be rendered in a post {{ should not be rendered in a post
2 participants