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);

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

  if (_haveBlockAttrs(element)) {
    _activeBlockAttributes.addLast(_toBlockAttributes(element));
  }
  if (_haveInlineAttrs(element)) {
    _activeInlineAttributes.addLast(_toInlineAttributes(element));
  }

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

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

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

  return true;
}