Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do cell vertical alignment in markdown/pandoc table?

Is there a way to to specify the vertical alignment of table cell contents in markdown/pandoc?

Details:
The default behavior is center alignment, I want cell contents to be aligned to the top of the cell. For an example of the default behavior:

|           |               |
|-----------|---------------|
| Something | This is a very long line that breaks into two. This is a very long line that breaks into two.This is a very long line that breaks into two.This is a very long line that breaks into two.|

The contents of the left cell in the example above will be vertically-centered.

like image 348
Mustafa Avatar asked Dec 01 '14 02:12

Mustafa


1 Answers

Use multiline table syntax (supported by Pandoc only -- it is a Pandoc-specific extension of Markdown):

   -------------------------------------------------------------
    Centered   Default           Right Left
     Header    Aligned         Aligned Aligned
   ----------- ------- --------------- -------------------------
      First    row                12.0 Example of a row that
                                       spans multiple lines.

     Second    row                 5.0 Here's another one. Note
                                       the blank line between
                                       rows.
   -------------------------------------------------------------

   Table: Here's the caption. It, too, may span
   multiple lines.

Multiline tables allow headers and table rows to span multiple lines of text (but cells that span multiple columns or rows of the table are not supported).

These work like simple tables, but with the following differences:

  • They must begin with a row of dashes, before the header text (unless the headers are omitted).

  • They must end with a row of dashes, then a blank line.

  • The rows must be separated by blank lines.

In multiline tables, the table parser pays attention to the widths of the columns, and the writers try to reproduce these relative widths in the output. So, if you find that one of the columns is too narrow in the output, try widening it in the markdown source.

like image 135
Kurt Pfeifle Avatar answered Sep 21 '22 14:09

Kurt Pfeifle