Skip to content
Ferromark

Ferromark / Node.js

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 = {
  insertions: true,
  frontMatter: true,
  headingIds: true,
  footnotes: true,
  tableColgroup: true,
  tableColumnNames: true,
  tableAttributes: true,
  imageAttributes: true,
  imageCaptions: true,
  extendedAttributes: true,
  bracketedSpans: true,
  blockquoteAttributions: true,
  autoAbbreviations: true,
  abbreviations: { API: "Application Programming Interface", GraphQL: "", README: null },
} satisfies Options;

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

Omitted values use the package defaults. Set preset: "ffm" to start from Ferromark Flavored Markdown instead: it enables the FFM syntax and technical abbreviation markup, while individual options still override it and the output policy stays unchanged. To add bare URL and email detection to the default GFM extensions, set autolinkLiterals: true. Typography is also explicit: set typography: { language: "en" } (or another supported language) to run the built-in post-parse typography pass. It is off when omitted and never detects or switches languages. autoAbbreviations adds optional render-time <abbr> markup for technical terms. Its exact override map can set titles, force a bare wrapper with an empty string, or suppress a term with null; supplying the map alone does not enable the feature. Empty override keys are ignored. See the technical abbreviation guide.

Option reference

All properties are optional. Syntax examples and output semantics live in the FFM guide, with the CommonMark and GFM baseline in Markdown syntax.

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
insertionsfalseDouble-plus inserted text rendered as <ins>
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
headingOffset0Shift rendered heading levels; results clamp to h1–h6
headingIdPrefixunsetPrefix heading IDs and permalink fragments; letters, digits, _, -
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
imageAttributesfalseImage IDs and CSS classes
imageCaptionsfalseSeparate captions on standalone images
blockquoteAttributionsfalseVisible sources after block quotes
extendedAttributesfalseShared key/value suffixes on links, images, headings, tables, figures
bracketedSpansfalseNative [text]{attributes} inline spans
tableColgroupfalseCSS-addressable colgroup elements
tableColumnNamesfalseHeader-derived column classes; requires tableColgroup
headingAttributesfalseExplicit heading IDs and classes
cjkEmphasisfalseCJK emphasis rules
mdxfalseMDX syntax capture and static island output
guillemetDigraphsfalsePreserve <<…>> for locale-aware typography
typographyunsetOptional language-aware prose punctuation transform
passesunsetOrdered GitHub-reference, emoji-shortcode, and typography transforms
autoAbbreviationsfalseWrap uppercase technical terms in <abbr> markup
abbreviationsemptyExact titles, bare-wrapper overrides, or null suppressions
presetunset"ffm" starts from Ferromark Flavored Markdown; options still override

Use passes when you need more than one transform or need to control their order. Its entries use kind: "githubReferences" (with an explicit repository), kind: "emojiShortcodes", or kind: "typography". Do not set the separate typography option at the same time; put typography in passes to make its position explicit.

typography requires a language from en, es, fr, pt, de, it, nl, pl, ru, or uk. The dashes and ellipses switches can disable those conversions independently. See the typography guide for examples, locale rules, and protected syntax.

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.