https://github.com/arve0/markdown-it-header-sections
similar to pandoc's --section-divs for markdown-it
https://github.com/arve0/markdown-it-header-sections
Last synced: 20 days ago
JSON representation
similar to pandoc's --section-divs for markdown-it
- Host: GitHub
- URL: https://github.com/arve0/markdown-it-header-sections
- Owner: arve0
- Created: 2015-07-18T19:52:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-02-27T21:25:53.000Z (about 1 year ago)
- Last Synced: 2025-04-26T21:05:51.542Z (27 days ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 19
- Watchers: 2
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# markdown-it-header-sections [](https://travis-ci.org/arve0/markdown-it-header-sections) [](http://badge.fury.io/js/markdown-it-header-sections)
Renders this markdown
```md
# Header 1
Text.
### Header 2
Lorem?
## Header 3
Ipsum.
# Last header
Markdown rules!
```to this output (without indentation)
```html
Header 1
Text.
Header 2
Lorem?
Header 3
Ipsum.
Last header
Markdown rules!
```
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
```md
# great stuff {.jumbotron}
loremclick me {.btn .btn-default}
```renders to
```md
great stuff
lorem
click me
```
## Install
```
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));
```[demo as jsfiddle](https://jsfiddle.net/arve0/5dn54cow/1/)
[attrs]: https://github.com/arve0/markdown-it-attrs
[anchor]: https://github.com/valeriangalliat/markdown-it-anchor