|
From: David G. <go...@us...> - 2002-09-15 14:31:36
|
I am considering relaxing the 4-character minimum requirement for
reStructuredText section title underlines, and would like to determine
the best course of action. The spec states:
An underline/overline is a single repeated punctuation character
that begins in column 1 and forms a line extending at least as far
as the right edge of the title text. ... An underline/overline
must be at least 4 characters long (to avoid mistaking ellipses
["..."] for overlines).
(http://docutils.sf.net/spec/rst/reStructuredText.html#sections)
The 4-character minimum on transition markers will remain, regardless.
Sometimes a title is less than 4 characters long, and it's natural to
want to use an underline of exactly the same length. I've noticed
such cases in others' documents, and in my own. In my own document, I
used a 3-character underline; the title was parsed as an ordinary
paragraph and it took some time to discover the problem and fix it,
because the parser produced no warning.
Here's the current entry in the "Bugs" section of the "To Do" list:
Section headers must have underlines at least 4 characters long.
But when the section title is only 3 characters long, it's natural
to underline with "===" (I just did). The parser should produce a
warning in such cases.
Or should the parser simply recognize such short underlines? A
zero-tolerance policy might work: over/underlines of 3 or fewer
characters which are shorter than the "title" text are not
recognized as titles, and should generate an "info" message.
There has also been a bug report submitted on the issue (by Jeremy
Hylton):
http://sf.net/tracker/?func=detail&atid=422030&aid=608108&group_id=38414
There's no problem with the typical case, where the over/underlines
are at least as long as the title text::
ABC
===
---
DEF
---
But what to do when the over/underline is too short? Ellipsis ("...")
and m-dash (commonly written "---") both use 3 repeated punctuation
characters; this ambiguity is what the 4-character minimum avoided. For
example::
Is This Supposed To Be A Title?
---
This, surely, is not
...
In these cases, I'm thinking of inserting INFO (level 1) system
messages that say, "Possible title underline, too short for the title
text. Treating it as ordinary text because it's so short." INFO
system messages are not normally visible (shown only if the
-v/--verbose option is used). In other words, short underlines (<= 3
characters) are recognized as title adornments if they're long enough
for the title text, but if they're too short they're just wrapped text
plus a normally-invisible system message. I think this is the right
balance of precision (unambiguous, unsurprising) and "do what I say"
(intuitive).
How about these cases, of overlines? Unless stated otherwise, the
short overlines would each be treated as ordinary text and an INFO
system message inserted::
...
This is not a title; perhaps an excerpt from a quote.
..
This is interpreted as a comment start immediately followed by a
paragraph. Triggers a "no blank line; unexpected unindent"
warning.
==
These lines would not be interpreted as a title.
==
---
The three dashes above might represent an m-dash.
==
Would this become a definition list?
==
And what about this? A definition list item followed by a
paragraph and a "no blank line; unexpected unindent" warning.
==
And when section titles are not expected/allowed::
Ordinary paragraph.
This title should trigger a SEVERE error (sections not allowed
inside block quotes), as currently happens with longer titles:
ABC
===
This title should trigger an INFO message and be treated as an
ordinary paragraph, since the underline is too short for the
title:
ABC
==
Does all of this seem reasonable? Any gotchas I'm missing?
--
David Goodger <go...@us...> Open-source projects:
- Python Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)
- The Go Tools Project: http://gotools.sourceforge.net/
|
|
From: David G. <go...@us...> - 2002-09-20 03:21:04
|
I have removed the 4-character minimum requirement for section title
underlines and overlines. The following section titles will now
process as expected::
ABC
===
---
DEF
---
The original reason for the minimum was to avoid misinterpretation of
common punctuation constructs, such as ellipsis ("...") and m-dash
("---"). The parser now allows for such constructs where they may
otherwise be misinterpreted as title adornments. For example, all of
the following will parse as ordinary paragraphs::
This is not a title
...
...
nor is this
Or this
---
Level-1/INFO system messages are inserted wherever there's any
question. Normally, level-1/INFO messages are not visible; to see
them, use the --verbose, -v, or --report-level=info options.
There is still one limitaton. A two-period overlined title is not
possible, because it will be parsed as a comment start. The text
immediately following will generate a warning because there's no
intervening blank line::
..
Hi
..
Extending the over/underlines to 3 characters makes it work::
...
Hi
...
A two-period *underline* has no problem though::
Hi
..
In other recent news:
* A subtle bug that introduced unwanted empty rows in some "simple"
tables has been fixed.
* The locale-setting code in front ends has been made fault-tolerant.
* The definition of "simple reference names" has been altered
slightly: internal hyphens, periods, and underscores may only occur
one at a time, not two or more adjacent. This prevents text like
"object.__method__" from being parsed as a reference (because of the
trailing underscores). If any such text *does* exist, it can always
be quoted like this::
reference to `object.__method__`_
The CVS snapshot is always up to date and available at:
http://docutils.sf.net/docutils-snapshot.tgz
--
David Goodger <go...@us...> Open-source projects:
- Python Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)
- The Go Tools Project: http://gotools.sourceforge.net/
|