---
title: Markdown
project: Total.js V4
version: 0.0.99
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v4/0-0-99/guides/markdown/
updated: 2026-11-16T15:41:20.819Z
---

# Markdown

> Convert Markdown to HTML with String.markdown() and choose what it produces with its options.

Every string has the method `markdown([opt])`, which returns HTML:

```js
var html = '# Hello\n\nThis is **bold**, _underlined_ and `code`.\n\n- one\n- two\n\t- nested'.markdown();
```

The parser supports headlines (`#` to `#####`), lists with `-`, `*` or `+` and ordered lists (`1.` or `a.`), task lists (`- [x] done`), tables with alignment, code blocks with a language, blockquotes (`> `), sections (`< `), collapsible blocks between `:::` lines, horizontal lines (`---`, `***`), images (`![alt](url)`, `![+alt](url)` without the responsive class, `![-alt](url)` for a gallery), links, footnotes (`[1](#1)` and `#1: text`), keywords (`{text}(type)`), icons (`:ti-home:` or `:fa fa-home:`), and links detected in plain text. Links to an e-mail address or a phone number become `mailto:` and `tel:` links.

HTML in the source is always encoded, so the output is safe to put into a page. Every block has the class `markdown-line` and its line number, which helps you style the output and map it back to the source.

Options change the output:

```js
var html = text.markdown({
	wrap: false,          // no <div class="markdown markdown-container">
	linetag: 'div',       // tag of normal lines (default 'p')
	bookmarks: true,      // id="..." for headlines (default true)
	prefix: 'help-',      // prefix of those ids
	tables: false,        // turn off a feature
	html: function(line, type) {
		return type === '#' ? line.toUpperCase() : line;
	}
});
```

Every feature can be turned off with `false`: `headlines`, `ul`, `code`, `images`, `links`, `formatting`, `icons`, `tables`, `br`, `hr`, `blockquotes`, `sections`, `blocks`, `footnotes`, `urlify`, `keywords` and `emptynewline`. The `custom` function changes each raw line before formatting, so you can add your own syntax.
