Skip to content

Showdown Options

Estevão Soares dos Santos edited this page Feb 6, 2017 · 8 revisions

To learn how to set and get options, please check Showdown's API documentation

omitExtraWLInCodeBlocks

type default since description
boolean false 1.0.0 Omit the trailing newline in a code block

By default, showdown adds a newline before the closing tags in code blocks. By enabling this option, that newline is removed.
This option affects both indented and fenced (gfm style) code blocks.

Example:

input:

    var foo = 'bar';

omitExtraWLInCodeBlocks = false:

<code><pre>var foo = 'bar';
</pre></code>

omitExtraWLInCodeBlocks = true:

<code><pre>var foo = 'bar';</pre></code>

noHeaderId

type default since description
boolean false 1.1.0 Disable the automatic generation of header ids

Showdown generates an id for headings automatically. This is useful for linking to a specific header. This behavior, however, can be disabled with this option.

Example

input:

# This is a header

noHeaderId = false

<h1 id="thisisaheader">This is a header</h1>

noHeaderId = true

<h1>This is a header</h1>

NOTE: Setting to true overrides prefixHeaderId and ghCompatibleHeaderId options

ghCompatibleHeaderId

type default since description
boolean false 1.5.5 Generate header ids compatible with github style

This changes the format of the generated header IDs: spaces are replaced with dashes and a bunch of non alphanumeric chars are removed.

Example

input:

# This is a header with @#$%

ghCompatibleHeaderId = false

<h1 id="thisisaheader">This is a header</h1>

ghCompatibleHeaderId = true

<h1 id="user-content-this-is-a-header-with-">This is a header with @#$%</h1>

prefixHeaderId

type default since description
string | boolean 1.0.0 Add a prefix to the generated header ids

Adds a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting it to true will add a generic 'section' prefix.

Example

input:

# header

prefixHeaderId = false

<h1 id="header">header</h1>

prefixHeaderId = true

<h1 id="sectionheader">header</h1>

prefixHeaderId = 'my prefix'

<h1 id="myprefixheader">header</h1>