Default parser and set of settings for parsing and rendering of Markdown blocks in API Description Documents.
$ npm install blueprint-markdown-renderer
import { renderHtml } from 'blueprint-markdown-render';
const mdText = '# Heading';
const html = renderHtml(mdText);
console.log("Rendered HTML: ", html);
Note that if you alter renderer's settings, you are potentially diverging from the ecosystem, therefore this is not encouraged. However, it's still better to share the same rendering core with customised behaviour than it is to start for the blank slate.
Blueprint Markdown Renderer uses markdown-it under the hood. See markdown-it API Documentation to find all available options how to change renderer.
import { renderHtml, rendererFactory } from 'blueprint-markdown-render';
import emojiPlugin from 'markdown-it-emoji';
const renderer = rendererFactory();
// alter default options
renderer.set({ langPrefix: 'lang-', breaks: true });
// add own plugin
renderer.use(emojiPlugin);
const mdText = ':smiley:';
const html = renderHtml(mdText, {
renderer, // custom renderer
env, // additional data from parsed input (references, for example)
sanitize: true, // run HTML sanitization
});
console.log("Rendered HTML: ", html);
While API Blueprint syntax is based on Markdown, it doesn't care about the (Markdown) content of description blocks. The reference parser actually preserves the source Markdown in the produced API Elements. Same logic applies to
This library is intended to provide a consistent API for parsing those Markdown blocks. Use it to get the same defaults and consistent rendering with the rest of JavaScript API Blueprint ecosystem.
To get consistent experience accross languages, this library uses CommonMark implementation under its hood. Following extensions to default rendering is enabled by default:
- Tables (GFM)
- Strikethrough (GFM)
- Subscript (Pandoc)
- Superscript (Pandoc)
- Lazy Headers (Relaxed ATX Header syntax)
$ npm install
$ npm test
By default, tests are ran on server as well as in the browser, using Karma. To ran manually just one specific type, use:
$ npm run server-test
$ npm run browser-test
This package is using Semantic Release.
Please use proper commit message format.
MIT (see LICENSE
file)
Apiary Czech Republic, s.r.o. [email protected]