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

TOC regex pattern should be matched on the state.src only from the current position parsed #35

Closed
GiridharanNarayanan opened this issue Aug 16, 2018 · 2 comments

Comments

@GiridharanNarayanan
Copy link
Contributor

GiridharanNarayanan commented Aug 16, 2018

Issue:

  • Multiple TOCs equal to the number of "[" in the same state.src as that of the state which contains [[toc]].
  • This is because we do the regex match on the whole src instead of the substring of the src from the position which we are currently processing.

Solution:

  • Match the regex only from the position we are currently processing in the state.
  • I shall raise a PR if you ack this as an issue.

RunKit example. The highlighted "[" is causing the second TOC to be rendered.

image

GiridharanNarayanan added a commit to GiridharanNarayanan/markdown-it-table-of-contents that referenced this issue Aug 17, 2018
@GiridharanNarayanan
Copy link
Contributor Author

Have created a PR #36

martinlissmyr pushed a commit that referenced this issue Aug 17, 2018
@martinlissmyr
Copy link
Collaborator

Thanks! 👏

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

No branches or pull requests

2 participants