Tables Extension

Vladimir Schneider edited this page Mar 19, 2018 · 1 revision

flexmark-java extension for table processing


Enables tables using pipes as in GitHub Flavored Markdown. With added options to handle column span syntax, ability to have more than one header row, disparate column numbers between rows, etc.

Converts pipe | delimited text to table elements:

|    Heading Centered    | Heading Left Aligned   |  Heading Centered  |   Heading Right Aligned |
| Cell text left aligned | Cell text left aligned | Cell text centered | Cell text right aligned |
| cell 21                | cell 22                |      cell 22       |                 cell 22 |


If GitHub table rendering option is not selected then tables can have multiple header rows, number of columns in table body does not need to match header or separator line columns and column spans can be specified by adding consecutive | at the end of the cell. Each pipe represents column span count || spans two columns, ||| three, etc.

When column span syntax is enabled, empty table cells must have at least one space. Otherwise they will be interpreted as column spans for the previous cell.

Note that this extended syntax is not supported by GitHub.

:warning: Table elements must be preceded by a blank line to be processed by this extension.

Parsing Details

Use class TablesExtension in artifact flexmark-ext-gfm-tables.

The following options are available:

Defined in TablesExtension class:

Static Field Default Value Description
MIN_HEADER_ROWS 0 minimum number of header rows
MAX_HEADER_ROWS Integer.MAX_INTEGER maximum number of header rows
HEADER_SEPARATOR_COLUMN_MATCH false when true only tables whose header lines contain the same number of columns as the separator line will be recognized
APPEND_MISSING_COLUMNS false whether table body columns should be at least the number or header columns
DISCARD_EXTRA_COLUMNS false whether to discard body columns that are beyond what is defined in the header
COLUMN_SPANS true treat consecutive pipes at the end of a column as defining spanning column.
WITH_CAPTION true when true will parse table caption line, line after table with format [ ... ]
CLASS_NAME `` class name to use on tables
FORMAT_LEAD_TRAIL_PIPES true formatting option when enabled adds opening and closing pipes on table rows, see: Markdown Formatter
FORMAT_SPACE_AROUND_PIPE true formatting option when enabled adds space around cell text, see: Markdown Formatter
FORMAT_ADJUST_COLUMN_WIDTH true expand columns to align column pipes across rows, formatting option see: Markdown Formatter
FORMAT_APPLY_COLUMN_ALIGNMENT true when true and FORMAT_ADJUST_COLUMN_WIDTH is true then apply column alignment to cell text, formatting option see: Markdown Formatter
FORMAT_FILL_MISSING_COLUMNS false when true add columns to make all rows have same number of columns, formatting option see: Markdown Formatter
FORMAT_REMOVE_CAPTION false when true table caption is removed, formatting option when enabled removes table caption, see: Markdown Formatter
FORMAT_LEFT_ALIGN_MARKER DiscretionaryText.AS_IS how to handle the left align : in output, formatting option see: Markdown Formatter
  • DiscretionaryText
    • AS_IS: no change
    • ADD: add to columns which have no alignment
    • REMOVE: remove from columns which have left alignment

When used with Formatter renderer with default options will convert:

nov. 2. tue|10:00|4h 40m
nov. 3. thu|11:00|4h
nov. 7. mon|10:20|4h 20m
total:|| **13h**


| day         | time  |   spent |
| nov. 2. tue | 10:00 |  4h 40m |
| nov. 3. thu | 11:00 |      4h |
| nov. 7. mon | 10:20 |  4h 20m |
| total:             || **13h** |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.