---
title: Markdown
project: Total.js V5
version: 0.0.20
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v5/0-0-20/reference/markdown/
updated: 2026-11-18T16:57:24.576Z
---

# Markdown

> String.prototype.markdown() and the Markdown syntax.

## API

### String.prototype.markdown([options], [nested])

Type: `method`

Converts a Markdown string to HTML.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `options` | `Object` | no | `{}` | Options, see the table. |
| `nested` | `Boolean` | no | `false` | Leaves out the `markdown-container` class. |

Returns: `String` HTML.

Every option is on by default; set it to `false` to skip that syntax.

| Option | Description |
| --- | --- |
| `wrap` | Wraps the output in `<div class="markdown markdown-container">` |
| `linetag` | Tag of paragraphs, default `'p'`; an empty string gives plain lines |
| `bookmarks` | Adds an `id` made from the text to headings |
| `prefix` | Text before the `id` of headings |
| `headlines`, `ul`, `tables`, `code`, `blockquotes`, `sections`, `hr`, `blocks` | Block syntax |
| `formatting`, `links`, `images`, `icons`, `keywords`, `footnotes`, `urlify`, `br` | Inline syntax (`urlify` turns plain URLs into links, `br` keeps `<br>`) |
| `emptynewline` | Two empty lines give `<br />` |
| `custom` | `function(line)` that changes each line before it is parsed |
| `html` | `function(text, type)` that changes the text of a block; `type` is `'#'`…`'#####'`, `'li'`, `'blockquote'`, `'section'`, `'block'` or the line tag |

`<` and `>` in the source are encoded, so raw HTML is not passed through; a text in angle brackets, such as `<www.totaljs.com>`, becomes a link. With `nested: true` the wrapper has only the class `markdown`.

Example: Article
```js
var html = article.body.markdown();
```

Example: Plain fragment
```js
'**Note:** see [docs](https://docs.totaljs.com)'.markdown({ wrap: false, linetag: '' });
// '<strong>Note:</strong> see <a href="https://docs.totaljs.com" target="_blank">docs</a>'
```

### Markdown syntax

Type: `type`

Markdown supported by `String.prototype.markdown()`, with the Total.js extensions.

| Syntax | Result |
| --- | --- |
| `# Title` … `##### Title` | `<h1>` … `<h5>` with an `id` |
| `**text**`, `*text*` | `<strong>`, `<em>` |
| `__text__`, `_text_`, `~~text~~` | `<b>`, `<u>`, `<strike>` |
| `` `code` `` and ```` ```js ```` blocks | `<code>`, `<pre><code class="lang-js">` |
| `- item`, `* item`, `+ item`, `1. item`, `a. item` | Lists; a tab nests them; `[ ]` and `[x]` make tasks |
| `\| a \| b \|` with a `\|---\|--:\|` line | A table with `left`, `right` or `center` columns |
| `> text` | `<blockquote>` |
| `< text` | `<section>` |
| `---`, `***` | `<hr>` |
| `[text](url)`, `![alt](url)`, `[![alt](img)](url)` | Links (external ones open in a new tab; e-mails and phone numbers get `mailto:` and `tel:`) and lazy images |
| `![+alt](url)`, `![-alt](url)` | An image without `img-responsive`, a gallery image |
| `:check:`, `:ti ti-user:` | Icons |
| `{text}(type)` | `<span class="markdown-keyword" data-type="type">` |
| `[1](#1)` and `#1: text` | A footnote and its body |
| `::: Title` … `:::` | An expandable block |
