feat: Switch to github flavor markdown to render checkboxes

Also fixes a bug where a room pill was not rendered as link.
This commit is contained in:
krille-chan 2025-05-10 15:45:31 +02:00
parent e4691d1636
commit f3bb654ac2
No known key found for this signature in database
2 changed files with 11 additions and 2 deletions

View File

@ -213,7 +213,7 @@ String markdown(
}) {
var ret = markdownToHtml(
text.replaceNewlines(),
extensionSet: ExtensionSet.commonMark,
extensionSet: ExtensionSet.gitHubFlavored,
blockSyntaxes: [
BlockLatexSyntax(),
],

View File

@ -141,7 +141,7 @@ void main() {
);
expect(
markdown('https://matrix.to/#/#fox:sorunome.de'),
'https://matrix.to/#/#fox:sorunome.de',
'<a href="https://matrix.to/#/#fox:sorunome.de">https://matrix.to/#/#fox:sorunome.de</a>',
);
expect(
markdown('Hey @sorunome:sorunome.de:1234!'),
@ -221,5 +221,14 @@ 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>',
);
});
test('Checkboxes', () {
expect(
markdown(
'- [ ] Check 1\n- [x] Check 2\n- Normal list item',
convertLinebreaks: true,
),
'<ul class="contains-task-list"><li class="task-list-item"><input type="checkbox"></input>Check 1</li><li class="task-list-item"><input type="checkbox" checked="true"></input>Check 2</li><li>Normal list item</li></ul>',
);
});
});
}