Skip to content

TableFormatter transformer #12

Description

@roxspring

Implement a transformer that pads GFM table columns to consistent widths for readable plain-text rendering.

Scope

  • Visits all TableBlock nodes (requires commonmark-java TablesExtension)
  • Two-pass approach:
    1. Collect all cell content widths column-by-column to find the maximum per column
    2. Re-emit each row with cells padded to the column maximum
  • Alignment markers (---, :---, ---:, :---:) are also padded consistently

Notes

  • Uses org.commonmark.ext.gfm.tables.TableBlock, TableHead, TableBody, TableRow, TableCell node types from commonmark-ext-gfm-tables
  • Table manipulation operates directly on the AST; re-rendering is handled by MarkdownFormatter

Acceptance criteria

  • All columns in a table are padded to consistent widths
  • Alignment markers are preserved correctly
  • Tables with a single column work correctly
  • Non-table content is unaffected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions