Skip to content

Optimize table formatting for text readability #133

@colindean

Description

@colindean

When I have the urge to format a Markdown table, I generally have one of two outcomes in mind:

  • optimize for storage
  • optimize for readability

Currently, comrak defaults to optimizing for storage. That is, a table input with extra spaces or dashes loses in output any unnecessary spaces or dashes in cells.

I'd like to see an option to optimize for readability. That is, a table input will have its cells padded with spaces or dashes to fit the longest cell in that column.

Example input:

| h1 | h2 | h3 |
|---|---|---|
| data1 | data2 | wide cell data |
| data1      | data2     | data3      |
|     longerdata | data2      |      data3 |

Comrack 0.6.2 output, optimized for storage:

| h1 | h2 | h3 |
| --- | --- | --- |
| data1 | data2 | wide cell data |
| data1 | data2 | data3 |
| longerdata | data2 | data3 |

Output optimized for text readability by markdowntable.com (src):

| h1         | h2    | h3             |
|------------|-------|----------------|
| data1      | data2 | wide cell data |
| data1      | data2 | data3          |
| longerdata | data2 | data3          |

This latter format is better for static files like READMEs that are just as often read in text format as they are consumed in HTML format and other places where editing the table is more important than reducing the byte size of the table.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions