Preserve Pipe Table column width in markdown to markdown conversion? #9464
-
As part of a document transformation, we do a markdown to markdown conversion to insert yaml metadata into the markdown content of a document before eventually converting that new markdown to html. In the grand sense, I want to preserve column widths as defined in pipe tables in markdown all the way through to the table colgroup / col style assignments in html. The first step of that is to understand how to preserve pipe table column widths in a markdown to markdown conversion. Converting this sample markdown # This Table Is Short
| Col1 | Col2 |
|:----|:------------------:|
| val1 | text 1 that is longer but not that long |
| val2 | text 2 that is short |
| s1 that can wrap and do stuff | More short text |
# This Table Is Long
| Col1 | Col2 |
|:-----------|:-------------------------------:|
| val1 | text 1 that is longer but not that long |
| val2 | text 2 that is short |
| val3 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, | using this command:
yields this output:
As I've learned through experimentation, table output behavior is heavily dependent on the Is there a way to do this? Also, if it helps, the second stage markdown doesn't have to be human readable as it is 'in process' during our transformations. If there is another table format that can preserve those column width percentages, I'd be fine with that. Thanks for the input! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is as documented. Relative column widths for pipe tables are only generated if the source of the table is longer than You can of course make any table wider than |
Beta Was this translation helpful? Give feedback.
This is as documented. Relative column widths for pipe tables are only generated if the source of the table is longer than
columns
. That is why your first table is parsed as a "simple table," without relative width information.https://pandoc.org/MANUAL.html#extension-pipe_tables
You can of course make any table wider than
columns
by increasing the width of the separator lines.