visitText method
Called when a Text node has been reached.
Implementation
@override
void visitText(md.Text text) {
String renderedText;
if (_isInBlockQuote) {
renderedText = text.text;
} else if (_isInCodeblock) {
renderedText = text.text.endsWith('\n')
? text.text.substring(0, text.text.length - 1)
: text.text;
} else {
renderedText = _trimTextToMdSpec(text.text);
}
if (renderedText.contains('\n')) {
var lines = renderedText.split('\n');
if (renderedText.endsWith('\n')) {
lines = lines.sublist(0, lines.length - 1);
}
for (var i = 0; i < lines.length; i++) {
final isLastItem = i == lines.length - 1;
final line = lines[i];
_delta.insert(line, _effectiveInlineAttrs());
if (!isLastItem) {
_delta.insert('\n', _effectiveBlockAttrs());
}
}
} else {
_delta.insert(renderedText, _effectiveInlineAttrs());
}
_lastTag = null;
_justPreviousBlockExit = false;
}