---
title: Markdown
project: Total.js V4
version: 0.0.99
section: reference
language: de
license: MIT
url: https://totaljs.es/docs/de/total-js-v4/0-0-99/reference/markdown/
updated: 2026-11-18T16:57:49.579Z
---

# Markdown

> String.markdown() und seine Optionen.

## API

### String.markdown([opt])

Type: `method`

Wandelt einen Markdown-String in HTML um.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `opt` | `Object` | no | `{}` | Optionen: `wrap`, `linetag`, `bookmarks`, `prefix`, `html`, `custom` und die oben aufgeführten Schalter für Funktionen. |

Returns: `String` HTML.

Das Framework lädt den Parser beim Start, daher hat jeder String diese Methode. HTML-Tags im Quelltext werden kodiert. Jeder Block bekommt die Klasse `markdown-line` und seine Zeilennummer in `data-line` (`data-index` bei Überschriften). Standardmäßig wird die Ausgabe in `<div class="markdown markdown-container">` eingeschlossen, und Tabs werden zu vier Leerzeichen.

Jede Funktion lässt sich mit `false` in `opt` abschalten: `headlines`, `ul` (Listen), `code`, `images`, `links`, `formatting`, `icons`, `tables`, `br`, `hr`, `blockquotes`, `sections`, `blocks`, `footnotes`, `urlify`, `keywords` und `emptynewline`. Aufzählungslisten können mit `-`, `*` oder `+` beginnen. Links zu einer E-Mail-Adresse oder einer Telefonnummer werden zu `mailto:`- und `tel:`-Links.

Example: Eine README rendern
```js
var html = '# Hello\n\n- one\n- two\n\nWrite to [us](info@company.com).'.markdown();
```

Example: Nur einfache Formatierung
```js
var html = text.markdown({ tables: false, code: false, images: false, wrap: false });
```

### String.markdown({ wrap: Boolean })

Type: `property`

Schließt die Ausgabe in einen `div`-Container ein.

Returns: `Boolean` Standard `true`.

Mit `true` ist die Ausgabe `<div class="markdown markdown-container">...</div>`. Nutze `false`, um das HTML in dein eigenes Element einzufügen.

Example: Ohne Container
```js
var html = '**Bold** text'.markdown({ wrap: false });
// <p class="markdown-line" data-line="0"><strong>Bold</strong> text</p>
```

### String.markdown({ linetag: String })

Type: `property`

Das Tag einer normalen Absatzzeile.

Returns: `String` Standard `'p'`.

Jede Zeile, die keine Überschrift, Liste, Tabelle oder kein anderer Block ist, wird in dieses Tag eingeschlossen. Ein leerer String schreibt die Zeilen ohne Tag.

Example: Zeilen als div
```js
var html = text.markdown({ linetag: 'div' });
```

### String.markdown({ bookmarks: Boolean })

Type: `property` · Since: `0.0.96`

Fügt Überschriften eine `id` hinzu (ein Slug des Textes).

Returns: `Boolean` Standard `true`.

`# Hello world` wird zu `<h1 id="hello-world" ...>`, sodass du auf `#hello-world` verlinken kannst. Setze `false`, um die `id` wegzulassen.

Example: Überschriften ohne id
```js
var html = '# Title'.markdown({ bookmarks: false, wrap: false });
// <h1 class="markdown-line" data-index="0">Title</h1>
```

### String.markdown({ prefix: String })

Type: `property` · Since: `0.0.96`

Ein Präfix für die `id` von Überschriften.

Returns: `String` Standard `''`.

Nützlich, wenn mehrere Markdown-Dokumente auf einer Seite stehen und ihre Überschriften dieselbe `id` bekämen.

Example: Lesezeichen mit Präfix
```js
var html = '# Hello world'.markdown({ prefix: 'doc-' });
// <h1 id="doc-hello-world" ...>
```

### String.markdown({ html: function(line, type) })

Type: `delegate`

Ändert das HTML eines Blocks, bevor es geschrieben wird.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `line` | `String` | yes |  | Der Inhalt des Blocks. |
| `type` | `String` | yes |  | Der Blocktyp. |

Returns: `String` Der neue Inhalt.

Wird mit dem Inhalt und dem Blocktyp aufgerufen: `#` bis `#####` für Überschriften, `li`, `blockquote`, `section`, `block` oder der Wert von `linetag` für normale Zeilen. Gib den neuen Inhalt zurück.

Example: h1 in Großbuchstaben
```js
var html = text.markdown({ html: function(line, type) {
	return type === '#' ? line.toUpperCase() : line;
}});
```

### String.markdown({ custom: function(line) })

Type: `delegate`

Ändert jede rohe Zeile, bevor die Inline-Formatierung angewendet wird.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `line` | `String` | yes |  | Eine Zeile der Quelle. |

Returns: `String` Die neue Zeile.

Nutze es für deine eigene Inline-Syntax. Die Zeile ist bereits HTML-kodiert. Gib die neue Zeile zurück.

Example: Einen Platzhalter ersetzen
```js
var html = text.markdown({ custom: function(line) {
	return line.replace(/\{year\}/g, NOW.getFullYear());
}});
```
