2

I have the following neat little table in reStructuredText:

======   =======   ======  =====================
Symbol   Meaning   Type    Example
======   =======   ======  =====================
   G     Era       Text    "GG" -> "AD"
   y     Year      Number  "yy" -> "03"
                           "yyyy" -> "2003"
   M     Month     Text    "M" -> "7"
                   or      "M" -> "12"
                   Number  "MM" -> "07"
                           "MMM" -> "Jul"
                           "MMMM" -> "December"
======   =======   ======  =====================

As per the Docutils documentation on simple tables I would expect the resulting HTML table that Spinx generates to be as layed out in the text, so "yy" and "yyyy" would be on different lines, as would be "M", "MM" and so on. However the result is this:

HTML table example generated by Sphinx. Contains Date format strings.

I have tried some alternatives like using pipes (|) at the beginning of the last column, empty lines, indentation. The closest I came was using an indent before "yyyy". Then the "yyyy" is on the next line, but it is indented. Of course I want it to be on the same indentation level as "yy".

Zero Piraeus
  • 56,143
  • 27
  • 150
  • 160
titusn
  • 1,201
  • 1
  • 12
  • 43

1 Answers1

7

What you need is a line block:

======   =======   ======  =====================
Symbol   Meaning   Type    Example
======   =======   ======  =====================
   G     Era       Text    "GG" -> "AD"
   y     Year      Number  | "yy" -> "03"
                           | "yyyy" -> "2003"
   M     Month     Text    | "M" -> "7"
                   or      | "M" -> "12"
                   Number  | "MM" -> "07"
                           | "MMM" -> "Jul"
                           | "MMMM" -> "December"
======   =======   ======  =====================

Example output:

RestructuredText Table with Line blocks

(source)

Zero Piraeus
  • 56,143
  • 27
  • 150
  • 160
  • Ah, yes I did try it before, but it didn't work. I probably didn't try extending it over both rows or I got the indent wrong. Will try first thing in the morning. Thanks! – titusn Jul 30 '13 at 19:37
  • Yes, it works. Turns out I got the spacing wrong. Very important to include a space after the pipe symbol. – titusn Jul 31 '13 at 07:36