markdown support for talk messages

This commit is contained in:
2026-08-16 21:35:41 +02:00
parent bd83a88e70
commit 02a7b87b5b
14 changed files with 379 additions and 19 deletions
@@ -0,0 +1,38 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:marianum_mobile/view/pages/talk/data/talk_markdown.dart';
void main() {
group('markdownToPlainText', () {
test('strips emphasis markers', () {
expect(
markdownToPlainText('**bold** and _italic_ and ~~struck~~'),
'bold and italic and struck',
);
});
test('drops heading markers', () {
expect(markdownToPlainText('# Title'), 'Title');
});
test('reduces links to their label and images to their alt text', () {
expect(markdownToPlainText('see [the docs](https://x.y)'), 'see the docs');
expect(markdownToPlainText('![a cat](https://x.y/c.png)'), 'a cat');
});
test('flattens lists into one space-separated line', () {
expect(markdownToPlainText('- one\n- two\n- three'), 'one two three');
});
test('unwraps inline code without the backticks', () {
expect(markdownToPlainText('run `flutter test` now'), 'run flutter test now');
});
test('keeps plain text unchanged', () {
expect(markdownToPlainText('just a normal sentence.'), 'just a normal sentence.');
});
test('leaves literal angle brackets intact (no HTML interpretation)', () {
expect(markdownToPlainText('a <b>tag</b>'), 'a <b>tag</b>');
});
});
}