Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line table cell in reStructuredText?

Tags:

Is there a way to input a newline into a table cell? For example, say I have a table like this:

+==========+==========+==========+ + Header 1 + Header 2 + Header 3 + +==========+==========+==========+ + Item 1   +          +          + + Item 2   +          +          + +----------+----------+----------+ 

I want the above to create a table with two rows, three columns, and the second row, first column to display Item 1 and Item 2 on separate lines.

I have tried the line blocks syntax |, but it doesn't work inside a table cell. I can use list syntax, but I don't want bullet points to appear.

like image 254
Kiet Tran Avatar asked Nov 22 '12 01:11

Kiet Tran


2 Answers

First of all I think your table syntax is incorrect, should it not be:

+----------+----------+----------+ | Header 1 | Header 2 | Header 3 | +==========+==========+==========+ | Item 1   |          |          | | Item 2   |          |          | +----------+----------+----------+ 

Note that the top row is made up of hyphens, not equal signs, and the rows are separated by pipes, |, not plus signs.

Now with this table, the line block syntax:

+----------+----------+----------+ | Header 1 | Header 2 | Header 3 | +==========+==========+==========+ | | Item 1 |          |          | | | Item 2 |          |          | +----------+----------+----------+ 

seems to work: testing with Pandoc the bottom left cell gets transformed into the following HTML:

<td align="left">Item 1<br />Item 2</td> 

Note the line break <br /> in between Item 1 and Item 2.

like image 127
Chris Avatar answered Sep 17 '22 14:09

Chris


You can also leave a gap between the lines like this

+----------+----------+----------+ | Header 1 | Header 2 | Header 3 | +==========+==========+==========+ | Item 1   |          |          | |          |          |          | | Item 2   |          |          | +----------+----------+----------+ 

This method tends to be friendlier with editors so they dont think you have accidentally added an extra pipe

like image 32
Tim Hughes Avatar answered Sep 18 '22 14:09

Tim Hughes