exportToMarkdown method

String exportToMarkdown()

Implementation

String exportToMarkdown() {
  final root = document.content;
  final buffer = StringBuffer();
  final nodes = root.nodes;
  for (var i = 0; i < nodes.length; i++) {
    final md = _nodeToMarkdown(nodes[i]);
    if (md.isEmpty) continue;
    buffer.write(md);
    // Separate blocks with a blank line so Markdown renders them
    // as distinct paragraphs / lists / tables.
    if (i < nodes.length - 1) buffer.write('\n\n');
  }
  return buffer.toString().trim();
}