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(#135): filter was executed before it was loaded #175

Merged
merged 2 commits into from
Feb 4, 2022

Conversation

ewfian
Copy link
Contributor

@ewfian ewfian commented Feb 2, 2022

The filter won't be work after upgrade to v6.0.0

The hexo loadScripts after loadModules
image

When this plugin being required and loaded by loadModules, the Renderer constructed and the filter markdown-it:renderer was executed at this time.

hexo.execFilterSync('markdown-it:renderer', this.parser, { context: this });

But the script that contains implementation of filter was loaded by loadScripts. So that, the filter has no chance to run.

I had checked how this mechanisms be implemented in another similar plugin hexo-renderer-marked. and the code in v5.0.0

I found that the filter should be executed when each render processed.

BTW: The hexo-renderer-marked execFilter in render process.

BTW2: Another way to fix this issue:
Wrap the execFilter with before_post_render

hexo.extend.filter.register('before_post_render', () => {
    hexo.execFilterSync('markdown-it:renderer', this.parser, { context: this });
});

Copy link
Member

@yoshinorin yoshinorin left a comment

Choose a reason for hiding this comment

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

Thank you very much :)

@yoshinorin yoshinorin merged commit 7bf600b into hexojs:master Feb 4, 2022
@yoshinorin
Copy link
Member

@ewfian
We published a new version 6.0.1.
Thank you :)

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.

2 participants