tableRowCells method

Parser<List<TableCellNode>> tableRowCells()
inherited

Implementation

Parser<List<TableCellNode>> tableRowCells() => [
  // Form 1: starts with |
  seq3(
    char('|'),
    ref0(tableCellContent).plusSeparated(char('|')),
    char('|').optional(),
  ).map3((_, cells, _) => _cleanCells(cells.elements)),
  // Form 2: at least 2 cells separated by | without leading |
  seq2(
    ref0(tableCellContent),
    char('|').then(ref0(tableCellContent)).plus(),
  ).map2(
    (first, rest) =>
        [first, ...rest.map((r) => r.$2)].map(TableCellNode.new).toList(),
  ),
].toChoiceParser();