Commit Graph

70 Commits

Author SHA1 Message Date
Dan Villiom Podlaski Christiansen
17ccef70f8 minirst: optimize HTML table generation a bit
avoid a couple of array copies and string interpolations
2013-02-09 21:51:21 +00: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
Dan Villiom Podlaski Christiansen
d045d03b91 help: use a full header for topic titles
...for prettier HTML!
2013-02-10 12:58:57 +01:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Olav Reinert
70c42374e2 minirst: generate tables as a list of joined lines 2012-06-01 11:58:23 +02: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
FUJIWARA Katsunori
f6b7a91d98 minirst: use unicode string as intermediate form for replacement
# this change redones part of e0051068893a, backed out by 38c00c035629

Some character encodings use ASCII characters other than
control/alphabet/digit as a part of multi-bytes characters, so direct
replacing with such characters on strings in local encoding causes
invalid byte sequences.

[mpm: test changed to simple doctest]
2011-10-31 21:06:18 +09: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
2a412dcdd8 rst: fix detection of single-row tables
This fixes option lists for commands with only an --mq option.
2011-10-02 13:13:46 -05:00
Matt Mackall
4204f3ffa5 help: use RST to format option lists 2011-09-21 13:00:48 -05:00
Matt Mackall
52b9791173 minirst: fix column handling for simple tables 2011-09-21 13:00:47 -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
35cdad6929 minirst: don't choke on empty text 2011-09-17 13:42:11 -05:00
Matt Mackall
5195ef177c minirst: remove some whitespace 2011-09-17 13:37:50 -05:00
Matt Mackall
39b5b8b931 minirst: remove pointless transcoding 2011-09-17 13:37:49 -05:00
Matt Mackall
f48ca50b08 minirst: fix container stripping logic 2011-09-16 14:37:53 -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
08834d9ea2 minirst: drop debug code
This standalone mode no longer works due to the mechanics of import
and util. When run not as part of a package, the import of util causes
an import of the built-in posix module, which doesn't contain the
expected symbols. This is difficult to fix in Py2.4.
2011-08-11 22:40:41 -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
Matt Mackall
b9b0379815 minirst: only strip leading newlines, not indentation 2011-08-11 22:05:31 -05:00
Matt Mackall
5fb24e4d76 minirst: add decorateblocks search helper 2011-08-02 17:43:20 -05:00
Matt Mackall
4cee9b4b85 minirst: add getsections helper 2011-08-02 17:43:18 -05:00
Matt Mackall
9b6295af46 minirst: add formatblocks helper 2011-08-02 17:41:45 -05:00
Matt Mackall
8a607bdb6b minirst: add parse method to get document structure 2011-08-02 14:54:38 -05:00
Martin Geisler
ce8ced9777 minirst: read test input from stdin 2011-05-26 10:46:34 +02:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02: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
c5a85fb04a minirst: better interaction between comments and margins
You can now split a list with a comment:

  * foo

  .. separator

  * bar

and the two list items will no longer be run together, that is the
output is

  * foo

  * bar

instead of

  * foo
  * bar
2010-11-16 11:10:50 +01:00
Martin Geisler
c0684c364b minirst: link to HelpStyleGuide in docstring 2010-11-10 14:46:13 +01:00
Matt Mackall
fce98d3778 minirst: use colwidth to match title lengths (issue2455) 2010-10-27 15:35:23 -05:00
Martin Geisler
98ed55bc01 minirst: ignore comments 2010-10-23 17:30:08 +02:00
Martin Geisler
428161f105 minirst: pull admonition titles out formatblock function 2010-10-08 23:23:49 +02:00
Martin Geisler
172cccbec3 minirst: refactor/simplify findblocks 2010-10-08 23:19:26 +02:00
Martin Geisler
0758677299 minirst: small code cleanup 2010-10-08 22:42:32 +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
FUJIWARA Katsunori
c90b346d0a minirst: use unicode string as intermediate form for replacement
Some character encodings use ASCII characters other than
control/alphabet/digit as a part of multi-bytes characters, so direct
replacing with such characters on strings in local encoding causes
invalid byte sequences.
2010-06-30 12:44:58 +09:00
FUJIWARA Katsunori
9cce255bec replace Python standard textwrap by MBCS sensitive one for i18n text
Mercurial has problem around text wrapping/filling in MBCS encoding
environment, because standard 'textwrap' module of Python can not
treat it correctly. It splits byte sequence for one character into two
lines.

According to unicode specification, "east asian width" classifies
characters into:

   W(ide), N(arrow), F(ull-width), H(alf-width), A(mbiguous)


W/N/F/H can be always recognized as 2/1/2/1 bytes in byte sequence,
but 'A' can not. Size of 'A' depends on language in which it is used.

Unicode specification says:

   If the context(= language) cannot be established reliably they
   should be treated as narrow characters by default

but many of class 'A' characters are full-width, at least, in Japanese
environment.

So, this patch treats class 'A' characters as full-width always for
safety wrapping.

This patch focuses only on MBCS safe-ness, not on writing/printing
rule strict wrapping for each languages

MBCS sensitive textwrap class is originally implemented
by ITO Nobuaki <daydream.trippers@gmail.com>.
2010-06-06 17:20:10 +09:00
Martin Geisler
e11007adaf minirst: handle line breaks in hg role 2010-05-18 16:24:14 +02:00
Martin Geisler
3411550e7e Merge with stable 2010-05-17 21:30:00 +02:00
Martin Geisler
88705a5b97 minirst: fix debug code 2010-05-17 20:42:28 +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
1d06245892 doc, minirst: support hg interpreted text role 2010-04-22 10:04:53 +02:00
Martin Geisler
ccd0b02516 minirst: removed unnecessary initindent variable 2010-04-18 15:47:49 +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