mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Backslash escape like CommonMark
This commit is contained in:
parent
eab734b457
commit
7fd6e0bb31
@ -4,7 +4,6 @@ namespace Erusev\Parsedown\Components\Inlines;
|
|||||||
|
|
||||||
use Erusev\Parsedown\AST\StateRenderable;
|
use Erusev\Parsedown\AST\StateRenderable;
|
||||||
use Erusev\Parsedown\Components\Inline;
|
use Erusev\Parsedown\Components\Inline;
|
||||||
use Erusev\Parsedown\Html\Renderables\RawHtml;
|
|
||||||
use Erusev\Parsedown\Html\Renderables\Text;
|
use Erusev\Parsedown\Html\Renderables\Text;
|
||||||
use Erusev\Parsedown\Parsing\Excerpt;
|
use Erusev\Parsedown\Parsing\Excerpt;
|
||||||
use Erusev\Parsedown\State;
|
use Erusev\Parsedown\State;
|
||||||
@ -13,17 +12,17 @@ final class EscapeSequence implements Inline
|
|||||||
{
|
{
|
||||||
use WidthTrait, DefaultBeginPosition;
|
use WidthTrait, DefaultBeginPosition;
|
||||||
|
|
||||||
const SPECIALS = '\\`*_{}[]()>#+-.!|~';
|
const SPECIALS = '!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~';
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $html;
|
private $text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $html
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
public function __construct($html)
|
public function __construct($text)
|
||||||
{
|
{
|
||||||
$this->html = $html;
|
$this->text = $text;
|
||||||
$this->width = 2;
|
$this->width = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +41,11 @@ final class EscapeSequence implements Inline
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return RawHtml
|
* @return Text
|
||||||
*/
|
*/
|
||||||
public function stateRenderable()
|
public function stateRenderable()
|
||||||
{
|
{
|
||||||
return new RawHtml($this->html);
|
return new Text($this->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +53,6 @@ final class EscapeSequence implements Inline
|
|||||||
*/
|
*/
|
||||||
public function bestPlaintext()
|
public function bestPlaintext()
|
||||||
{
|
{
|
||||||
return new Text($this->html);
|
return new Text($this->text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<p>escaped *emphasis*.</p>
|
<p>escaped *emphasis*.</p>
|
||||||
<p><code>escaped \*emphasis\* in a code span</code></p>
|
<p><code>escaped \*emphasis\* in a code span</code></p>
|
||||||
<pre><code>escaped \*emphasis\* in a code block</code></pre>
|
<pre><code>escaped \*emphasis\* in a code block</code></pre>
|
||||||
<p>\ ` * _ { } [ ] ( ) > # + - . !</p>
|
<p>\ ` * _ { } [ ] ( ) > # + - . !</p>
|
||||||
<p><em>one_two</em> <strong>one_two</strong></p>
|
<p><em>one_two</em> <strong>one_two</strong></p>
|
||||||
<p><em>one*two</em> <strong>one*two</strong></p>
|
<p><em>one*two</em> <strong>one*two</strong></p>
|
Loading…
Reference in New Issue
Block a user