fix(#135): filter was executed before it was loaded #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The filter won't be work after upgrade to v6.0.0
The hexo loadScripts after loadModules
When this plugin being required and loaded by loadModules, the
Renderer
constructed and the filtermarkdown-it:renderer
was executed at this time.hexo-renderer-markdown-it/lib/renderer.js
Line 47 in 4d4d4bd
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