update markdown

This commit is contained in:
Dennis Eichhorn 2023-09-21 22:22:09 +00:00
parent 37db31e85f
commit b69c9b708c
23 changed files with 230 additions and 20 deletions

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace phpOMS\tests\Utils\Parser\Markdown;
include_once __DIR__ . '/../../../Autoloader.php';
use phpOMS\System\File\Local\Directory;
use phpOMS\Utils\Parser\Markdown\Markdown;
@ -42,4 +44,12 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
self::assertTrue(true);
}
public function testSafeMode() : void
{
$parser = new Markdown();
$parser->setSafeMode(true);
self::assertTrue(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.html') === ($parsed = $parser->text(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.md'))), $parsed);
}
}

View File

@ -0,0 +1,3 @@
<p>The <abbr title="Hyper Text Markup Language">HTML</abbr> specification
is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.
The abbreviation <abbr title="Markup Language">ML</abbr> is contained in the abbreviation <abbr title="Hyper Text Markup Language">HTML</abbr>.</p>

View File

@ -0,0 +1,7 @@
The HTML specification
is maintained by the W3C.
The abbreviation ML is contained in the abbreviation HTML.
*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium
*[ML]: Markup Language

View File

@ -1,9 +1,9 @@
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<h1 id="h1">h1</h1>
<h2 id="h2">h2</h2>
<h3 id="h3">h3</h3>
<h4 id="h4">h4</h4>
<h5 id="h5">h5</h5>
<h6 id="h6">h6</h6>
<p>####### not a heading</p>
<h1>closed h1</h1>
<p>#</p>
<h1 id="closed-h1">closed h1</h1>
<h1 id=""></h1>

View File

@ -1,5 +1,5 @@
<blockquote>
<h2>header</h2>
<h2 id="header">header</h2>
<p>paragraph</p>
<ul>
<li>li</li>

View File

@ -0,0 +1,18 @@
<p>footnote <sup id="fnref1:1"><a href="#fn:1" class="footnote-ref">1</a></sup> and another one <sup id="fnref1:2"><a href="#fn:2" class="footnote-ref">2</a></sup></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>line 1
line 2</p>
<blockquote>
<p>quote</p>
</blockquote>
<p>another paragraph&#160;<a href="#fnref1:1" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:2">
<p>paragraph</p>
<p>another paragraph&#160;<a href="#fnref1:2" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
</ol>
</div>

View File

@ -0,0 +1,13 @@
footnote [^1] and another one [^2]
[^1]: line 1
line 2
> quote
another paragraph
[^2]:
paragraph
another paragraph

View File

@ -1,12 +1,12 @@
<ul>
<li>li
<ul>
<li>li
<ul>
<li>li<ul>
<li>li<ul>
<li>li</li>
<li>li</li>
</ul></li>
</ul>
</li>
<li>li</li>
</ul></li>
</ul>
</li>
<li>li</li>
</ul>

View File

@ -0,0 +1,23 @@
<dl>
<dt>Term 1</dt>
<dd>one</dd>
<dd>two
extra line</dd>
<dt>Term 2</dt>
<dd>
<p>lazy
line</p>
</dd>
<dd>
<p>multiple</p>
<p>paragraphs</p>
</dd>
<dd>
<p>nested</p>
<pre><code>code block</code></pre>
<blockquote>
<p>quote
block</p>
</blockquote>
</dd>
</dl>

View File

@ -0,0 +1,20 @@
Term 1
: one
: two
extra line
Term 2
: lazy
line
: multiple
paragraphs
: nested
code block
> quote
> block

View File

@ -0,0 +1,20 @@
<p>first <sup id="fnref1:1"><a href="#fn:1" class="footnote-ref">1</a></sup> second <sup id="fnref1:2"><a href="#fn:2" class="footnote-ref">2</a></sup>.</p>
<p>first <sup id="fnref1:a"><a href="#fn:a" class="footnote-ref">3</a></sup> second <sup id="fnref1:b"><a href="#fn:b" class="footnote-ref">4</a></sup>.</p>
<p>second time <sup id="fnref2:1"><a href="#fn:1" class="footnote-ref">1</a></sup></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>one&#160;<a href="#fnref1:1" rev="footnote" class="footnote-backref">&#8617;</a> <a href="#fnref2:1" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:2">
<p>two&#160;<a href="#fnref1:2" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:a">
<p>one&#160;<a href="#fnref1:a" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:b">
<p>two&#160;<a href="#fnref1:b" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
</ol>
</div>

View File

@ -0,0 +1,11 @@
first [^1] second [^2].
[^1]: one
[^2]: two
first [^a] second [^b].
[^a]: one
[^b]: two
second time [^1]

View File

@ -1,6 +1,8 @@
<blockquote>
<p>quote
the rest of it</p>
</blockquote>
<blockquote>
<p>another paragraph
the rest of it</p>
</blockquote>

View File

@ -0,0 +1,25 @@
<div class="example">
<p><em>markdown</em></p>
<p>This is another paragraph. It contains <em>inline markup</em>.</p>
<div>
_no markdown_
</div>
</div>
<hr />
<div>
<p><em>markdown</em></p>
<div>
<p><em>markdown</em></p>
</div>
</div>
<hr />
<div>
_no markdown_
<div>
<p><em>markdown</em></p>
</div>
</div>
<hr />
<div markdown="0">
_no markdown_
</div>

View File

@ -0,0 +1,32 @@
<div class="example" markdown="1">
_markdown_
This is another paragraph. It contains <em>inline markup</em>.
<div>
_no markdown_
</div>
</div>
---
<div markdown="1">
_markdown_
<div markdown="1">
_markdown_
</div>
</div>
---
<div>
_no markdown_
<div markdown="1">
_markdown_
</div>
</div>
---
<div markdown="0">
_no markdown_
</div>

View File

@ -8,5 +8,7 @@
<li>
<p>li</p>
</li>
<li>li</li>
<li>
<p>li</p>
</li>
</ul>

View File

@ -1,5 +1,5 @@
<h1>h1</h1>
<h2>h2</h2>
<h2>single character</h2>
<h1 id="h1">h1</h1>
<h2 id="h2">h2</h2>
<h2 id="single-character">single character</h2>
<p>not a header</p>
<hr />

View File

@ -2,7 +2,9 @@
<li>
<p>li</p>
</li>
<li>li</li>
<li>
<p>li</p>
</li>
</ul>
<hr />
<ul>

View File

@ -0,0 +1,6 @@
<h1 id="header1">Header 1</h1>
<h2 id="header2">Header 2</h2>
<h2 class="main" id="the-site">The Site</h2>
<h2 id="the-site" class="main shine">The Site</h2>
<p><a href="http://parsedown.org" id="link" class="primary upper-case">link</a></p>
<p><img src="/md.png" alt="logo" id="logo" class="big" /></p>

View File

@ -0,0 +1,12 @@
Header 1 {#header1}
========
## Header 2 ## {#header2}
## The Site ## {.main}
## The Site ## {.main .shine #the-site}
[link](http://parsedown.org) {.primary #link .upper-case}
![logo](/md.png) {#logo .big}

View File

@ -5,6 +5,10 @@
<p>mixed markers:</p>
<ul>
<li>li</li>
</ul>
<ul>
<li>li</li>
</ul>
<ul>
<li>li</li>
</ul>