Fenced Code Blocks

If enabled in the Behavior preferences, fenced code blocks in your document will be rendered. Fenced code blocks are delimited by three or more tildes (~) or backticks (`). You can use more than three, but the beginning and ending delimiters must have exactly the same number of characters.

Some code to be rendered as a pre/code block

Languages may be specified using the language title (or short title) after the delimiter in the first line, or in curly brackets (with or without a leading period) after the last delimeter. For example:

some ruby code

Will render as:

<pre><code class="ruby">some ruby code</code></pre>

Or with backticks:

some Java code

Marked can detect both Markdown Extra/Python Markdown ({.lang} after closing fence) and Discount (lang after first fence) language specifications. The following (Discount format) would create the same result as the above (Python Markdown format):

some Java code

Marked also handles indented fenced code blocks so you can use them within nested lists.

The built in syntax highlighting will recognize 41+ different language specifiers. If there is no language specified, it will detect it automatically, so it’s not required for the preview. The language string given will be output in the final html as a class on the <code> tag.

See the section on Marked Special Syntax to learn how to include external code files in your document.

Search | Support Site | Knowledgebase