Usage
Basic Options
These options control the Markdown syntax style used for common elements.string
default:"setext"
The style to use for headings.Valid values:
setext- Uses underlines for h1 and h2 (h1 uses=, h2 uses-)atx- Uses#symbols for all heading levels
string
default:"* * *"
string
default:"*"
The character to use for unordered list items.Valid values:
-, +, or *string
default:"indented"
The style to use for code blocks.Valid values:function hello()
indented- Uses 4-space indentationfenced- Uses code fences with backticks
string
default:"```"
The fence character to use for fenced code blocks.Only used when
codeBlockStyle is fenced.Valid values: ``` or ~~~string
default:"_"
The delimiter to use for emphasis (italic) text.Valid values:
_ or *string
default:"**"
The delimiter to use for strong (bold) text.Valid values:
** or __string
default:"inlined"
The style to use for links.Valid values:
inlined- Places URL directly in the linkreferenced- Uses reference-style links with definitions at the bottom
string
default:"full"
The style to use for reference links.Only used when
linkStyle is referenced.Valid values:full- Uses numeric referencescollapsed- Uses empty square bracketsshortcut- Uses link text as reference
string
default:" "
The string to use for line breaks (
<br> elements).Default is two spaces (CommonMark line break syntax).boolean
default:"false"
Whether to preserve whitespace in code blocks.When
true, prevents collapsing of whitespace in <pre> elements.See collapse-whitespace issue #16 for details.Advanced Options
These options provide fine-grained control over special conversion cases using custom replacement functions.function
default:"See below"
A function that determines how blank elements should be converted.A blank element contains only whitespace and is not an The default returns two newlines for block elements and an empty string for inline elements.
<a>, <td>, <th>, or void element.Function signature: function(content, node)Default implementation:function
default:"See below"
A function that determines how elements marked with The default surrounds block-level elements with blank lines.
keep() should be rendered.Elements marked with keep() are rendered as HTML in the Markdown output.Function signature: function(content, node)Default implementation:function
default:"See below"
A function that handles elements not matched by any rule.This is the fallback for unrecognized elements.Function signature: The default outputs the element’s text content, surrounded by blank lines if it’s a block element.
function(content, node)Default implementation:Complete Example
Here’s an example using multiple options:Options can only be set during instantiation. To use different options, create a new TurndownService instance.