refactor: Escape HTML tags before markdown rendering
This commit is contained in:
parent
9e26e5087a
commit
c9f8ece8d4
|
|
@ -212,7 +212,13 @@ String markdown(
|
||||||
bool convertLinebreaks = true,
|
bool convertLinebreaks = true,
|
||||||
}) {
|
}) {
|
||||||
var ret = markdownToHtml(
|
var ret = markdownToHtml(
|
||||||
text.replaceNewlines(),
|
text
|
||||||
|
.replaceAllMapped(
|
||||||
|
// Replace HTML tags
|
||||||
|
RegExp(r'<([^>]*)>'),
|
||||||
|
(match) => '<${match.group(1)}>',
|
||||||
|
)
|
||||||
|
.replaceNewlines(),
|
||||||
extensionSet: ExtensionSet.gitHubFlavored,
|
extensionSet: ExtensionSet.gitHubFlavored,
|
||||||
blockSyntaxes: [
|
blockSyntaxes: [
|
||||||
BlockLatexSyntax(),
|
BlockLatexSyntax(),
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,10 @@ void main() {
|
||||||
),
|
),
|
||||||
'<p>The first<br/>codeblock</p><pre><code class="language-dart">void main(){\nprint(something);\n}\n</code></pre><p>And the second code block</p><pre><code class="language-js">meow\nmeow\n</code></pre>',
|
'<p>The first<br/>codeblock</p><pre><code class="language-dart">void main(){\nprint(something);\n}\n</code></pre><p>And the second code block</p><pre><code class="language-js">meow\nmeow\n</code></pre>',
|
||||||
);
|
);
|
||||||
|
expect(
|
||||||
|
markdown('Test <m> *unescaped*'),
|
||||||
|
'Test <m> <em>unescaped</em>',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
test('Checkboxes', () {
|
test('Checkboxes', () {
|
||||||
expect(
|
expect(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue