Fix-65575 MarkdownIt plugins (or Rules) called multiple times for one input#65953
Fix-65575 MarkdownIt plugins (or Rules) called multiple times for one input#65953mjbvz merged 4 commits intomicrosoft:masterfrom
Conversation
There was a problem hiding this comment.
Thanks for taking a look. I think this needs some more work though so that it won't cause regressions:
-
The cache needs to use the document uri as the key for storing the tokens. One way to do this would be to create a new private method called
tokenizeor something like that that bothrenderandparsecall into. Thetokenizemethod would check the cached tokens to see if they are valid for the current document. If they are, it would use these. Otherwise, it would compute and cache the tokens for the new document -
However there is also a small difference in
renderandparse:parsealways strips out markdown yaml front-matter whilerenderonly strips the front-matter if a setting is configured. One way to preserve this behavior would be to run markdown-itsrenderon the tokens without the front matter and then add the front matter back on to the html output
Let me know if that makes sense
|
@mjbvz , Cool , this sounds good and makes sense , I am working on it and update you on the progress. Thanks for the review :) |
|
@mjbvz , I have changed it as per your review , Please review it now and let me know if this is good or something needs to be changed , Happy to correct it (Just want to make sure it is good). |
mjbvz
left a comment
There was a problem hiding this comment.
Looks light the right direction. Please take a look my comments and let me know if they make sense
… newly created token and cache it
|
Thanks! Will make a few tweaks to this but approach looks good |
@mjbvz , here is the initial PR based on my understanding to fix #65575 , I have added CachedToken and implementation to use it.
Please review this and let me know if anything is missing or not correct, I will correct it accordingly, Thanks :)