Skip to content

coderaiser/happy-mark

Repository files navigation

Happy Mark License NPM version Build Status

image

Markdown to JS AST parser.

Install

npm i happy-mark --save

How to use?

Binary

cat README.md | happy-mark

For full loop use (format detected automatically):

cat README.md | happy-mark | happy-mark

Reference

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'))
![alt](url) 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

About

markdown to js ast parser

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors