mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 21:31:28 +01:00
Do not handle weird edge cases
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
95f9275a61
commit
996d3df4d0
@ -158,7 +158,7 @@ abstract class StrTools extends Extension
|
||||
if ($markdown === '') {
|
||||
return $markdown;
|
||||
}
|
||||
$html = (new Parsedown($markdown))->text($markdown);
|
||||
$html = Parsedown::instance()->text($markdown);
|
||||
$document = new DOMDocument('', 'utf-8');
|
||||
@$document->loadHTML(\mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||
if (!$document->getElementsByTagName('body')[0]) {
|
||||
|
@ -24,7 +24,7 @@ final class DOMEntities
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$html = \preg_replace("/\<br(\s*)?\/?\>/i", "\n", $html);
|
||||
$dom->loadxml("<body>" . \str_replace(['&', ''', '"', '>', '<', '&'], ['&', '\'', "\"", '>', '<', '&'], \trim($html)) . "</body>");
|
||||
$dom->loadxml("<body>" . \trim($html) . "</body>");
|
||||
$this->parseNode($dom->getElementsByTagName('body')->item(0), 0);
|
||||
}
|
||||
/**
|
||||
|
@ -153,12 +153,12 @@ class EntitiesTest extends MadelineTestCase
|
||||
],
|
||||
[
|
||||
'html',
|
||||
'<b>&\'"</b>',
|
||||
'&\'"',
|
||||
'<b>\'"</b>',
|
||||
'\'"',
|
||||
[
|
||||
[
|
||||
'offset' => 0,
|
||||
'length' => 3,
|
||||
'length' => 2,
|
||||
'type' => 'bold'
|
||||
]
|
||||
]
|
||||
@ -182,6 +182,18 @@ class EntitiesTest extends MadelineTestCase
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'markdown',
|
||||
'_a b c <b> & " '_',
|
||||
'a b c <b> & " \'',
|
||||
[
|
||||
[
|
||||
'offset' => 0,
|
||||
'length' => 15,
|
||||
'type' => 'italic',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'markdown',
|
||||
'test *italic* **bold** <u>underlined</u> ~~strikethrough~~ <pre language="test">pre</pre> <code>code</code> <spoiler>spoiler</spoiler>',
|
||||
|
Loading…
x
Reference in New Issue
Block a user