markdown-model
v2.2.15
Published
Markdown object model, parser, and renderer
Downloads
1,088
Readme
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
This package is developed using javascript-build. It was started using javascript-template as follows:
template-specialize javascript-template/template/ markdown-model/ -k package markdown-model -k name 'Craig A. Hobbs' -k email '[email protected]' -k github 'craigahobbs' -k noapp 1