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: fixed the issue of code block not being exported in markdown #347

Merged
merged 1 commit into from
Aug 1, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ class CodeBlockNodeParser extends NodeParser {
const CodeBlockNodeParser();

@override
String get id => 'code_block';
String get id => 'code';

@override
String transform(Node node) {
assert(node.type == 'code_block');
assert(node.type == 'code');

final delta = node.delta;
final language = node.attributes['language'] ?? '';
if (delta == null) {
throw Exception('Delta is null');
}
final markdown = DeltaMarkdownEncoder().convert(delta);
final result = '```\n$markdown\n```';
final result = '```$language\n$markdown\n```';
final suffix = node.next == null ? '' : '\n';

return '$result$suffix';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void main() async {

test('code block style', () {
final node = Node(
type: 'code_block',
type: 'code',
attributes: {
'delta': (Delta()..insert(text)).toJson(),
},
Expand Down
Loading