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".

有帮助吗?

解决方案

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)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top