parse method

List<Node>? parse()

Implementation

List<Node>? parse() {
  // Make a fake top tag to hold the results.
  _stack.add(TagState(0, 0, null, null));

  while (!isDone) {
    // See if any of the current tags on the stack match.  This takes
    // priority over other possible matches.
    if (_stack.reversed.any((state) => state.syntax != null && state.tryMatch(this))) {
      continue;
    }

    // See if the current text matches any defined markdown syntax.
    if (syntaxes.any((syntax) => syntax.tryMatch(this))) {
      continue;
    }

    // If we got here, it's just text.
    advanceBy(1);
  }

  // Unwind any unmatched tags and get the results.
  return _stack[0].close(this, null);
}