select-section
Cut out sections from TxtAST or mdast.
Section?
A section is slitted by Header Node.
This rule defined section as following:
The Markdown contents
# Header1
text.
# Header2
text.
to be
------------|---- # Header 1
|
Section1 | text.
|
------------|---- # Header 2
|
Section2 | text.
|
------------|---------------
A section is slitted by Header Node.
This rule defined section as following:
The Markdown contents
# Header1
text.
## Header2
text.
to be
--------------------------|---- # Header 1
|
Section1 | text.
|
--------------|---- ## Header 2
- -|
- Section2 -| text.
- -|
--------------------------|---------------
Tree view:
└── _Section1_
├── # Header 1
├── text.
└── _Section2_
├── ## Header 2
└── text.
Install
Install with npm:
npm install select-section
Usage
Create "Section" node that compatible with TxtAST.
const createSections = require("select-section");
const parse = require("markdown-to-ast").parse;
const AST = parse(`# Header
text1
text1
# Header
text2
text2`);
const results = createSections(AST);
Example
Changelog
See Releases page.
Running tests
Install devDependencies and Run npm test
:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
License
MIT © azu