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

support parase "[TOC]"? #306

Open
huanglw opened this issue Aug 30, 2018 · 1 comment
Open

support parase "[TOC]"? #306

huanglw opened this issue Aug 30, 2018 · 1 comment

Comments

@huanglw
Copy link

huanglw commented Aug 30, 2018

It seems not support "[TOC]" default?

@CyanGlory
Copy link

you may need this:

wrapper the provided html, and add some script:

<script>
    // add a basic TOC for markdown-js
    const headers = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
    headers.forEach((value, index, array) => {
      const tags = document.getElementsByTagName(value);
      for (let index = 0; index < tags.length; index++) {
        tags[index].setAttribute('id', tags[index].innerText);
      }
    });
  </script>

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