happy-mark
v1.5.0
Published
markdown to js ast parser
Readme
Happy Mark

Markdown to JS AST parser.
Install
npm i happy-mark --saveHow to use?
Binary
cat README.md | happy-markFor full loop use (format detected automatically):
cat README.md | happy-mark | happy-markReference
Happy Mark converts Markdown to JavaScript this way:
| Markdown | Becomes |
|----------------|----------------------------------|
| # Heading | heading(1, 'Heading') |
| Some text | paragraph('Some text') |
| **bold** | paragraph(bold('bold')) |
| - one\n- two | ul(li('one'), li('two')) |
| > quote | blockquote(paragraph('quote')) |
|  | paragraph(image('alt', 'url')) |
| [text](url) | link('text', 'url') |
API
import {
convertMarkdownToJs,
convertJsToMarkdown,
} from 'happy-mark';
import {montag} from 'montag';
const source = montag`
# hello
Hello world
\`\`\`js
const a = 3;
\`\`\`
`;
const js = convertMarkdownToJs(source);
// returns
`
[
header(1, 'hello'),
paragraph('Hello world'),
codeblock('js', 'const a = 3;'),
];
`;
convertJsToMarkdown(js);
// returns
`
# hello
Hello world
\`\`\`js
const a = 3;
\`\`\`
`;License
MIT
