Skip to main content

module @markdown

The module provides Markdown related services.

functions:

toHTML()

const html = markdown.toHTML(markdown, options);

Returns html string converted from the markdown source.

Parameters:

  • markdown - either string or ArrayBuffer, MD text;
  • options - optional object, see;

Returns string - HTML text.

toElement()

markdown.toElement(container, markdown, options);

Parses markdown text directly into DOM element bypassing HTML parsing phase.

Parameters:

  • container - DOM Element that will contain parsed content;
  • markdown - either string or ArrayBuffer, MD text;
  • options - optional object, see;

Returns true in case of success.

toFragment()

markdown.toFragment(markdown, options);

Parses markdown text into VDOM fragment that is ready to be used in Reactor components, for example as:

function Markdown({md}) {
return <section styleset="markdown.css#markdown">
{ MD.toFragment(md) }
</section>;
}

Parameters:

  • markdown - either string or ArrayBuffer, MD text;
  • options - optional object, see;

Returns VDOM fragment : <>...md content here...</>.

options

An object that defines parsing flags:

  • indentedCodeBlocks - bool, true (default) - supports indented code blocks;
  • tables - bool, true (default) - supports Table extension;
  • taskLists - bool, true (default) - supports Task Lists extension;
  • superscripts - bool, true (default) - supports superscript extension;
  • subscripts - bool, true (default) - supports subscript extension;
  • admonitions, bool, true (default) - supports [GitHub admonition] (https://www.markdownlang.com/advanced/github.html#alerts) and Docusaurus admonitions;
  • footnotes - not yet;
  • highlight - bool, true (default) - supports highlight extension;
  • strikethrough - bool, true (default) - supports strikethrough extension;
  • blockIdClass - bool, true (default) - supports Heading ID extension with optional class name as {#myid .myclass}
  • spanIdClass - bool, true (default) - supports Span ID and Classes extension as [span text]{#myid .myclass}.
  • _spoilers - not yet;
  • _defintionLists - not yet;
  • embeddedHTML - bool, true (default) - supports embedded HTML blocks and spans;
  • URL - string, URL of the markdown document. The URL is used to resolve relative links and image URLs.