mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Test against HTML block endings
This commit is contained in:
parent
14f8ff52e1
commit
08c40afc16
@ -27,6 +27,13 @@ final class Markup implements ContinuableBlock
|
||||
5 => ']]>'
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
private static $specialHtmlBlockTags = [
|
||||
'script' => true,
|
||||
'style' => true,
|
||||
'pre' => true,
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
private $html;
|
||||
|
||||
@ -85,7 +92,10 @@ final class Markup implements ContinuableBlock
|
||||
if (\preg_match('/^<[\/]?+(\w++)(?:[ ]*+'.self::REGEX_HTML_ATTRIBUTE.')*+[ ]*+(\/)?>/', $text, $matches)) {
|
||||
$element = \strtolower($matches[1]);
|
||||
|
||||
if (\array_key_exists($element, Element::$TEXT_LEVEL_ELEMENTS)) {
|
||||
if (
|
||||
\array_key_exists($element, Element::$TEXT_LEVEL_ELEMENTS)
|
||||
|| \array_key_exists($element, self::$specialHtmlBlockTags)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
6
tests/commonmark/117-HTML_blocks.html
Normal file
6
tests/commonmark/117-HTML_blocks.html
Normal file
@ -0,0 +1,6 @@
|
||||
<table><tr><td>
|
||||
<pre>
|
||||
**Hello**,
|
||||
<p><em>world</em>.
|
||||
</pre></p>
|
||||
</td></tr></table>
|
7
tests/commonmark/117-HTML_blocks.md
Normal file
7
tests/commonmark/117-HTML_blocks.md
Normal file
@ -0,0 +1,7 @@
|
||||
<table><tr><td>
|
||||
<pre>
|
||||
**Hello**,
|
||||
|
||||
_world_.
|
||||
</pre>
|
||||
</td></tr></table>
|
337
tests/data/markup_end_conditions.html
Normal file
337
tests/data/markup_end_conditions.html
Normal file
@ -0,0 +1,337 @@
|
||||
<style> foo </script>
|
||||
<p>bar
|
||||
</script></p>
|
||||
<p>foo</p>
|
||||
<style> foo -->
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo ?>
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo >
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo ]]>
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo
|
||||
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<!-- foo </script>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo -->
|
||||
<p>bar
|
||||
--></p>
|
||||
<p>foo</p>
|
||||
<!-- foo ?>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo >
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo ]]>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo
|
||||
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<?php foo </script>
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo -->
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo ?>
|
||||
<p>bar
|
||||
?></p>
|
||||
<p>foo</p>
|
||||
<?php foo >
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo ]]>
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo
|
||||
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<!A foo </script>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo -->
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo ?>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo >
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo ]]>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo
|
||||
|
||||
bar
|
||||
>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<![CDATA[ foo </script>
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo -->
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo ?>
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo >
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo ]]>
|
||||
<p>bar
|
||||
]]></p>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo
|
||||
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<body> foo </script>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo -->
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo ?>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo >
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo ]]>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo
|
||||
<p>bar</p>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<style> foo
|
||||
</script>
|
||||
<p>bar
|
||||
</script></p>
|
||||
<p>foo</p>
|
||||
<style> foo
|
||||
-->
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo
|
||||
?>
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo
|
||||
>
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo
|
||||
]]>
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<style> foo
|
||||
|
||||
bar
|
||||
</script>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<!-- foo
|
||||
</script>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo
|
||||
-->
|
||||
<p>bar
|
||||
--></p>
|
||||
<p>foo</p>
|
||||
<!-- foo
|
||||
?>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo
|
||||
>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo
|
||||
]]>
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<!-- foo
|
||||
|
||||
bar
|
||||
-->
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<?php foo
|
||||
</script>
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo
|
||||
-->
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo
|
||||
?>
|
||||
<p>bar
|
||||
?></p>
|
||||
<p>foo</p>
|
||||
<?php foo
|
||||
>
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo
|
||||
]]>
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<?php foo
|
||||
|
||||
bar
|
||||
?>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<!A foo
|
||||
</script>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo
|
||||
-->
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo
|
||||
?>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo
|
||||
>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo
|
||||
]]>
|
||||
<p>bar</p>
|
||||
<blockquote>
|
||||
</blockquote>
|
||||
<p>foo</p>
|
||||
<!A foo
|
||||
|
||||
bar
|
||||
>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<![CDATA[ foo
|
||||
</script>
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo
|
||||
-->
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo
|
||||
?>
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo
|
||||
>
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo
|
||||
]]>
|
||||
<p>bar
|
||||
]]></p>
|
||||
<p>foo</p>
|
||||
<![CDATA[ foo
|
||||
|
||||
bar
|
||||
]]>
|
||||
<p>foo</p>
|
||||
<hr />
|
||||
<body> foo
|
||||
</script>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo
|
||||
-->
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo
|
||||
?>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo
|
||||
>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo
|
||||
]]>
|
||||
bar
|
||||
<p>foo</p>
|
||||
<body> foo
|
||||
<p>bar</p>
|
||||
<p>foo</p>
|
483
tests/data/markup_end_conditions.md
Normal file
483
tests/data/markup_end_conditions.md
Normal file
@ -0,0 +1,483 @@
|
||||
<style> foo </script>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo -->
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo ?>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo >
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo ]]>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo
|
||||
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<!-- foo </script>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo -->
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo ?>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo >
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo ]]>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo
|
||||
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<?php foo </script>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo -->
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo ?>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo >
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo ]]>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo
|
||||
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<!A foo </script>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo -->
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo ?>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo >
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo ]]>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo
|
||||
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<![CDATA[ foo </script>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo -->
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo ?>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo >
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo ]]>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo
|
||||
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<body> foo </script>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo -->
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo ?>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo >
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo ]]>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo
|
||||
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<style> foo
|
||||
</script>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo
|
||||
-->
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo
|
||||
?>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo
|
||||
>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo
|
||||
]]>
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
<style> foo
|
||||
|
||||
bar
|
||||
</script>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<!-- foo
|
||||
</script>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo
|
||||
-->
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo
|
||||
?>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo
|
||||
>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo
|
||||
]]>
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
<!-- foo
|
||||
|
||||
bar
|
||||
-->
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<?php foo
|
||||
</script>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo
|
||||
-->
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo
|
||||
?>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo
|
||||
>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo
|
||||
]]>
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
<?php foo
|
||||
|
||||
bar
|
||||
?>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<!A foo
|
||||
</script>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo
|
||||
-->
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo
|
||||
?>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo
|
||||
>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo
|
||||
]]>
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
<!A foo
|
||||
|
||||
bar
|
||||
>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<![CDATA[ foo
|
||||
</script>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo
|
||||
-->
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo
|
||||
?>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo
|
||||
>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo
|
||||
]]>
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
<![CDATA[ foo
|
||||
|
||||
bar
|
||||
]]>
|
||||
|
||||
foo
|
||||
|
||||
---
|
||||
|
||||
<body> foo
|
||||
</script>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo
|
||||
-->
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo
|
||||
?>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo
|
||||
>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo
|
||||
]]>
|
||||
bar
|
||||
|
||||
foo
|
||||
|
||||
<body> foo
|
||||
|
||||
bar
|
||||
|
||||
foo
|
Loading…
x
Reference in New Issue
Block a user