processSpaceCharactersDropNewline method

void processSpaceCharactersDropNewline(
  1. StringToken token
)

Implementation

void processSpaceCharactersDropNewline(StringToken token) {
  // Sometimes (start of <pre>, <listing>, and <textarea> blocks) we
  // want to drop leading newlines
  var data = token.data;
  dropNewline = false;
  if (data.startsWith('\n')) {
    final lastOpen = tree.openElements.last;
    if (const ['pre', 'listing', 'textarea'].contains(lastOpen.localName) &&
        !lastOpen.hasContent()) {
      data = data.substring(1);
    }
  }
  if (data.isNotEmpty) {
    tree.reconstructActiveFormattingElements();
    tree.insertText(data, token.span);
  }
}