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

perf(tag): rendering optimization #4418

Merged
merged 7 commits into from Jul 24, 2020

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Jul 15, 2020

What does it do?

Escape swig tag inside code block only once.

How to test

git clone -b post-tag-render-optimize 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 SukkaW requested review from seaoak, segayuu, stevenjoezhang and a team July 15, 2020 09:50
@coveralls
Copy link

coveralls commented Jul 15, 2020

Coverage Status

Coverage decreased (-0.004%) to 98.233% when pulling 1d3506b on SukkaW:post-tag-render-optimize into a34a7e2 on hexojs:master.

@SukkaW SukkaW requested a review from curbengh July 15, 2020 14:56
@SukkaW SukkaW mentioned this pull request Jul 16, 2020
22 tasks
curbengh
curbengh previously approved these changes Jul 17, 2020
@@ -5,7 +5,8 @@ const { cyan } = require('chalk');
const { Environment } = require('nunjucks');
const Promise = require('bluebird');
const placeholder = '\uFFFC';
const rPlaceholder = /(?:<|&lt;)!--\uFFFC(\d+)--(?:>|&gt;)/g;
const rPlaceholder = /<!--\uFFFC(\d+)-->/g;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why the previous regex matches &lt; &gt;? I thought <> is only escaped in code block?

Copy link
Member Author

@SukkaW SukkaW Jul 19, 2020

Choose a reason for hiding this comment

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

@curbengh IMHO, the regexp here might be copied from post.js in which the <> will be escaped by post renderer (like marked.js & our highlighter).

But inside tag rendering process, there will be no escape at all.

@SukkaW SukkaW requested a review from curbengh July 19, 2020 05:58
@SukkaW SukkaW force-pushed the post-tag-render-optimize branch 9 times, most recently from 0470503 to cf4ee3c Compare July 19, 2020 10:48
@SukkaW SukkaW marked this pull request as draft July 24, 2020 03:32
@SukkaW SukkaW force-pushed the post-tag-render-optimize branch 3 times, most recently from 91431ec to d477f57 Compare July 24, 2020 06:56
@SukkaW SukkaW marked this pull request as ready for review July 24, 2020 07:53
@SukkaW
Copy link
Member Author

SukkaW commented Jul 24, 2020

@seaoak @curbengh @stevenjoezhang The PR is ready for review now.

@SukkaW SukkaW changed the title Post tag render optimize perf(tag): rendering optimization Jul 24, 2020
Copy link
Contributor

@curbengh curbengh left a comment

Choose a reason for hiding this comment

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

WFM

#### Multi-line raw

{% raw %}
{{ 1+1 }}
{% endraw %}

#### Same line raw

{% raw %}{{ 1+1 }}{% endraw %}

#### Single backquote

`{{ 1+1 }}`

#### Triple backquote

```
{{ 1+1 }}
```

#### Original

{{ 1+1 }}

#### C code

{% codeblock lang:objc %}
[rectangle setX: 10 y: 10 width: 20 height: 20];
{% endcodeblock %}

@SukkaW
Copy link
Member Author

SukkaW commented Jul 24, 2020

WFM

@curbengh A lot of test cases has been added during pre-hexo-5.0.0 development and I am sure most of the case has been covered in unit test now.

@SukkaW SukkaW merged commit 12c3536 into hexojs:master Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants