Commit Graph

82 Commits

Author SHA1 Message Date
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
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
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Martin Geisler
cfb7949d48 minirst: update module docstring 2009-11-07 03:22:03 +01:00
Martin Geisler
4c7564177a minirst: support enumerated lists 2009-11-07 03:14:56 +01:00
Martin Geisler
04f9650185 minirst: prepare for general types of bullet lists
The old code worked for '-' bullets only, but we can easily support
variable width bullets.
2009-11-07 03:04:46 +01:00
Martin Geisler
182015cfeb minirst: combine list parsing in one function
Bullet, option, field, and definition lists were parsed very similar
code. They are now parsed by a single function (splitparagraphs).

Some logic from the old parsing functions has been moved down to
formatblock. This simplifies the parsing while putting the logic where
it's really needed.
2009-11-06 00:30:35 +01:00
Martin Geisler
25e020bb8c minirst: remove unnecessary "elif:" statements 2009-11-05 21:30:50 +01:00
Martin Geisler
fb05a0948c minirst: convert `foo` into "foo" upon display
This lets us markup many more occurances of inline literals since they
no longer look strange in the terminal output.
2009-10-20 22:16:27 +02:00
Martin Geisler
8b8fb723b7 help: un-indent help topics
The help topics are reused in the HTML documentation, and there it
looks odd that whole sections are indented. We now only indent it for
output on the terminal.
2009-10-04 12:18:43 +02:00
Martin Geisler
298efc8d54 util, minirst: do not crash with COLUMNS=0 2009-09-03 21:07:06 +02:00
Martin Geisler
d2c1c263b4 minirst: parse field lists 2009-08-02 23:38:07 +02:00
Martin Geisler
e0160ceaeb minirst: simplify bullet list indentation computation 2009-08-02 21:29:15 +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
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
d96f024a4b minirst: don't test regexps twice
We know the regexps match since splitparagraphs used them too.
2009-12-13 22:37:30 +01:00
Martin Geisler
e1df25704d minirst: run inlineliterals too in debug mode 2009-12-13 19:24:24 +01:00