Fixing lint

pull/1828/head
dbrezack 1 year ago
parent 1e36914bf3
commit 9088107706
  1. 28
      lib/src/packages/quill_markdown/markdown_to_delta.dart

@ -21,7 +21,8 @@ typedef ElementToEmbeddableConvertor = Embeddable Function(
);
/// Convertor from Markdown string to quill [Delta].
class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor {
class MarkdownToDelta extends Converter<String, Delta>
implements md.NodeVisitor {
///
MarkdownToDelta({
required this.markdownDocument,
@ -143,7 +144,9 @@ class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor
if (_isInBlockQuote) {
renderedText = text.text;
} else if (_isInCodeblock) {
renderedText = text.text.endsWith('\n') ? text.text.substring(0, text.text.length - 1) : text.text;
renderedText = text.text.endsWith('\n')
? text.text.substring(0, text.text.length - 1)
: text.text;
} else {
renderedText = _trimTextToMdSpec(text.text);
}
@ -245,7 +248,9 @@ class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor
}
void _insertNewLineBeforeElementIfNeeded(md.Element element) {
if (!_isInBlockQuote && _lastTag == 'blockquote' && element.tag == 'blockquote') {
if (!_isInBlockQuote &&
_lastTag == 'blockquote' &&
element.tag == 'blockquote') {
_insertNewLine();
return;
}
@ -283,7 +288,10 @@ class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor
return;
}
if (!_justPreviousBlockExit && (_isTopLevelNode(element) || _haveBlockAttrs(element) || element.tag == 'li')) {
if (!_justPreviousBlockExit &&
(_isTopLevelNode(element) ||
_haveBlockAttrs(element) ||
element.tag == 'li')) {
_justPreviousBlockExit = true;
_insertNewLine();
return;
@ -368,7 +376,8 @@ class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor
result = _effectiveElementToInlineAttr()[element.tag]?.call(element);
}
if (result == null) {
throw Exception('Element $element cannot be converted to inline attribute');
throw Exception(
'Element $element cannot be converted to inline attribute');
}
return result;
}
@ -387,7 +396,8 @@ class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor
List<Attribute<dynamic>> _toBlockAttributes(md.Element element) {
final result = _effectiveElementToBlockAttr()[element.tag]?.call(element);
if (result == null) {
throw Exception('Element $element cannot be converted to block attribute');
throw Exception(
'Element $element cannot be converted to block attribute');
}
return result;
}
@ -399,10 +409,12 @@ class MarkdownToDelta extends Converter<String, Delta> implements md.NodeVisitor
};
}
bool _isEmbedElement(md.Element element) => _effectiveElementToEmbed().containsKey(element.tag);
bool _isEmbedElement(md.Element element) =>
_effectiveElementToEmbed().containsKey(element.tag);
Embeddable _toEmbeddable(md.Element element) {
final result = _effectiveElementToEmbed()[element.tag]?.call(element.attributes);
final result =
_effectiveElementToEmbed()[element.tag]?.call(element.attributes);
if (result == null) {
throw Exception('Element $element cannot be converted to Embeddable');
}

Loading…
Cancel
Save