Better Markdown Parser in PHP - Tests

It's time to copy&paste.

[TOC]

Markdown tests

Aesthetic Table

| header 1 | header 2 |
| -------- | -------- |
| cell 1.1 | cell 1.2 |
| cell 2.1 | cell 2.2 |
header 1 header 2
cell 1.1 cell 1.2
cell 2.1 cell 2.2

Aligned Table

| header 1 | header 2 | header 2 |
| :------- | :------: | -------: |
| cell 1.1 | cell 1.2 | cell 1.3 |
| cell 2.1 | cell 2.2 | cell 2.3 |
header 1 header 2 header 2
cell 1.1 cell 1.2 cell 1.3
cell 2.1 cell 2.2 cell 2.3

Atx Heading

# h1

## h2

### h3

#### h4

##### h5

###### h6

####### not a heading

# closed h1 #

#

h1

h2

h3

h4

h5
h6

closed h1

<https://example.com>

https://example.com

Block-level Html

<div>_content_</div>

paragraph

<div>
  <div class="inner">
    _content_
  </div>
</div>

<style type="text/css">
  p {color: #789;}
</style>

<div>
  <a href="/">home</a></div>
_content_

paragraph

_content_

Code Block

    <?php

    $message = 'Hello World!';
    echo $message;

---

    > not a quote
    - not a list item
    [not a reference]: https://foo.com
<?php

$message = 'Hello World!';
echo $message;

> not a quote
- not a list item
[not a reference]: https://foo.com

Code Span

a `code span`

`this is also a codespan` trailing text

`and look at this one!`

single backtick in a code span: `` ` ``

backtick-delimited string in a code span: `` `foo` ``

`sth `` sth`

a code span

this is also a codespan trailing text

and look at this one!

single backtick in a code span: `

backtick-delimited string in a code span: `foo`

sth `` sth

Compound Blockquote

> header
> ------
>
> paragraph
>
> - li
>
> ---
>
> paragraph

header

paragraph

  • li

paragraph

Compound Emphasis

_`code`_ __`code`__

*`code`**`code`**`code`*

code code

codecodecode

Compound List

- paragraph

  paragraph

- paragraph

  > quote
  • paragraph

    paragraph

  • paragraph

    quote

Deeply Nested List

- li
    - li
        - li
        - li
    - li
- li
  • li
    • li
      • li
      • li
    • li
  • li

Em Strong

___em strong___

___em strong_ strong__

__strong _em strong___

__strong _em strong_ strong__

***em strong***

***em strong* strong**

**strong *em strong***

**strong *em strong* strong**

em strong

em strong strong

strong em strong

strong em strong strong

em strong

em strong strong

strong em strong

strong em strong strong

Email

my email is <[email protected]>

my email is [email protected]

Emphasis

_underscore_, *asterisk*, _one two_, *three four*, _a_, *b*

**strong** and *em* and **strong** and *em*

_line
line
line_

this_is_not_an_emphasis

an empty emphasis __ ** is not an emphasis

*mixed **double and* single asterisk** spans

underscore, asterisk, one two, three four, a, b

strong and em and strong and em

line
line
line

this_is_not_an_emphasis

an empty emphasis __ ** is not an emphasis

*mixed *double and single asterisk** spans

Escaping

escaped \*emphasis\*.

`escaped \*emphasis\* in a code span`

    escaped \*emphasis\* in a code block

\\ \` \* \_ \{ \} \[ \] \( \) \> \# \+ \- \. \!

_one\_two_ __one\_two__

*one\*two* **one\*two**

escaped *emphasis*.

escaped \*emphasis\* in a code span

escaped \*emphasis\* in a code block

\ ` * _ { } [ ] ( ) > # + - . !

one_two one_two

one*two one*two

Fenced Code Block

```
<?php

$message = 'fenced code block';
echo $message;
```

~~~
tilde
~~~

```php
echo 'language identifier';
```
<?php

$message = 'fenced code block';
echo $message;
tilde
echo 'language identifier';

Horizontal Rule

---

- - -

   - - -

***

___





Html Comment

<!-- single line -->

paragraph

<!-- 
  multiline -->

paragraph

paragraph

paragraph

Html Entity

&amp; &copy; &#123;

& © {

Image Reference

![Markdown Logo][https://parsedown.org/md.png]

[image]: https://parsedown.org/md.png

![missing reference]

![Markdown Logo][https://parsedown.org/md.png]

![missing reference]

Image Title

![alt](https://parsedown.org/md.png "title")

![blank title](https://parsedown.org/md.png "")

alt

blank title

Implicit Reference

an [implicit] reference link

[implicit]: https://example.com

an [implicit][] reference link with an empty link definition

an [implicit][] reference link followed by [another][]

[another]: https://cnn.com

an [explicit][example] reference link with a title

[example]: https://example.com "Example"

an implicit reference link

an implicit reference link with an empty link definition

an implicit reference link followed by another

an explicit reference link with a title

[link](https://example.com)

[link](/url-(parentheses)) with parentheses in URL 

([link](/index.php)) in parentheses

[`link`](https://example.com)

[![MD Logo](https://parsedown.org/md.png)](https://example.com)

[![MD Logo](https://parsedown.org/md.png) and text](https://example.com)

[![MD Logo](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAUCAYAAADskT9PAAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2dlndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE9wIYEAEOWAHA4WZmBEf4RALU/L09mZmoSMaz9u4ugGS72yy/UCZz1v9/kSI3QyQGAApF1TY8fiYX5QKUU7PFGTL/BMr0lSkyhjEyFqEJoqwi48SvbPan5iu7yZiXJuShGlnOGbw0noy7UN6aJeGjjAShXJgl4GejfAdlvVRJmgDl9yjT0/icTAAwFJlfzOcmoWyJMkUUGe6J8gIACJTEObxyDov5OWieAHimZ+SKBIlJYqYR15hp5ejIZvrxs1P5YjErlMNN4Yh4TM/0tAyOMBeAr2+WRQElWW2ZaJHtrRzt7VnW5mj5v9nfHn5T/T3IevtV8Sbsz55BjJ5Z32zsrC+9FgD2JFqbHbO+lVUAtG0GQOXhrE/vIADyBQC03pzzHoZsXpLE4gwnC4vs7GxzAZ9rLivoN/ufgm/Kv4Y595nL7vtWO6YXP4EjSRUzZUXlpqemS0TMzAwOl89k/fcQ/+PAOWnNycMsnJ/AF/GF6FVR6JQJhIlou4U8gViQLmQKhH/V4X8YNicHGX6daxRodV8AfYU5ULhJB8hvPQBDIwMkbj96An3rWxAxCsi+vGitka9zjzJ6/uf6Hwtcim7hTEEiU+b2DI9kciWiLBmj34RswQISkAd0oAo0gS4wAixgDRyAM3AD3iAAhIBIEAOWAy5IAmlABLJBPtgACkEx2AF2g2pwANSBetAEToI2cAZcBFfADXALDIBHQAqGwUswAd6BaQiC8BAVokGqkBakD5lC1hAbWgh5Q0FQOBQDxUOJkBCSQPnQJqgYKoOqoUNQPfQj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sWSAMYoPEcAFOTs5EoNw+NPl9UHE0YQYGglEA09HR0bEAxsZHA0PnFzAqgoBq9gIxKOrOAnEQSBxIYwCiQgBDFwEBYFB/BEaVJ7AQ2wGiQXxcWhhhJRZQ0UBURsSlAVyup4Y4TaKAFIeBouAJUIM0KZqoqPYpEzBrpQANfEFFQ4k16gXIbgCggnKoJ5DJdwAAAABJRU5ErkJggg==) and text](https://example.com)

link

link with parentheses in URL

(link) in parentheses

link

MD Logo

MD Logo and text

MD Logo and text

Inline Link Title

[single quotes](https://example.com 'Title')

[double quotes](https://example.com "Title")

[single quotes blank](https://example.com '')

[double quotes blank](https://example.com "")

[space](https://example.com "2 Words")

[parentheses](https://example.com/url-(parentheses) "Title")

single quotes

double quotes

single quotes blank

double quotes blank

space

parentheses

Inline Title

[single quotes](https://example.com 'Example') and [double quotes](https://example.com "Example")

single quotes and double quotes

Lazy Blockquote

> quote
the rest of it

> another paragraph
the rest of it

quote
the rest of it

another paragraph
the rest of it

Lazy List

- li
the rest of it
  • li
    the rest of it

Line Break

line  
line

line
line

Multiline List Paragraph

- li

  line
  line
  • li

    line
    line

Nested Block-level Html

<div>
_parent_
<div>
_child_
</div>
<pre>
_adopted child_
</pre>
</div>

_outside_
_parent_
_child_
_adopted child_

outside

Ordered List

1. one
2. two

repeating numbers:

1. one
1. two

large numbers:

123. one
  1. one
  2. two

repeating numbers:

  1. one
  2. two

large numbers:

  1. one

Paragraph List

paragraph
- li
- li

paragraph

   * li

   * li

paragraph

  • li
  • li

paragraph

  • li

  • li

Reference Title

[double quotes] and [single quotes] and [parentheses]

[double quotes]: https://example.com "example title"
[single quotes]: https://example.com 'example title'
[parentheses]: https://example.com (example title)
[invalid title]: https://example.com example title

double quotes and single quotes and parentheses

[invalid title]: https://example.com example title

Self-closing Html

<hr>
paragraph
<hr/>
paragraph
<hr />
paragraph
<hr class="foo" id="bar" />
paragraph
<hr class="foo" id="bar"/>
paragraph
<hr class="foo" id="bar" >
paragraph

paragraph


paragraph


paragraph


paragraph


paragraph


paragraph

Separated Nested List

- li

    - li
    - li
  • li

    • li
    • li

Setext Header

h1
==

h2
--

single character
-

not a header

------------

h1

h2

single character

not a header


Simple Blockquote

indented:
   > quote

no space after `>`:
>quote

indented:

quote

no space after >:

quote

Simple Table

header 1 | header 2
-------- | --------
cell 1.1 | cell 1.2
cell 2.1 | cell 2.2

---

header 1 | header 2
:------- | --------
cell 1.1 | cell 1.2
cell 2.1 | cell 2.2
header 1 header 2
cell 1.1 cell 1.2
cell 2.1 cell 2.2

header 1 header 2
cell 1.1 cell 1.2
cell 2.1 cell 2.2

Span-level Html

an <b>important</b> <a href=''>link</a>

broken<br/>
line

<b>inline tag</b> at the beginning

<span>https://example.com</span>

an important link

broken

line

inline tag at the beginning

https://example.com

Sparse Dense List

- li

- li
- li
  • li

  • li

  • li

Sparse Html

<div>
line 1

line 2
line 3

line 4
</div>
line 1 line 2 line 3 line 4

Sparse List

- li

- li

---

- li

    - indented li
  • li

  • li


  • li

    • indented li

Special Characters

AT&T has an ampersand in their name

this & that

4 < 5 and 6 > 5

<https://example.com/autolink?a=1&b=2>

[inline link](/script?a=1&b=2)

[reference link][1]

[1]: https://example.com/?a=1&b=2

AT&T has an ampersand in their name

this & that

4 < 5 and 6 > 5

https://example.com/autolink?a=1&b=2

inline link

reference link

Strikethrough

~~strikethrough~~

here's ~~one~~ followed by ~~another one~~

~~ this ~~ is not one neither is ~this~

strikethrough

here's one followed by another one

~~ this ~~ is not one neither is ~this~

Strong Em

*em **strong em***

***strong em** em*

*em **strong em** em*

_em __strong em___

___strong em__ em_

_em __strong em__ em_

em strong em

strong em em

em strong em em

em strong em

strong em em

em strong em em

Tab-indented Code Block

    <?php

    $message = 'Hello World!';
    echo $message;

    echo "following a blank line";
<?php

$message = 'Hello World!';
echo $message;

echo "following a blank line";

Table Inline Markdown

| _header_ 1   | header 2     |
| ------------ | ------------ |
| _cell_ 1.1   | ~~cell~~ 1.2 |
| `|` 2.1      | \| 2.2       |
| `\|` 2.1     | [link](/)    |
header 1 header 2
cell 1.1 cell 1.2
| 2.1 | 2.2
\| 2.1 link

Text Reference

[reference link][1]

[1]: https://example.com

[one][website] with a semantic name

[website]: https://example.com

[one][404] with no definition

[multiline
one][website] defined on 2 lines

[one][Label] with a mixed case label and an upper case definition

[LABEL]: https://example.com

[one]
[1] with the a label on the next line

[`link`][website]

reference link

one with a semantic name

[one][404] with no definition

multiline
one
defined on 2 lines

one with a mixed case label and an upper case definition

one with the a label on the next line

link

Unordered List

- li
- li

mixed markers:

* li
+ li
- li
  • li
  • li

mixed markers:

  • li
  • li
  • li

Untidy Table

| header 1 | header 2          |
| ------------- | ----------- |
| cell 1.1   | cell 1.2 |
|    cell 2.1 | cell 2.2     |
header 1 header 2
cell 1.1 cell 1.2
cell 2.1 cell 2.2

Url Autolinking

an autolink https://example.com

inside of brackets [https://example.com], inside of braces {https://example.com},  inside of parentheses (https://example.com)

trailing slash https://example.com/ and https://example.com/path/

an autolink https://example.com

inside of brackets [https://example.com], inside of braces {https://example.com}, inside of parentheses (https://example.com)

trailing slash https://example.com/ and https://example.com/path/

Whitespace



    code

code

Font weight tests

Fallback sans

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

Fallback serif

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

我能吞下玻璃而不伤身体。

标签: none

知识共享许可协议 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。

添加新评论