render method

String render(
  1. List<Node> nodes
)

Renders a markdown string to styled ANSI output.

Implementation

String render(List<md.Node> nodes) {
  _outputBuffer.clear();
  _blockStack.clear();
  _inlineStack.clear();
  _linkStack.clear();
  _listCounters.clear();
  _listIsOrdered.clear();
  _lastChar = 0;

  // Push document root block
  _enterBlock(theme.document, width);

  for (final node in nodes) {
    node.accept(this);
  }

  // Pop document root block which flushes to output
  _exitBlock();

  // Trim trailing newlines if any
  var result = _outputBuffer.toString();
  while (result.endsWith('\n\n')) {
    result = result.substring(0, result.length - 1);
  }
  return result;
}