markdown-js icon indicating copy to clipboard operation
markdown-js copied to clipboard

support parase "[TOC]"?

Open huanglw opened this issue 7 years ago • 1 comments

It seems not support "[TOC]" default?

huanglw avatar Aug 30 '18 07:08 huanglw

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>

CyanGlory avatar Sep 23 '18 10:09 CyanGlory