mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Added missing attributes to markdown renderer
This commit is contained in:
parent
94dc76d1a9
commit
ab214d4a74
@ -65,8 +65,7 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
|
|||||||
// First close any current styles if needed
|
// First close any current styles if needed
|
||||||
final markedForRemoval = <Attribute>[];
|
final markedForRemoval = <Attribute>[];
|
||||||
// Close the styles in reverse order, e.g. **_ for _**Test**_.
|
// Close the styles in reverse order, e.g. **_ for _**Test**_.
|
||||||
for (final value
|
for (final value in currentInlineStyle.attributes.values.toList().reversed) {
|
||||||
in currentInlineStyle.attributes.values.toList().reversed) {
|
|
||||||
// TODO(tillf): Is block correct?
|
// TODO(tillf): Is block correct?
|
||||||
if (value.scope == AttributeScope.BLOCK) {
|
if (value.scope == AttributeScope.BLOCK) {
|
||||||
continue;
|
continue;
|
||||||
@ -123,10 +122,8 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
|
|||||||
// Close any open inline styles.
|
// Close any open inline styles.
|
||||||
_handleInline(lineBuffer, '', null);
|
_handleInline(lineBuffer, '', null);
|
||||||
|
|
||||||
final lineBlock = Style.fromJson(attributes)
|
final lineBlock =
|
||||||
.attributes
|
Style.fromJson(attributes).attributes.values.singleWhereOrNull((a) => a.scope == AttributeScope.BLOCK);
|
||||||
.values
|
|
||||||
.singleWhereOrNull((a) => a.scope == AttributeScope.BLOCK);
|
|
||||||
|
|
||||||
if (lineBlock == currentBlockStyle) {
|
if (lineBlock == currentBlockStyle) {
|
||||||
currentBlockLines.add(lineBuffer.toString());
|
currentBlockLines.add(lineBuffer.toString());
|
||||||
@ -220,6 +217,16 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
|
|||||||
buffer.write(!close ? '[' : '](${attribute.value})');
|
buffer.write(!close ? '[' : '](${attribute.value})');
|
||||||
} else if (attribute == Attribute.codeBlock) {
|
} else if (attribute == Attribute.codeBlock) {
|
||||||
buffer.write(!close ? '```\n' : '\n```');
|
buffer.write(!close ? '```\n' : '\n```');
|
||||||
|
} else if (attribute.key == Attribute.background.key) {
|
||||||
|
buffer.write(!close ? '<mark>' : '</mark>');
|
||||||
|
} else if (attribute.key == Attribute.underline.key) {
|
||||||
|
buffer.write(!close ? '<u>' : '</u>');
|
||||||
|
} else if (attribute.key == Attribute.codeBlock.key) {
|
||||||
|
buffer.write(!close ? '```\n' : '\n```');
|
||||||
|
} else if (attribute.key == Attribute.inlineCode.key) {
|
||||||
|
buffer.write(!close ? '`' : '`');
|
||||||
|
} else if (attribute.key == Attribute.strikeThrough.key) {
|
||||||
|
buffer.write(!close ? '~~' : '~~');
|
||||||
} else {
|
} else {
|
||||||
throw ArgumentError('Cannot handle $attribute');
|
throw ArgumentError('Cannot handle $attribute');
|
||||||
}
|
}
|
||||||
@ -246,6 +253,8 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
|
|||||||
buffer.write('## ');
|
buffer.write('## ');
|
||||||
} else if (block.key == Attribute.h3.key && block.value == 3) {
|
} else if (block.key == Attribute.h3.key && block.value == 3) {
|
||||||
buffer.write('### ');
|
buffer.write('### ');
|
||||||
|
} else if (block.key == Attribute.list.key) {
|
||||||
|
buffer.write('* ');
|
||||||
} else {
|
} else {
|
||||||
throw ArgumentError('Cannot handle block $block');
|
throw ArgumentError('Cannot handle block $block');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user