Skip to content

Commit

Permalink
feat: add support for horizontal line
Browse files Browse the repository at this point in the history
  • Loading branch information
maelchiotti committed Sep 2, 2024
1 parent d0013aa commit 0472ce1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/parchment/lib/src/codecs/markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ class _ParchmentMarkdownEncoder extends Converter<ParchmentDocument, String> {
ParchmentAttribute? currentBlockAttribute;

void handleLine(LineNode node) {
if (node.hasBlockEmbed) {
if (node.embedNode.value == BlockEmbed.horizontalRule) {
_writeHorizontalLineTag(buffer);
}

return;
}

for (final attr in node.style.lineAttributes) {
if (attr.key == ParchmentAttribute.block.key) {
if (currentBlockAttribute != attr) {
Expand Down Expand Up @@ -586,4 +594,8 @@ class _ParchmentMarkdownEncoder extends Converter<ParchmentDocument, String> {
}
}
}

void _writeHorizontalLineTag(StringBuffer buffer) {
buffer.write('---');
}
}

0 comments on commit 0472ce1

Please sign in to comment.