Skip to content

Fix-65575 MarkdownIt plugins (or Rules) called multiple times for one input#65953

Merged
mjbvz merged 4 commits intomicrosoft:masterfrom
skprabhanjan:fix-65575
Jan 10, 2019
Merged

Fix-65575 MarkdownIt plugins (or Rules) called multiple times for one input#65953
mjbvz merged 4 commits intomicrosoft:masterfrom
skprabhanjan:fix-65575

Conversation

@skprabhanjan
Copy link
Contributor

@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 :)

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

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 tokenize or something like that that both render and parse call into. The tokenize method 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 render and parse: parse always strips out markdown yaml front-matter while render only strips the front-matter if a setting is configured. One way to preserve this behavior would be to run markdown-its render on 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

@skprabhanjan
Copy link
Contributor Author

skprabhanjan commented Jan 4, 2019

@mjbvz , Cool , this sounds good and makes sense , I am working on it and update you on the progress. Thanks for the review :)

@skprabhanjan
Copy link
Contributor Author

@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).
Thanks :)

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

Looks light the right direction. Please take a look my comments and let me know if they make sense

@mjbvz mjbvz merged commit 9140285 into microsoft:master Jan 10, 2019
@mjbvz mjbvz added this to the December/January 2019 milestone Jan 10, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 10, 2019

Thanks! Will make a few tweaks to this but approach looks good

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MarkdownIt plugins (or Rules) called multiple times for one input

3 participants