1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Allow extension to "vouch" for raw HTML they produce

Rename "unsafeHtml" to "rawHtml"
This commit is contained in:
Aidan Woods
2018-03-15 19:46:03 +00:00
parent ef7ed7b66c
commit 3fc54bc966
4 changed files with 78 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
<?php
require 'UnsafeExtension.php';
require 'SampleExtensions.php';
use PHPUnit\Framework\TestCase;
@@ -56,7 +56,7 @@ class ParsedownTest extends TestCase
$this->assertEquals($expectedMarkup, $actualMarkup);
}
function testUnsafeHtml()
function testRawHtml()
{
$markdown = "```php\nfoobar\n```";
$expectedMarkup = '<pre><code class="language-php"><p>foobar</p></code></pre>';
@@ -73,6 +73,23 @@ class ParsedownTest extends TestCase
$this->assertEquals($expectedSafeMarkup, $actualSafeMarkup);
}
function testTrustDelegatedRawHtml()
{
$markdown = "```php\nfoobar\n```";
$expectedMarkup = '<pre><code class="language-php"><p>foobar</p></code></pre>';
$expectedSafeMarkup = $expectedMarkup;
$unsafeExtension = new TrustDelegatedExtension;
$actualMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
$unsafeExtension->setSafeMode(true);
$actualSafeMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedSafeMarkup, $actualSafeMarkup);
}
function data()
{
$data = array();