Commit Graph

30 Commits

Author SHA1 Message Date
Simon Heimberg
0aad267371 minirst: create valid output when table data contains a newline
When table data contained a newline, the result of minirst.maketable
did not look nice plus it was not recognised by minirst.format:
  == === ====
  l1 1   one
  l2 2   2
22
  l3
  == === ====

This problem occurred when the description of options had a very long
translation which was split by newlines. Do not bother a translator with
this detail.

The multiline translations for option descriptions have been fixed in
7a88a81d5d9e in it.po, de.po and ro.po. I manually did the same as this patch
does, I removed the newlines.

When a newline was in the description, this created unusable help output:
  $ hg help somecommand
  hg somecommand [option]...

  with somecommand, you can...

  options:

  == =================== =======================================================
  =================================== --longdesc VALUE    xxxxxxxxxxxxxxxxxxxxxx
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -n --norm
  normal desc --newline VALUE line1 line2 == =================== ===============
  ===========================================================================

now this looks much nicer:
  ...
  options:

      --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                       xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   -n --norm           normal desc
      --newline VALUE  line1 line2
2014-02-19 17:32:21 +01:00
Simon Heimberg
c3b209ae8d tests: modify minirst test input to new format
Modifying the test input data shows the effects of the last patches.
In text output nothing has changed.
In html output the title has moved on its own line.
2013-11-04 10:23:06 +01:00
Dan Villiom Podlaski Christiansen
e6781fbadb minirst: HTML formatter tweaks
output table rows on distinct lines
don't make the first row a table header
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
5ff9149ead minirst: CGI escape strings prior to embedding it in the HTML 2013-02-09 17:44:25 -05:00
Dan Villiom Podlaski Christiansen
768b2c3969 minirst: don't generate TH elements for the first row in table
We mainly use them for option tables -- browsers bolding and centering
them looks wrong.
2013-02-09 21:51:21 +00:00
Olav Reinert
cfc7a5074e minirst: simplify and standardize field list formatting
The default width of field lists is changed from 12 to 14 to align minirst with
the rst2html tool. Shrinking the width of the left column to fit the content is
removed, to keep formatting simple and uniform.
2012-01-11 18:08:25 +01:00
Matt Mackall
3e9b4998db minirst: improve test harness 2011-10-15 00:39:06 -05:00
Matt Mackall
7791d14df5 minirst: add style flag to format 2011-10-15 00:39:04 -05:00
Matt Mackall
cdd258d4fd minirst: add basic HTML formatting support 2011-10-15 00:39:01 -05:00
Matt Mackall
cca20e5611 minirst: end all blocks with newlines
Formerly RST blocks were formatted without a trailing newline, which
wasn't particularly helpful. Now everything that comes back from the
formatter has a trailing newline so remove all the extra ones added by
users.
2011-09-17 14:17:09 -05:00
Matt Mackall
a2ffbae5a5 minirst: add a helper function to build an RST table from an array 2011-08-11 22:40:43 -05:00
Matt Mackall
4f50548371 minirst: add simple table support
This adds a subset of the 'simple table' support from RST to allow
formatting of options lists through RST. Table columns are
automatically sized based on contents, with line wrapping in the last
column.
2011-08-11 22:05:57 -05:00
Erik Zielke
cd95a50630 minirst: improved support for option lists.
This enables minirst to parse and print option lists which have both
long and short options. Before, we could only parse option lists with
long options.
2010-11-02 17:44:19 +01:00
Erik Zielke
87792363c2 minirst: modified minirst to also recognize empty comments.
The modifies minirst to also handle empty comments. An empty comment
is a block with a single line containing two dots.
2010-11-16 13:29:08 +01:00
Martin Geisler
98ed55bc01 minirst: ignore comments 2010-10-23 17:30:08 +02:00
Erik Zielke
208cfeec63 minirst: Support for admonitions
The old asciidoc format supported something like this,
this is why there is NOTE: scattered here and there.
2010-09-22 15:51:59 +02:00
Martin Geisler
0d2cf4548b minirst: support all recommended title adornments 2010-04-25 18:19:54 +02:00
Martin Geisler
52cafb8233 minirst: correctly format sections containing inline markup
Before, a section like

  ``foo``
  -------

would be formatted as

  "foo"
  -------

We now recompute the length of the underline when formatting the
section.
2010-04-25 17:48:26 +02:00
Martin Geisler
3213b9890f minirst: add test for sections 2010-04-25 16:17:24 +02:00
Martin Geisler
1d06245892 doc, minirst: support hg interpreted text role 2010-04-22 10:04:53 +02:00
Martin Geisler
63c19fe3c4 minirst: add margin around definition items
This greatly improves the output of 'hg help env'.
2010-04-18 15:47:49 +02:00
Martin Geisler
5d5d51ef46 minirst: support line blocks 2010-02-13 21:21:40 +01:00
Martin Geisler
9abe6f2e23 minirst: report pruned container types 2010-02-13 18:11:08 +01:00
Martin Geisler
5d09b1af66 minirst: support containers
Text can be grouped into generic containers in reStructuredText:

  .. container:: foo

     This is text inside a "foo" container.

     .. container:: bar

        This is nested inside two containers.

The minirst parser now recognizes these containers. The containers are
either pruned completely from the output (included all nested blocks)
or they are simply un-indented. So if 'foo' and 'bar' containers are
kept, the above example will result in:

     This is text inside a "foo" container.

     This is nested inside two containers.

If only 'foo' containers are kept, we get:

     This is text inside a "foo" container.

No output is made if only 'bar' containers are kept.

This feature will come in handy for implementing different levels of
help output (e.g., verbose and debug level help texts).
2009-10-04 22:03:41 +02:00
Martin Geisler
1a33bb5ceb minirst: improve layout of field lists
Before, we used the padding following the key to compute where to wrap
the text. Long keys would thus give a big indentation. It also
required careful alignment of the source text, making it cumbersome to
items to the list.

We now compute the maximum key length and use that for all items in
the list. We also put a cap on the indentation: keys longer than 10
characters are put on their own line. This is similar to how rst2html
handles large keys: it uses 14 as the cutoff point, but I felt that 10
was better for monospaced text in the console.
2009-12-13 23:49:53 +01:00
Martin Geisler
4c7564177a minirst: support enumerated lists 2009-11-07 03:14:56 +01:00
Martin Geisler
7271a9da14 test-minirst: don't test on invalid reST input
Input such as

      Only the
    left-most line
  (this line!)
    is significant
      for the indentation

is not valid reStructuredText: the first line starts a block quote,
but then the second line is not allowed to be unindented.
2009-11-05 21:53:22 +01:00
Martin Geisler
d2c1c263b4 minirst: parse field lists 2009-08-02 23:38:07 +02:00
Martin Geisler
65b64640d1 minirst: indent literal blocks with two spaces
The vast majority* of them are formatted like this in the source, so
this basically reverts the output to how it looked before we got the
minirst parser.

*: the help on templating use four spaces for some examples and will
   now shown with an indentation of just two spaces.
2009-08-02 17:17:17 +02:00
Martin Geisler
7953ecf0bd minimal reStructuredText parser 2009-07-16 23:25:25 +02:00