add sections to markdown headers
npm install markdown-it-header-sections
Renders this markdown
``md`Header 1
Text.$3
Lorem?Header 3
Ipsum.Last header
Markdown rules!
to this output (without indentation) Text. Lorem? Ipsum. Markdown rules!
`html`
Header 1
Header 2
Header 3
Last header
If you add [attrs], [anchor] or any other plugin that adds attributes to header-tokens, sections will have the same attributes (which is useful for styling).
E.g., with [attrs] enabled before header-sections:
`js`
var md = require('markdown-it')()
.use(require('markdown-it-attrs'))
.use(require('markdown-it-header-sections'))
this markdown
`mdgreat stuff {.jumbotron}
lorem
click me {.btn .btn-default}
`
renders to lorem click me
`md`
great stuff
npm install markdown-it-header-sections
`Usage
`js
var md = require('markdown-it')();
md.use(require('markdown-it-header-sections'));var src = '# first header\n';
src += 'lorem\n\n'
src += '## second header\n';
src += 'ipsum';
console.log(md.render(src));
``
[attrs]: https://github.com/arve0/markdown-it-attrs
[anchor]: https://github.com/valeriangalliat/markdown-it-anchor