markdown-model
The markdown-model package is a JavaScript Markdown parser and renderer.
Links
Parsing Markdown
To parse a Markdown document, use the
parseMarkdown
function:
import {parseMarkdown} from 'markdown-model/lib/parser.js';
const markdownModel = parseMarkdown(markdownText);
Note: Markdown documents are parsed as
GitHub Flavored Markdown
(with the exception of HTML blocks).
Rendering Markdown
To render the parsed Markdown in a web browser, use the
markdownElements
function with the
renderElements
function from the
element-model
package:
import {markdownElements} from 'markdown-model/lib/elements.js';
import {renderElements} from 'element-model/lib/elementModel.js';
renderElements(document.body, markdownElements(markdownModel));
Computing the Markdown Title
To compute the title of the parsed Markdown, use the
getMarkdownTitle
function:
import {getMarkdownTitle} from 'markdown-model/lib/parser.js';
const markdownTitle = getMarkdownTitle(markdownModel);
Development
markdown-model is developed using javascript-build
and it was started using javascript-template:
template-specialize javascript-template/template/ markdown-model/ -k package markdown-model -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k noapp 1