visitElementBefore method

  1. @override
bool visitElementBefore(
  1. Element element
)

Called when an Element has been reached, before its children have been visited.

Returns false to skip its children.

Implementation

@override
bool visitElementBefore(md.Element element) {
  _insertNewLineBeforeElementIfNeeded(element);

  _didRemoveTrailingSoftLineBreak = false;
  final tag = element.tag;
  _currentBlockTag ??= tag;
  _lastTag = tag;

  if (_haveBlockAttrs(element)) {
    _addBlockAttrs(_toBlockAttributes(element));
  }
  if (_haveInlineAttrs(element)) {
    _addInlineAttrs(_toInlineAttributes(element));
  }

  if (tag == 'blockquote') {
    _isInBlockQuote = true;
  }

  if (tag == 'pre') {
    _isInCodeblock = true;
  }

  if (tag == 'li') {
    _listItemIndent++;
  }

  return true;
}