Block elements


A line that starts with a right angle bracket > (optionally followed by a space) is a blockquote. Blockquotes can be nested but they can't be used inside of lists. Consecutive blockquotes can be separated with two blank lines.

> > Deep blockquote
> Shallower blockquote

No blockquote
<blockquote><blockquote><p>Deep blockquote</p></blockquote>

<p>Shallower blockquote</p></blockquote>

<p>No blockquote</p>


*, - and + for unordered lists, or any number of digits followed by a dot such as 1. for an ordered list. The list item must be followed by a space then at least one character. Lists can be nested and can be used inside of blockquotes.

The indentation inside of nested lists emulates the behaviour of the original Markdown, meaning that sublists after the first should be indented by 4 spaces or a tab.

If a list has any of its text content or list items separated with a blank line, each of its items' content is wrapped in a paragraph. Consecutive lists can be separated with two blank lines.

1. Collect underpants
2. **?**
3. Profit
<ol><li>Collect underpants</li>
- Milk
- Bread
- Nutella

Indented code blocks

A series of lines indented by at least 4 spaces or a tab, preceded with an empty line.

Check out this program:

    10 PRINT "Hello"
    20 GOTO 10

Fenced code blocks

A series of lines between two markers composed of at least 3 consecutive ` or ~ and identical in length. The name of the programming language can be appended to the first marker.

<div class="banner">...</div>


Block spoilers are similar to blockquotes and follow the same rules as blockquotes. Block spoilers use >! as opening markup instead of >. Subsequent lines can be started with >.

>! >! Super spoiler
>! Spoiler

No spoiler
<details class="spoiler"><details class="spoiler"><p>Super spoiler</p></details>


<p>No spoiler</p>



This is an H1

This is an H2
<h1>This is an H1</h1>

<h2>This is an H2</h2>


# This is an H1

## This is an H2

###### This is an H6
<h1>This is an H1</h1>

<h2>This is an H2</h2>

<h6>This is an H6</h6>

Horizontal rules

Each of those creates an horizontal rule.

* * *



- - -


Paragraphs and line breaks

Paragraphs are automatically created. Newlines are ignored by default, line breaks can be forced by ending a line with two spaces.

another line
forced  <br>
another line</p>

Alternatively, automatic line breaks can be enabled globally with a enabledAutoLineBreaks rule as in the following example.

$configurator = new s9e\TextFormatter\Configurator;

// Enable automatic line breaks globally

// Get an instance of the parser and the renderer

$text = "First line\n"
      . "Second line";
$xml  = $parser->parse($text);
$html = $renderer->render($xml);

echo $html;
<p>First line<br>
Second line</p>

Formatting elements

Note that special characters inside links can be escaped with a backslash.

[Link text](
[Link text]( "Link title")
[Link text]( 'Link title')
[Link text]( (Link title))
<p><a href="">Link text</a>
<a href="" title="Link title">Link text</a>
<a href="" title="Link title">Link text</a>
<a href="" title="Link title">Link text</a>
<a href="">Mars</a>
<a href="">Mars</a></p>


A pair of * or _ around non-whitespace text marks emphasis (<em>) while a pair of ** or __ marks strong emphasis (<strong>). One exception: a single _ between two ASCII alphanumerical characters is kept as-is.


***ON SALE!***

a * b = b * a


<p><strong><em>ON SALE!</em></strong></p>

<p>a * b = b * a</p>


When a block of three * or _ is found, the order of strong/em depends on the next series of * or _ characters.

***foo* bar**

***foo** bar*
<p><strong><em>foo</em> bar</strong></p>

<p><em><strong>foo</strong> bar</em></p>

Inline spoilers

Any text between >! and !< or between || and ||. Unlike block spoilers, they can be used anywhere on a line.

This is a Reddit-style >!spoiler!<.
This is a Discord-style ||spoiler||.
<p>This is a Reddit-style <span class="spoiler" onclick="this.removeAttribute('style')" style="background:#444;color:transparent">spoiler</span>.
This is a Discord-style <span class="spoiler" onclick="this.removeAttribute('style')" style="background:#444;color:transparent">spoiler</span>.</p>


Any text between two ~~ markers.

90s haircuts are ~~cool~~ ~~lame~~ cool again.
<p>90s haircuts are <del>cool</del> <del>lame</del> cool again.</p>

Subscript and superscript

x^(n - 1)
x<sup>n - 1</sup>

Inline code

Any text between two markers of same length, entirely composed of backticks ` and neither preceded or followed by a backtick. Leading and trailing whitespace is removed. The backslash does not escape characters inside of a code span.

Single `print("``")` or double ``print("`")``
<p>Single <code>print("``")</code> or double <code>print("`")</code></p>

Inline elements


![Alt text](
![Alt text]( "Image title")
[![Alt text](](
<p><img src="" alt="">
<img src="" alt="Alt text">
<img src="" alt="Alt text" title="Image title">
<a href=""><img src="" alt="Alt text"></a></p>