markdownscript
v1.3.0
Published
Creates markdown Abstract Syntax Tree
Downloads
110
Maintainers
Readme
markdownscript
Creates markdown Abstract Syntax Tree
Installation
npm i -S markdownscript
Usage
'use strict'
const m = require('markdownscript')
const heading = m.heading
const paragraph = m.paragraph
const ast = heading({ depth: 1 }, [
paragraph(['Hello world!']),
])
console.log(JSON.stringify(ast, null, 2))
//> {
// "type": "heading",
// "children": [
// {
// "type": "paragraph",
// "children": [
// {
// "type": "text",
// "value": "Hello world!"
// }
// ]
// }
// ],
// "depth": 1
// }
API
m(type, [attributes], [children])
- create a node
console.log(m('link', { url: 'http://google.com' }, ['Google']))
//> { type: 'link',
// children: [ { type: 'text', value: 'Google' } ],
// url: 'http://google.com' }
m.[type]([attributes], [children])
- create a node
const code = m.code
console.log(code({ lang: 'js' }, ['void 0']))
//> { type: 'code',
// children: [ { type: 'text', value: 'void 0' } ],
// lang: 'js' }
m.h[depth]([attributes], [children])
- create a heading node of the specified depth
const h3 = m.h3
console.log(h3([paragraph(['Foo bar'])]))
//> { type: 'heading',
// children: [ { type: 'paragraph', children: [Object] } ],
// depth: 3 }
License
Dependencies
- babel-runtime: babel selfContained runtime
Dev Dependencies
- babel-cli: Babel command line.
- babel-plugin-add-module-exports: Fix babel/babel#2212
- babel-plugin-transform-runtime: Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals
- babel-preset-es2015: Babel preset for all es2015 plugins.
- babel-preset-stage-0: Babel preset for stage 0 plugins
- babel-register: babel require hook
- chai: BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
- cz-conventional-changelog: Commitizen adapter following the conventional-changelog format.
- eslint: An AST-based pattern checker for JavaScript.
- eslint-config-standard: JavaScript Standard Style - ESLint Shareable Config
- eslint-plugin-promise: Enforce best practices for JavaScript promises
- eslint-plugin-standard: ESlint Plugin for the Standard Linter
- ghooks: Simple git hooks
- istanbul: Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests
- mocha: simple, flexible, fun test framework
- mos: A pluggable module that injects content into your markdown files via hidden JavaScript snippets
- semantic-release: automated semver compliant package publishing
- tonic-example: Tonic example generator
- validate-commit-msg: Script to validate a commit message follows the conventional changelog standard