Spanish Total.js
English
Documentation For AI agents
Contents

Markdown

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

.md GitHub
On this page

API

method

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

Converts a Markdown string to HTML.
ParameterTypeDescription
options? Object Options, see the table. Default: {}
nested? Boolean Leaves out the markdown-container class. Default: false

Returns String HTML.

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

OptionDescription
wrapWraps the output in <div class="markdown markdown-container">
linetagTag of paragraphs, default 'p'; an empty string gives plain lines
bookmarksAdds an id made from the text to headings
prefixText before the id of headings
headlines, ul, tables, code, blockquotes, sections, hr, blocksBlock syntax
formatting, links, images, icons, keywords, footnotes, urlify, brInline syntax (urlify turns plain URLs into links, br keeps
)
emptynewlineTwo empty lines give
customfunction(line) that changes each line before it is parsed
htmlfunction(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.

Article
var html = article.body.markdown();
Plain fragment
'**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>'
type

Markdown syntax

Markdown supported by String.prototype.markdown(), with the Total.js extensions.
SyntaxResult
# Title … ##### Title<h1> … <h5> with an id
**text**, *text*<strong>, <em>
__text__, _text_, ~~text~~<b>, <u>, <strike>
code and js blockscode, <pre>code class="lang-js"`
- item, * item, + item, 1. item, a. itemLists; a tab nests them; [ ] and [x] make tasks
| a | b | with a |---|--:| lineA table with left, right or center columns
> text<blockquote>
< text<section>
---, ***<hr>
[text](url), alt, altLinks (external ones open in a new tab; e-mails and phone numbers get mailto: and tel:) and lazy images
alt, altAn image without img-responsive, a gallery image
, Icons
text<span class="markdown-keyword" data-type="type">
[1](#1) and #1: textA footnote and its body
::: Title … :::An expandable block
Made in Europe