visitText method

  1. @override
void visitText(
  1. Text text
)
override

Called when a Text node has been reached.

Implementation

@override
void visitText(Text text) {
  var content = text.text;
  if (const {'br', 'p', 'li'}.contains(_lastVisitedTag)) {
    var lines = LineSplitter.split(content);
    content = !_trimLeft || content.contains('<pre>')
        ? lines.join('\n')
        : lines.map((line) => line.trimLeft()).join('\n');
    if (text.text.endsWith('\n')) {
      content = '$content\n';
    }
  }
  buffer.write(content);

  _lastVisitedTag = null;
}