/// Parses a table into its three parts: /// /// * a head row of head cells (`<th>` cells) /// * a divider of hyphens and pipes (not rendered) /// * many body rows of body cells (`<td>` cells) public override Node parse(BlockParser parser) { var alignments = parseAlignments(parser.next); var columnCount = alignments.Count; var headRow = parseRow(parser, alignments, "th"); if (headRow.children.Count != columnCount) { return(null); } var head = new Element("thead", new List <Node>() { headRow }); // Advance past the divider of hyphens. parser.advance(); var rows = new List <Element>() { }; while (!parser.isDone && !BlockSyntax.isAtBlockEnd(parser)) { var row = parseRow(parser, alignments, "td"); while (row.children.Count < columnCount) { // Insert synthetic empty cells. row.children.Add(Element.empty("td")); } while (row.children.Count > columnCount) { row.children.removeLast(); } rows.Add(row); } if (rows.isEmpty()) { return(new Element("table", new List <Node>() { head })); } else { var body = new Element("tbody", rows); return(new Element("table", new List <Node>() { head, body })); } }
public override Node parse(BlockParser parser) { parser.advance(); return(Element.empty("hr")); }