Table of Contents Generator
Node.js server side Table of Content (TOC) generator. Produce valid HTML5 code.
Examples
const makeToc = const content = ` <p>Long long long text</p> [TOC] <h2>Some title</h2> <p>Long long long text</p> <h2>Other Title</h2> <p>Long long long text</p> <p>Long long long text</p> <h3>Sub title 1</h3> <p>Long long long text</p> <h3>Sub title 2</h3> <p>Long long long text</p> <h2>Title</h2> <p>Long long long text</p>`
Output:
Long long long text СодержаниеSome titleOther TitleSub title 1Sub title 2Title Some title Long long long text Other Title Long long long text Long long long text Sub title 1 Long long long text Sub title 2 Long long long text Title Long long long text
- If we pass null to config.bbCode – it always generates TOC at the beginning of content.
- If we pass some string to config.bbCode – it only generates TOC if content contains this BBCode. And if it finds BBCode, then TOC will be paste in place of this BBCode.
License
MIT