-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Token stream must stay immutable after renderer call #260
Comments
I took the sample markdown file on the homepage to see which plugins may also be mutating the token stream and found only two:
Markdown-it-container, after two passes, yields:
Markdown-it-named-headers, after two passes, yields:
Just with ever header element. I'm curious how they implement this. Maybe there is a way to fix their as well, though it's probably best to place a issue request on their respective repos. One last thing, I added the code: it("2Pass: " + fixture.header && options.head ? fixture.header : 'line ' + (fixture.first.range[0] - 1), function () {
var tokens = md.parse(fixture.first.text, md.options);
var render1 = md.renderer.render(tokens, md.options, {});
var render2 = md.renderer.render(tokens, md.options, {});
options.assert.strictEqual(render1, render2);
}); to markdown-it-testgen here and found that everything passes except for |
Can this issue be closed? |
I haven't tested it but I trust you got it right, I can let you know if I run into troubles again. |
Released 6.1.0 with fix. Closing now. Feel free to create new issue if any problems still exists. |
I've looked at About Probably, we need to invent better solution to extend attrs output in render without mutation, but no good ideas right now. Cloning works, but is not effective. May be second optional param in attr renderer... need to think... |
I remember reading #28 awhile back. It was a good post to read to understand the complexities involved with named headers in markdown. I believe that the HTML5 I took another look at how vscode is using markdown-it in their recent merge, and I came to realize that there seems to be no use whatsoever of the named headers. Certainly some users may want to compile their markdown with named headers, but this probably isn't something that belongs in the preview mode. I suspect that there was an idea of creating links for the headers so that clicking the link will send you back to the source (which could be a useful feature), but the correct route would be to use the source maps similar to what you did to sync the scrolls. |
See details in #259
The text was updated successfully, but these errors were encountered: