Skip to content

Configure Node.js Rendering

Pass an options object to a render function, or set it once when constructing a Renderer. Use camelCase property names. Unknown keys throw a TypeError so spelling mistakes cannot silently change your output.

Enable the features your content uses

import { type Options, toHtml } from "ferromark";

const options = {
  frontMatter: true,
  headingIds: true,
  footnotes: true,
  tableColgroup: true,
  tableColumnNames: true,
  tableAttributes: true,
} satisfies Options;

const html = toHtml("# Notes\n\nA detail.[^1]\n\n[^1]: More context.", options);

Omitted values use the package defaults. There are no named preset constructors in the Node.js API; configure the individual options directly. To add bare URL and email detection to the default GFM extensions, set autolinkLiterals: true.

Option reference

All properties are optional. Syntax examples and output semantics live in the shared Markdown guide.

OptionDefaultPurpose
renderPolicy'untrusted'Escape raw HTML and check URL schemes; 'trusted' permits passthrough
allowHtmltruePermit raw HTML in trusted output; false escapes it
allowLinkRefstrueResolve reference-style links
tablestrueGFM pipe tables
mergedTableCellsfalseHorizontal cell spans; requires tables
strikethroughtrueDouble-tilde strikethrough
highlightfalseHighlight markup
superscriptfalseSuperscript markup
subscriptfalseSubscript markup
taskListstrueTask-list checkboxes
autolinkLiteralsfalseBare URL, www, and email links
disallowedRawHtmltrueGFM tag filter in trusted mode
footnotesfalseReference footnotes
inlineFootnotesfalseInline footnotes
frontMatterfalseExtract leading YAML/TOML-style front matter
headingIdstrueGenerate heading IDs
mathfalseInline and display math markup
calloutstrueGitHub-style note/warning callouts
definitionListsfalseTerms and descriptions
lineCommentsfalseOmit physical-line-start source comments
linkBasePathunsetEnable site routing for links, images, raw HTML URLs, and .md paths
tableAttributesfalseTable IDs, CSS classes, and captions
tableColgroupfalseCSS-addressable colgroup elements
tableColumnNamesfalseHeader-derived column classes; requires tableColgroup
headingAttributesfalseExplicit heading IDs and classes
wikiLinksfalseWiki-link syntax
cjkEmphasisfalseCJK emphasis rules
mdxfalseMDX syntax capture and static island output

The published TypeScript declarations are the complete API contract and power editor autocomplete.

Preserve trusted HTML

import { toHtml } from "ferromark";

const html = toHtml('<span class="note">Internal note</span>', {
  renderPolicy: "trusted",
});

Use this only for content you trust. It also permits arbitrary URL schemes. The default disallowedRawHtml filter still removes GFM-disallowed tags; it is not an HTML sanitizer. See rendering and trust.

Next: HTML, metadata, and reusable renderers.