Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: document from markdown contains html escape text #841

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/lib/pages/markdown/markdown_code_block_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ class MarkdownCodeBlockParserV2 extends CustomMarkdownParser {
language = languageClass.substring('language-'.length);
}

final deltaDecoder = DeltaMarkdownDecoder();

return [
codeBlockNode(
language: language,
delta: deltaDecoder.convertNodes(code.children),
delta: Delta()..insert(code.textContent.trimRight()),
),
];
}
Expand Down
47 changes: 47 additions & 0 deletions example/test/markdown_code_block_parser_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:appflowy_editor/src/plugins/markdown/decoder/document_markdown_decoder.dart';
import 'package:example/pages/markdown/markdown_code_block_parser.dart';
import 'package:flutter_test/flutter_test.dart';

void main() async {
group('markdown_heading_parser.dart', () {
final parser = DocumentMarkdownDecoder(
markdownElementParsers: [
const MarkdownCodeBlockParserV2(),
],
);

test('contains quote syntax', () {
const codeBlockMarkdown = '''```python
# Example of using the GTD class
gtd_system = GTD()
gtd_system.capture("Write a blog post")
gtd_system.capture("Prepare presentation for Monday")
gtd_system.capture("Plan vacation")
gtd_system.clarify()
gtd_system.review()
gtd_system.engage()
```''';

final result = parser.convert(codeBlockMarkdown);
final codeBlock = result.root.children.first;
expect(codeBlock.toJson(), {
'type': 'code',
'data': {
'language': 'python',
'delta': [
{
'insert': '''# Example of using the GTD class
gtd_system = GTD()
gtd_system.capture("Write a blog post")
gtd_system.capture("Prepare presentation for Monday")
gtd_system.capture("Plan vacation")
gtd_system.clarify()
gtd_system.review()
gtd_system.engage()''',
},
],
},
});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DocumentMarkdownDecoder extends Converter<String, Document> {
...inlineSyntaxes,
UnderlineInlineSyntax(),
],
encodeHtml: false,
).parse(input);
final document = Document.blank();

Expand Down
Loading