1.0.1 • Published 9 years ago
markdown-extractor v1.0.1
markdown-extractor
Get everythings from markdown document
node: ^0.10.40
npm: ^1.4.28Install
$ npm install markdown-extractorUsage
NodeJS
var mdext = require('markdown-extractor');
console.log(mdext.heading("> Get lots of heading in document\n# Heading\n## Sub heading"));
// Output: [{ type: 'h1', data: 'Heading' }, { type: 'h2', data: 'Sub heading' }]Browser
Add script in ./lib/markdown-extractor.js
<script src="./lib/markdown-extractor.js"></script>In script using
console.log(mdext.heading("> Get lots of heading in document\n# Heading\n## Sub heading"));
// Output: [{ type: 'h1', data: 'Heading' }, { type: 'h2', data: 'Sub heading' }]Demo
API
mdext.heading(content)
Get headings from content. The result is array object. Each object have two field type and data.
Example:
console.log(mdext.heading("# Heading\n## Sub heading"));
// Output: [{ type: 'h1', data: 'Heading' }, { type: 'h2', data: 'Sub heading' }]mdext.metadata(content)
Get metadata from content. The result is object key: value
Example:
console.log(mdext.metadata("Outside <!--metadata\ntitle: Hello\ndescription: Love u\n-->\nOutside"));
// Output: {title: 'Hello', description: 'Love u'}Note: Metadata in markdown document must had structure like:
<!--metadata
key1: value1
key2: value2
-->LICENSE
MIT