fix typo
[docutils.git] / docs / dev / rst / alternatives.txt
blob72758a3d9c2a379b36ff751599599444a699dbf1
1 ==================================================
2  A Record of reStructuredText Syntax Alternatives
3 ==================================================
5 :Author: David Goodger
6 :Contact: goodger@python.org
7 :Revision: $Revision$
8 :Date: $Date$
9 :Copyright: This document has been placed in the public domain.
11 The following are ideas, alternatives, and justifications that were
12 considered for reStructuredText syntax, which did not originate with
13 Setext_ or StructuredText_.  For an analysis of constructs which *did*
14 originate with StructuredText or Setext, please see `Problems With
15 StructuredText`_.  See the `reStructuredText Markup Specification`_
16 for full details of the established syntax.
18 The ideas are divided into sections:
20 * Implemented_: already done.  The issues and alternatives are
21   recorded here for posterity.
23 * `Not Implemented`_: these ideas won't be implemented.
25 * Tabled_: these ideas should be revisited in the future.
27 * `To Do`_: these ideas should be implemented.  They're just waiting
28   for a champion to resolve issues and get them done.
30 * `... Or Not To Do?`_: possible but questionable.  These probably
31   won't be implemented, but you never know.
33 .. _Setext: http://docutils.sourceforge.net/mirror/setext.html
34 .. _StructuredText:
35    http://www.zope.org/DevHome/Members/jim/StructuredTextWiki/FrontPage
36 .. _Problems with StructuredText: problems.html
37 .. _reStructuredText Markup Specification:
38    ../../ref/rst/restructuredtext.html
41 .. contents::
43 -------------
44  Implemented
45 -------------
47 Field Lists
48 ===========
50 Prior to the syntax for field lists being finalized, several
51 alternatives were proposed.
53 1. Unadorned RFC822_ everywhere::
55        Author: Me
56        Version: 1
58    Advantages: clean, precedent (RFC822-compliant).  Disadvantage:
59    ambiguous (these paragraphs are a prime example).
61    Conclusion: rejected.
63 2. Special case: use unadorned RFC822_ for the very first or very last
64    text block of a document::
66        """
67        Author: Me
68        Version: 1
70        The rest of the document...
71        """
73    Advantages: clean, precedent (RFC822-compliant).  Disadvantages:
74    special case, flat (unnested) field lists only, still ambiguous::
76        """
77        Usage: cmdname [options] arg1 arg2 ...
79        We obviously *don't* want the like above to be interpreted as a
80        field list item.  Or do we?
81        """
83    Conclusion: rejected for the general case, accepted for specific
84    contexts (PEPs, email).
86 3. Use a directive::
88        .. fields::
90           Author: Me
91           Version: 1
93    Advantages: explicit and unambiguous, RFC822-compliant.
94    Disadvantage: cumbersome.
96    Conclusion: rejected for the general case (but such a directive
97    could certainly be written).
99 4. Use Javadoc-style::
101        @Author: Me
102        @Version: 1
103        @param a: integer
105    Advantages: unambiguous, precedent, flexible.  Disadvantages:
106    non-intuitive, ugly, not RFC822-compliant.
108    Conclusion: rejected.
110 5. Use leading colons::
112        :Author: Me
113        :Version: 1
115    Advantages: unambiguous, obvious (*almost* RFC822-compliant),
116    flexible, perhaps even elegant.  Disadvantages: no precedent, not
117    quite RFC822-compliant.
119    Conclusion: accepted!
121 6. Use double colons::
123        Author:: Me
124        Version:: 1
126    Advantages: unambiguous, obvious? (*almost* RFC822-compliant),
127    flexible, similar to syntax already used for literal blocks and
128    directives.  Disadvantages: no precedent, not quite
129    RFC822-compliant, similar to syntax already used for literal blocks
130    and directives.
132    Conclusion: rejected because of the syntax similarity & conflicts.
134 Why is RFC822 compliance important?  It's a universal Internet
135 standard, and super obvious.  Also, I'd like to support the PEP format
136 (ulterior motive: get PEPs to use reStructuredText as their standard).
137 But it *would* be easy to get used to an alternative (easy even to
138 convert PEPs; probably harder to convert python-deviants ;-).
140 Unfortunately, without well-defined context (such as in email headers:
141 RFC822 only applies before any blank lines), the RFC822 format is
142 ambiguous.  It is very common in ordinary text.  To implement field
143 lists unambiguously, we need explicit syntax.
145 The following question was posed in a footnote:
147    Should "bibliographic field lists" be defined at the parser level,
148    or at the DPS transformation level?  In other words, are they
149    reStructuredText-specific, or would they also be applicable to
150    another (many/every other?) syntax?
152 The answer is that bibliographic fields are a
153 reStructuredText-specific markup convention.  Other syntaxes may
154 implement the bibliographic elements explicitly.  For example, there
155 would be no need for such a transformation for an XML-based markup
156 syntax.
158 .. _RFC822: http://www.rfc-editor.org/rfc/rfc822.txt
161 Interpreted Text "Roles"
162 ========================
164 The original purpose of interpreted text was as a mechanism for
165 descriptive markup, to describe the nature or role of a word or
166 phrase.  For example, in XML we could say "<function>len</function>"
167 to mark up "len" as a function.  It is envisaged that within Python
168 docstrings (inline documentation in Python module source files, the
169 primary market for reStructuredText) the role of a piece of
170 interpreted text can be inferred implicitly from the context of the
171 docstring within the program source.  For other applications, however,
172 the role may have to be indicated explicitly.
174 Interpreted text is enclosed in single backquotes (`).
176 1. Initially, it was proposed that an explicit role could be indicated
177    as a word or phrase within the enclosing backquotes:
179    - As a prefix, separated by a colon and whitespace::
181          `role: interpreted text`
183    - As a suffix, separated by whitespace and a colon::
185          `interpreted text :role`
187    There are problems with the initial approach:
189    - There could be ambiguity with interpreted text containing colons.
190      For example, an index entry of "Mission: Impossible" would
191      require a backslash-escaped colon.
193    - The explicit role is descriptive markup, not content, and will
194      not be visible in the processed output.  Putting it inside the
195      backquotes doesn't feel right; the *role* isn't being quoted.
197 2. Tony Ibbs suggested that the role be placed outside the
198    backquotes::
200        role:`prefix` or `suffix`:role
202    This removes the embedded-colons ambiguity, but limits the role
203    identifier to be a single word (whitespace would be illegal).
204    Since roles are not meant to be visible after processing, the lack
205    of whitespace support is not important.
207    The suggested syntax remains ambiguous with respect to ratios and
208    some writing styles.  For example, suppose there is a "signal"
209    identifier, and we write::
211        ...calculate the `signal`:noise ratio.
213    "noise" looks like a role.
215 3. As an improvement on #2, we can bracket the role with colons::
217        :role:`prefix` or `suffix`:role:
219    This syntax is similar to that of field lists, which is fine since
220    both are doing similar things: describing.
222    This is the syntax chosen for reStructuredText.
224 4. Another alternative is two colons instead of one::
226        role::`prefix` or `suffix`::role
228    But this is used for analogies ("A:B::C:D": "A is to B as C is to
229    D").
231    Both alternative #2 and #4 lack delimiters on both sides of the
232    role, making it difficult to parse (by the reader).
234 5. Some kind of bracketing could be used:
236    - Parentheses::
238          (role)`prefix` or `suffix`(role)
240    - Braces::
242          {role}`prefix` or `suffix`{role}
244    - Square brackets::
246          [role]`prefix` or `suffix`[role]
248    - Angle brackets::
250          <role>`prefix` or `suffix`<role>
252      (The overlap of \*ML tags with angle brackets would be too
253      confusing and precludes their use.)
255 Syntax #3 was chosen for reStructuredText.
258 Comments
259 ========
261 A problem with comments (actually, with all indented constructs) is
262 that they cannot be followed by an indented block -- a block quote --
263 without swallowing it up.
265 I thought that perhaps comments should be one-liners only.  But would
266 this mean that footnotes, hyperlink targets, and directives must then
267 also be one-liners?  Not a good solution.
269 Tony Ibbs suggested a "comment" directive.  I added that we could
270 limit a comment to a single text block, and that a "multi-block
271 comment" could use "comment-start" and "comment-end" directives.  This
272 would remove the indentation incompatibility.  A "comment" directive
273 automatically suggests "footnote" and (hyperlink) "target" directives
274 as well.  This could go on forever!  Bad choice.
276 Garth Kidd suggested that an "empty comment", a ".." explicit markup
277 start with nothing on the first line (except possibly whitespace) and
278 a blank line immediately following, could serve as an "unindent".  An
279 empty comment does **not** swallow up indented blocks following it,
280 so block quotes are safe.  "A tiny but practical wart."  Accepted.
283 Anonymous Hyperlinks
284 ====================
286 Alan Jaffray came up with this idea, along with the following syntax::
288     Search the `Python DOC-SIG mailing list archives`{}_.
290     .. _: http://mail.python.org/pipermail/doc-sig/
292 The idea is sound and useful.  I suggested a "double underscore"
293 syntax::
295     Search the `Python DOC-SIG mailing list archives`__.
297     .. __: http://mail.python.org/pipermail/doc-sig/
299 But perhaps single underscores are okay?  The syntax looks better, but
300 the hyperlink itself doesn't explicitly say "anonymous"::
302     Search the `Python DOC-SIG mailing list archives`_.
304     .. _: http://mail.python.org/pipermail/doc-sig/
306 Mixing anonymous and named hyperlinks becomes confusing.  The order of
307 targets is not significant for named hyperlinks, but it is for
308 anonymous hyperlinks::
310     Hyperlinks: anonymous_, named_, and another anonymous_.
312     .. _named: named
313     .. _: anonymous1
314     .. _: anonymous2
316 Without the extra syntax of double underscores, determining which
317 hyperlink references are anonymous may be difficult.  We'd have to
318 check which references don't have corresponding targets, and match
319 those up with anonymous targets.  Keeping to a simple consistent
320 ordering (as with auto-numbered footnotes) seems simplest.
322 reStructuredText will use the explicit double-underscore syntax for
323 anonymous hyperlinks.  An alternative (see `Reworking Explicit Markup
324 (Round 1)`_ below) for the somewhat awkward ".. __:" syntax is "__"::
326     An anonymous__ reference.
328     __ http://anonymous
331 Reworking Explicit Markup (Round 1)
332 ===================================
334 Alan Jaffray came up with the idea of `anonymous hyperlinks`_, added
335 to reStructuredText.  Subsequently it was asserted that hyperlinks
336 (especially anonymous hyperlinks) would play an increasingly important
337 role in reStructuredText documents, and therefore they require a
338 simpler and more concise syntax.  This prompted a review of the
339 current and proposed explicit markup syntaxes with regards to
340 improving usability.
342 1. Original syntax::
344        .. _blah:                     internal hyperlink target
345        .. _blah: http://somewhere    external hyperlink target
346        .. _blah: blahblah_           indirect hyperlink target
347        .. __:                        anonymous internal target
348        .. __: http://somewhere       anonymous external target
349        .. __: blahblah_              anonymous indirect target
350        .. [blah] http://somewhere    footnote
351        .. blah:: http://somewhere    directive
352        .. blah: http://somewhere     comment
354    .. Note::
356       The comment text was intentionally made to look like a hyperlink
357       target.
359    Origins:
361    * Except for the colon (a delimiter necessary to allow for
362      phrase-links), hyperlink target ``.. _blah:`` comes from Setext.
363    * Comment syntax from Setext.
364    * Footnote syntax from StructuredText ("named links").
365    * Directives and anonymous hyperlinks original to reStructuredText.
367    Advantages:
369    + Consistent explicit markup indicator: "..".
370    + Consistent hyperlink syntax: ".. _" & ":".
372    Disadvantages:
374    - Anonymous target markup is awkward: ".. __:".
375    - The explicit markup indicator ("..") is excessively overloaded?
376    - Comment text is limited (can't look like a footnote, hyperlink,
377      or directive).  But this is probably not important.
379 2. Alan Jaffray's proposed syntax #1::
381        __ _blah                      internal hyperlink target
382        __ blah: http://somewhere     external hyperlink target
383        __ blah: blahblah_            indirect hyperlink target
384        __                            anonymous internal target
385        __ http://somewhere           anonymous external target
386        __ blahblah_                  anonymous indirect target
387        __ [blah] http://somewhere    footnote
388        .. blah:: http://somewhere    directive
389        .. blah: http://somewhere     comment
391    The hyperlink-connoted underscores have become first-level syntax.
393    Advantages:
395    + Anonymous targets are simpler.
396    + All hyperlink targets are one character shorter.
398    Disadvantages:
400    - Inconsistent internal hyperlink targets.  Unlike all other named
401      hyperlink targets, there's no colon.  There's an extra leading
402      underscore, but we can't drop it because without it, "blah" looks
403      like a relative URI.  Unless we restore the colon::
405          __ blah:                      internal hyperlink target
407    - Obtrusive markup?
409 3. Alan Jaffray's proposed syntax #2::
411        .. _blah                      internal hyperlink target
412        .. blah: http://somewhere     external hyperlink target
413        .. blah: blahblah_            indirect hyperlink target
414        ..                            anonymous internal target
415        .. http://somewhere           anonymous external target
416        .. blahblah_                  anonymous indirect target
417        .. [blah] http://somewhere    footnote
418        !! blah: http://somewhere     directive
419        ## blah: http://somewhere     comment
421    Leading underscores have been (almost) replaced by "..", while
422    comments and directives have gained their own syntax.
424    Advantages:
426    + Anonymous hyperlinks are simpler.
427    + Unique syntax for comments.  Connotation of "comment" from
428      some programming languages (including our favorite).
429    + Unique syntax for directives.  Connotation of "action!".
431    Disadvantages:
433    - Inconsistent internal hyperlink targets.  Again, unlike all other
434      named hyperlink targets, there's no colon.  There's a leading
435      underscore, matching the trailing underscores of references,
436      which no other hyperlink targets have.  We can't drop that one
437      leading underscore though: without it, "blah" looks like a
438      relative URI.  Again, unless we restore the colon::
440          .. blah:                      internal hyperlink target
442    - All (except for internal) hyperlink targets lack their leading
443      underscores, losing the "hyperlink" connotation.
445    - Obtrusive syntax for comments.  Alternatives::
447          ;; blah: http://somewhere
448             (also comment syntax in Lisp & others)
449          ,, blah: http://somewhere
450             ("comma comma": sounds like "comment"!)
452    - Iffy syntax for directives.  Alternatives?
454 4. Tony Ibbs' proposed syntax::
456        .. _blah:                     internal hyperlink target
457        .. _blah: http://somewhere    external hyperlink target
458        .. _blah: blahblah_           indirect hyperlink target
459        ..                            anonymous internal target
460        .. http://somewhere           anonymous external target
461        .. blahblah_                  anonymous indirect target
462        .. [blah] http://somewhere    footnote
463        .. blah:: http://somewhere    directive
464        .. blah: http://somewhere     comment
466    This is the same as the current syntax, except for anonymous
467    targets which drop their "__: ".
469    Advantage:
471    + Anonymous targets are simpler.
473    Disadvantages:
475    - Anonymous targets lack their leading underscores, losing the
476      "hyperlink" connotation.
477    - Anonymous targets are almost indistinguishable from comments.
478      (Better to know "up front".)
480 5. David Goodger's proposed syntax: Perhaps going back to one of
481    Alan's earlier suggestions might be the best solution.  How about
482    simply adding "__ " as a synonym for ".. __: " in the original
483    syntax?  These would become equivalent::
485        .. __:                        anonymous internal target
486        .. __: http://somewhere       anonymous external target
487        .. __: blahblah_              anonymous indirect target
489        __                            anonymous internal target
490        __ http://somewhere           anonymous external target
491        __ blahblah_                  anonymous indirect target
493 Alternative 5 has been adopted.
496 Backquotes in Phrase-Links
497 ==========================
499 [From a 2001-06-05 Doc-SIG post in reply to questions from Doug
500 Hellmann.]
502 The first draft of the spec, posted to the Doc-SIG in November 2000,
503 used square brackets for phrase-links.  I changed my mind because:
505 1. In the first draft, I had already decided on single-backquotes for
506    inline literal text.
508 2. However, I wanted to minimize the necessity for backslash escapes,
509    for example when quoting Python repr-equivalent syntax that uses
510    backquotes.
512 3. The processing of identifiers (function/method/attribute/module
513    etc. names) into hyperlinks is a useful feature.  PyDoc recognizes
514    identifiers heuristically, but it doesn't take much imagination to
515    come up with counter-examples where PyDoc's heuristics would result
516    in embarassing failure.  I wanted to do it deterministically, and
517    that called for syntax.  I called this construct "interpreted
518    text".
520 4. Leveraging off the ``*emphasis*/**strong**`` syntax, lead to the
521    idea of using double-backquotes as syntax.
523 5. I worked out some rules for inline markup recognition.
525 6. In combination with #5, double backquotes lent themselves to inline
526    literals, neatly satisfying #2, minimizing backslash escapes.  In
527    fact, the spec says that no interpretation of any kind is done
528    within double-backquote inline literal text; backslashes do *no*
529    escaping within literal text.
531 7. Single backquotes are then freed up for interpreted text.
533 8. I already had square brackets required for footnote references.
535 9. Since interpreted text will typically turn into hyperlinks, it was
536    a natural fit to use backquotes as the phrase-quoting syntax for
537    trailing-underscore hyperlinks.
539 The original inspiration for the trailing underscore hyperlink syntax
540 was Setext.  But for phrases Setext used a very cumbersome
541 ``underscores_between_words_like_this_`` syntax.
543 The underscores can be viewed as if they were right-pointing arrows:
544 ``-->``.  So ``hyperlink_`` points away from the reference, and
545 ``.. _hyperlink:`` points toward the target.
548 Substitution Mechanism
549 ======================
551 Substitutions arose out of a Doc-SIG thread begun on 2001-10-28 by
552 Alan Jaffray, "reStructuredText inline markup".  It reminded me of a
553 missing piece of the reStructuredText puzzle, first referred to in my
554 contribution to "Documentation markup & processing / PEPs" (Doc-SIG
555 2001-06-21).
557 Substitutions allow the power and flexibility of directives to be
558 shared by inline text.  They are a way to allow arbitrarily complex
559 inline objects, while keeping the details out of the flow of text.
560 They are the equivalent of SGML/XML's named entities.  For example, an
561 inline image (using reference syntax alternative 4d (vertical bars)
562 and definition alternative 3, the alternatives chosen for inclusion in
563 the spec)::
565     The |biohazard| symbol must be used on containers used to dispose
566     of medical waste.
568     .. |biohazard| image:: biohazard.png
569        [height=20 width=20]
571 The ``|biohazard|`` substitution reference will be replaced in-line by
572 whatever the ``.. |biohazard|`` substitution definition generates (in
573 this case, an image).  A substitution definition contains the
574 substitution text bracketed with vertical bars, followed by a an
575 embedded inline-compatible directive, such as "image".  A transform is
576 required to complete the substitution.
578 Syntax alternatives for the reference:
580 1. Use the existing interpreted text syntax, with a predefined role
581    such as "sub"::
583        The `biohazard`:sub: symbol...
585    Advantages: existing syntax, explicit.  Disadvantages: verbose,
586    obtrusive.
588 2. Use a variant of the interpreted text syntax, with a new suffix
589    akin to the underscore in phrase-link references::
591        (a) `name`@
592        (b) `name`#
593        (c) `name`&
594        (d) `name`/
595        (e) `name`<
596        (f) `name`::
597        (g) `name`:
600    Due to incompatibility with other constructs and ordinary text
601    usage, (f) and (g) are not possible.
603 3. Use interpreted text syntax with a fixed internal format::
605        (a) `:name:`
606        (b) `name:`
607        (c) `name::`
608        (d) `::name::`
609        (e) `%name%`
610        (f) `#name#`
611        (g) `/name/`
612        (h) `&name&`
613        (i) `|name|`
614        (j) `[name]`
615        (k) `<name>`
616        (l) `&name;`
617        (m) `'name'`
619    To avoid ML confusion (k) and (l) are definitely out.  Square
620    brackets (j) won't work in the target (the substitution definition
621    would be indistinguishable from a footnote).
623    The ```/name/``` syntax (g) is reminiscent of "s/find/sub"
624    substitution syntax in ed-like languages.  However, it may have a
625    misleading association with regexps, and looks like an absolute
626    POSIX path.  (i) is visually equivalent and lacking the
627    connotations.
629    A disadvantage of all of these is that they limit interpreted text,
630    albeit only slightly.
632 4. Use specialized syntax, something new::
634        (a) #name#
635        (b) @name@
636        (c) /name/
637        (d) |name|
638        (e) <<name>>
639        (f) //name//
640        (g) ||name||
641        (h) ^name^
642        (i) [[name]]
643        (j) ~name~
644        (k) !name!
645        (l) =name=
646        (m) ?name?
647        (n) >name<
649    "#" (a) and "@" (b) are obtrusive.  "/" (c) without backquotes
650    looks just like a POSIX path; it is likely for such usage to appear
651    in text.
653    "|" (d) and "^" (h) are feasible.
655 5. Redefine the trailing underscore syntax.  See definition syntax
656    alternative 4, below.
658 Syntax alternatives for the definition:
660 1. Use the existing directive syntax, with a predefined directive such
661    as "sub".  It contains a further embedded directive resolving to an
662    inline-compatible object::
664        .. sub:: biohazard
665           .. image:: biohazard.png
666              [height=20 width=20]
668        .. sub:: parrot
669           That bird wouldn't *voom* if you put 10,000,000 volts
670           through it!
672    The advantages and disadvantages are the same as in inline
673    alternative 1.
675 2. Use syntax as in #1, but with an embedded directivecompressed::
677        .. sub:: biohazard image:: biohazard.png
678           [height=20 width=20]
680    This is a bit better than alternative 1, but still too much.
682 3. Use a variant of directive syntax, incorporating the substitution
683    text, obviating the need for a special "sub" directive name.  If we
684    assume reference alternative 4d (vertical bars), the matching
685    definition would look like this::
687        .. |biohazard| image:: biohazard.png
688           [height=20 width=20]
690 4. (Suggested by Alan Jaffray on Doc-SIG from 2001-11-06.)
692    Instead of adding new syntax, redefine the trailing underscore
693    syntax to mean "substitution reference" instead of "hyperlink
694    reference".  Alan's example::
696        I had lunch with Jonathan_ today.  We talked about Zope_.
698        .. _Jonathan: lj [user=jhl]
699        .. _Zope: http://www.zope.org/
701    A problem with the proposed syntax is that URIs which look like
702    simple reference names (alphanum plus ".", "-", "_") would be
703    indistinguishable from substitution directive names.  A more
704    consistent syntax would be::
706        I had lunch with Jonathan_ today.  We talked about Zope_.
708        .. _Jonathan: lj:: user=jhl
709        .. _Zope: http://www.zope.org/
711    (``::`` after ``.. _Jonathan: lj``.)
713    The "Zope" target is a simple external hyperlink, but the
714    "Jonathan" target contains a directive.  Alan proposed is that the
715    reference text be replaced by whatever the referenced directive
716    (the "directive target") produces.  A directive reference becomes a
717    hyperlink reference if the contents of the directive target resolve
718    to a hyperlink.  If the directive target resolves to an icon, the
719    reference is replaced by an inline icon.  If the directive target
720    resolves to a hyperlink, the directive reference becomes a
721    hyperlink reference.
723    This seems too indirect and complicated for easy comprehension.
725    The reference in the text will sometimes become a link, sometimes
726    not.  Sometimes the reference text will remain, sometimes not.  We
727    don't know *at the reference*::
729        This is a `hyperlink reference`_; its text will remain.
730        This is an `inline icon`_; its text will disappear.
732    That's a problem.
734 The syntax that has been incorporated into the spec and parser is
735 reference alternative 4d with definition alternative 3::
737     The |biohazard| symbol...
739     .. |biohazard| image:: biohazard.png
740        [height=20 width=20]
742 We can also combine substitution references with hyperlink references,
743 by appending a "_" (named hyperlink reference) or "__" (anonymous
744 hyperlink reference) suffix to the substitution reference.  This
745 allows us to click on an image-link::
747     The |biohazard|_ symbol...
749     .. |biohazard| image:: biohazard.png
750        [height=20 width=20]
751     .. _biohazard: http://www.cdc.gov/
753 There have been several suggestions for the naming of these
754 constructs, originally called "substitution references" and
755 "substitutions".
757 1. Candidate names for the reference construct:
759    (a) substitution reference
760    (b) tagging reference
761    (c) inline directive reference
762    (d) directive reference
763    (e) indirect inline directive reference
764    (f) inline directive placeholder
765    (g) inline directive insertion reference
766    (h) directive insertion reference
767    (i) insertion reference
768    (j) directive macro reference
769    (k) macro reference
770    (l) substitution directive reference
772 2. Candidate names for the definition construct:
774    (a) substitution
775    (b) substitution directive
776    (c) tag
777    (d) tagged directive
778    (e) directive target
779    (f) inline directive
780    (g) inline directive definition
781    (h) referenced directive
782    (i) indirect directive
783    (j) indirect directive definition
784    (k) directive definition
785    (l) indirect inline directive
786    (m) named directive definition
787    (n) inline directive insertion definition
788    (o) directive insertion definition
789    (p) insertion definition
790    (q) insertion directive
791    (r) substitution definition
792    (s) directive macro definition
793    (t) macro definition
794    (u) substitution directive definition
795    (v) substitution definition
797 "Inline directive reference" (1c) seems to be an appropriate term at
798 first, but the term "inline" is redundant in the case of the
799 reference.  Its counterpart "inline directive definition" (2g) is
800 awkward, because the directive definition itself is not inline.
802 "Directive reference" (1d) and "directive definition" (2k) are too
803 vague.  "Directive definition" could be used to refer to any
804 directive, not just those used for inline substitutions.
806 One meaning of the term "macro" (1k, 2s, 2t) is too
807 programming-language-specific.  Also, macros are typically simple text
808 substitution mechanisms: the text is substituted first and evaluated
809 later.  reStructuredText substitution definitions are evaluated in
810 place at parse time and substituted afterwards.
812 "Insertion" (1h, 1i, 2n-2q) is almost right, but it implies that
813 something new is getting added rather than one construct being
814 replaced by another.
816 Which brings us back to "substitution".  The overall best names are
817 "substitution reference" (1a) and "substitution definition" (2v).  A
818 long way to go to add one word!
821 Inline External Targets
822 =======================
824 Currently reStructuredText has two hyperlink syntax variations:
826 * Named hyperlinks::
828       This is a named reference_ of one word ("reference").  Here is
829       a `phrase reference`_.  Phrase references may even cross `line
830       boundaries`_.
832       .. _reference: http://www.example.org/reference/
833       .. _phrase reference: http://www.example.org/phrase_reference/
834       .. _line boundaries: http://www.example.org/line_boundaries/
836   + Advantages:
838     - The plaintext is readable.
839     - Each target may be reused multiple times (e.g., just write
840       ``"reference_"`` again).
841     - No syncronized ordering of references and targets is necessary.
843   + Disadvantages:
845     - The reference text must be repeated as target names; could lead
846       to mistakes.
847     - The target URLs may be located far from the references, and hard
848       to find in the plaintext.
850 * Anonymous hyperlinks (in current reStructuredText)::
852       This is an anonymous reference__.  Here is an anonymous
853       `phrase reference`__.  Phrase references may even cross `line
854       boundaries`__.
856       __ http://www.example.org/reference/
857       __ http://www.example.org/phrase_reference/
858       __ http://www.example.org/line_boundaries/
860   + Advantages:
862     - The plaintext is readable.
863     - The reference text does not have to be repeated.
865   + Disadvantages:
867     - References and targets must be kept in sync.
868     - Targets cannot be reused.
869     - The target URLs may be located far from the references.
871 For comparison and historical background, StructuredText also has two
872 syntaxes for hyperlinks:
874 * First, ``"reference text":URL``::
876       This is a "reference":http://www.example.org/reference/
877       of one word ("reference").  Here is a "phrase
878       reference":http://www.example.org/phrase_reference/.
880 * Second, ``"reference text", http://example.com/absolute_URL``::
882       This is a "reference", http://www.example.org/reference/
883       of one word ("reference").  Here is a "phrase reference",
884       http://www.example.org/phrase_reference/.
886 Both syntaxes share advantages and disadvantages:
888 + Advantages:
890   - The target is specified immediately adjacent to the reference.
892 + Disadvantages:
894   - Poor plaintext readability.
895   - Targets cannot be reused.
896   - Both syntaxes use double quotes, common in ordinary text.
897   - In the first syntax, the URL and the last word are stuck
898     together, exacerbating the line wrap problem.
899   - The second syntax is too magical; text could easily be written
900     that way by accident (although only absolute URLs are recognized
901     here, perhaps because of the potential for ambiguity).
903 A new type of "inline external hyperlink" has been proposed.
905 1. On 2002-06-28, Simon Budig proposed__ a new syntax for
906    reStructuredText hyperlinks::
908        This is a reference_(http://www.example.org/reference/) of one
909        word ("reference").  Here is a `phrase
910        reference`_(http://www.example.org/phrase_reference/).  Are
911        these examples, (single-underscore), named?  If so, `anonymous
912        references`__(http://www.example.org/anonymous/) using two
913        underscores would probably be preferable.
915    __ http://mail.python.org/pipermail/doc-sig/2002-June/002648.html
917    The syntax, advantages, and disadvantages are similar to those of
918    StructuredText.
920    + Advantages:
922      - The target is specified immediately adjacent to the reference.
924    + Disadvantages:
926      - Poor plaintext readability.
927      - Targets cannot be reused (unless named, but the semantics are
928        unclear).
930    + Problems:
932      - The ``"`ref`_(URL)"`` syntax forces the last word of the
933        reference text to be joined to the URL, making a potentially
934        very long word that can't be wrapped (URLs can be very long).
935        The reference and the URL should be separate.  This is a
936        symptom of the following point:
938      - The syntax produces a single compound construct made up of two
939        equally important parts, *with syntax in the middle*, *between*
940        the reference and the target.  This is unprecedented in
941        reStructuredText.
943      - The "inline hyperlink" text is *not* a named reference (there's
944        no lookup by name), so it shouldn't look like one.
946      - According to the IETF standards RFC 2396 and RFC 2732,
947        parentheses are legal URI characters and curly braces are legal
948        email characters, making their use prohibitively difficult.
950      - The named/anonymous semantics are unclear.
952 2. After an analysis__ of the syntax of (1) above, we came up with the
953    following compromise syntax::
955        This is an anonymous reference__
956        __<http://www.example.org/reference/> of one word
957        ("reference").  Here is a `phrase reference`__
958        __<http://www.example.org/phrase_reference/>.  `Named
959        references`_ _<http://www.example.org/anonymous/> use single
960        underscores.
962    __ http://mail.python.org/pipermail/doc-sig/2002-July/002670.html
964    The syntax builds on that of the existing "inline internal
965    targets": ``an _`inline internal target`.``
967    + Advantages:
969      - The target is specified immediately adjacent to the reference,
970        improving maintainability:
972        - References and targets are easily kept in sync.
973        - The reference text does not have to be repeated.
975      - The construct is executed in two parts: references identical to
976        existing references, and targets that are new but not too big a
977        stretch from current syntax.
979      - There's overwhelming precedent for quoting URLs with angle
980        brackets [#]_.
982    + Disadvantages:
984      - Poor plaintext readability.
985      - Lots of "line noise".
986      - Targets cannot be reused (unless named; see below).
988    To alleviate the readability issue slightly, we could allow the
989    target to appear later, such as after the end of the sentence::
991        This is a named reference__ of one word ("reference").
992        __<http://www.example.org/reference/>  Here is a `phrase
993        reference`__.  __<http://www.example.org/phrase_reference/>
995    Problem: this could only work for one reference at a time
996    (reference/target pairs must be proximate [refA trgA refB trgB],
997    not interleaved [refA refB trgA trgB] or nested [refA refB trgB
998    trgA]).  This variation is too problematic; references and inline
999    external targets will have to be kept imediately adjacent (see (3)
1000    below).
1002    The ``"reference__ __<target>"`` syntax is actually for "anonymous
1003    inline external targets", emphasized by the double underscores.  It
1004    follows that single trailing and leading underscores would lead to
1005    *implicitly named* inline external targets.  This would allow the
1006    reuse of targets by name.  So after ``"reference_ _<target>"``,
1007    another ``"reference_"`` would point to the same target.
1009    .. [#]
1010       From RFC 2396 (URI syntax):
1012           The angle-bracket "<" and ">" and double-quote (")
1013           characters are excluded [from URIs] because they are often
1014           used as the delimiters around URI in text documents and
1015           protocol fields.
1017           Using <> angle brackets around each URI is especially
1018           recommended as a delimiting style for URI that contain
1019           whitespace.
1021       From RFC 822 (email headers):
1023           Angle brackets ("<" and ">") are generally used to indicate
1024           the presence of a one machine-usable reference (e.g.,
1025           delimiting mailboxes), possibly including source-routing to
1026           the machine.
1028 3. If it is best for references and inline external targets to be
1029    immediately adjacent, then they might as well be integrated.
1030    Here's an alternative syntax embedding the target URL in the
1031    reference::
1033        This is an anonymous `reference <http://www.example.org
1034        /reference/>`__ of one word ("reference").  Here is a `phrase
1035        reference <http://www.example.org/phrase_reference/>`__.
1037    Advantages and disadvantages are similar to those in (2).
1038    Readability is still an issue, but the syntax is a bit less
1039    heavyweight (reduced line noise).  Backquotes are required, even
1040    for one-word references; the target URL is included within the
1041    reference text, forcing a phrase context.
1043    We'll call this variant "embedded URIs".
1045    Problem: how to refer to a title like "HTML Anchors: <a>" (which
1046    ends with an HTML/SGML/XML tag)?  We could either require more
1047    syntax on the target (like ``"`reference text
1048    __<http://example.com/>`__"``), or require the odd conflicting
1049    title to be escaped (like ``"`HTML Anchors: \<a>`__"``).  The
1050    latter seems preferable, and not too onerous.
1052    Similarly to (2) above, a single trailing underscore would convert
1053    the reference & inline external target from anonymous to implicitly
1054    named, allowing reuse of targets by name.
1056    I think this is the least objectionable of the syntax alternatives.
1058 Other syntax variations have been proposed (by Brett Cannon and Benja
1059 Fallenstein)::
1061     `phrase reference`->http://www.example.com
1063     `phrase reference`@http://www.example.com
1065     `phrase reference`__ ->http://www.example.com
1067     `phrase reference` [-> http://www.example.com]
1069     `phrase reference`__ [-> http://www.example.com]
1071     `phrase reference` <http://www.example.com>_
1073 None of these variations are clearly superior to #3 above.  Some have
1074 problems that exclude their use.
1076 With any kind of inline external target syntax it comes down to the
1077 conflict between maintainability and plaintext readability.  I don't
1078 see a major problem with reStructuredText's maintainability, and I
1079 don't want to sacrifice plaintext readability to "improve" it.
1081 The proponents of inline external targets want them for easily
1082 maintainable web pages.  The arguments go something like this:
1084 - Named hyperlinks are difficult to maintain because the reference
1085   text is duplicated as the target name.
1087   To which I said, "So use anonymous hyperlinks."
1089 - Anonymous hyperlinks are difficult to maintain becuase the
1090   references and targets have to be kept in sync.
1092   "So keep the targets close to the references, grouped after each
1093   paragraph.  Maintenance is trivial."
1095 - But targets grouped after paragraphs break the flow of text.
1097   "Surely less than URLs embedded in the text!  And if the intent is
1098   to produce web pages, not readable plaintext, then who cares about
1099   the flow of text?"
1101 Many participants have voiced their objections to the proposed syntax:
1103     Garth Kidd: "I strongly prefer the current way of doing it.
1104     Inline is spectactularly messy, IMHO."
1106     Tony Ibbs: "I vehemently agree... that the inline alternatives
1107     being suggested look messy - there are/were good reasons they've
1108     been taken out...  I don't believe I would gain from the new
1109     syntaxes."
1111     Paul Moore: "I agree as well.  The proposed syntax is far too
1112     punctuation-heavy, and any of the alternatives discussed are
1113     ambiguous or too subtle."
1115 Others have voiced their support:
1117     fantasai: "I agree with Simon.  In many cases, though certainly
1118     not in all, I find parenthesizing the url in plain text flows
1119     better than relegating it to a footnote."
1121     Ken Manheimer: "I'd like to weigh in requesting some kind of easy,
1122     direct inline reference link."
1124 (Interesting that those *against* the proposal have been using
1125 reStructuredText for a while, and those *for* the proposal are either
1126 new to the list ["fantasai", background unknown] or longtime
1127 StructuredText users [Ken Manheimer].)
1129 I was initially ambivalent/against the proposed "inline external
1130 targets".  I value reStructuredText's readability very highly, and
1131 although the proposed syntax offers convenience, I don't know if the
1132 convenience is worth the cost in ugliness.  Does the proposed syntax
1133 compromise readability too much, or should the choice be left up to
1134 the author?  Perhaps if the syntax is *allowed* but its use strongly
1135 *discouraged*, for aesthetic/readability reasons?
1137 After a great deal of thought and much input from users, I've decided
1138 that there are reasonable use cases for this construct.  The
1139 documentation should strongly caution against its use in most
1140 situations, recommending independent block-level targets instead.
1141 Syntax #3 above ("embedded URIs") will be used.
1144 Doctree Representation of Transitions
1145 =====================================
1147 (Although not reStructuredText-specific, this section fits best in
1148 this document.)
1150 Having added the "horizontal rule" construct to the `reStructuredText
1151 Markup Specification`_, a decision had to be made as to how to reflect
1152 the construct in the implementation of the document tree.  Given this
1153 source::
1155     Document
1156     ========
1158     Paragraph 1
1160     --------
1162     Paragraph 2
1164 The horizontal rule indicates a "transition" (in prose terms) or the
1165 start of a new "division".  Before implementation, the parsed document
1166 tree would be::
1168     <document>
1169         <section names="document">
1170             <title>
1171                 Document
1172             <paragraph>
1173                 Paragraph 1
1174             --------               <--- error here
1175             <paragraph>
1176                 Paragraph 2
1178 There are several possibilities for the implementation:
1180 1. Implement horizontal rules as "divisions" or segments.  A
1181    "division" is a title-less, non-hierarchical section.  The first
1182    try at an implementation looked like this::
1184        <document>
1185            <section names="document">
1186                <title>
1187                    Document
1188                <paragraph>
1189                    Paragraph 1
1190                <division>
1191                    <paragraph>
1192                        Paragraph 2
1194    But the two paragraphs are really at the same level; they shouldn't
1195    appear to be at different levels.  There's really an invisible
1196    "first division".  The horizontal rule splits the document body
1197    into two segments, which should be treated uniformly.
1199 2. Treating "divisions" uniformly brings us to the second
1200    possibility::
1202        <document>
1203            <section names="document">
1204                <title>
1205                    Document
1206                <division>
1207                    <paragraph>
1208                        Paragraph 1
1209                <division>
1210                    <paragraph>
1211                        Paragraph 2
1213    With this change, documents and sections will directly contain
1214    divisions and sections, but not body elements.  Only divisions will
1215    directly contain body elements.  Even without a horizontal rule
1216    anywhere, the body elements of a document or section would be
1217    contained within a division element.  This makes the document tree
1218    deeper.  This is similar to the way HTML_ treats document contents:
1219    grouped within a ``<body>`` element.
1221 3. Implement them as "transitions", empty elements::
1223        <document>
1224            <section names="document">
1225                <title>
1226                    Document
1227                <paragraph>
1228                    Paragraph 1
1229                <transition>
1230                <paragraph>
1231                    Paragraph 2
1233    A transition would be a "point element", not containing anything,
1234    only identifying a point within the document structure.  This keeps
1235    the document tree flatter, but the idea of a "point element" like
1236    "transition" smells bad.  A transition isn't a thing itself, it's
1237    the space between two divisions.  However, transitions are a
1238    practical solution.
1240 Solution 3 was chosen for incorporation into the document tree model.
1242 .. _HTML: http://www.w3.org/MarkUp/
1245 Syntax for Line Blocks
1246 ======================
1248 * An early idea: How about a literal-block-like prefix, perhaps
1249   "``;;``"?  (It is, after all, a *semi-literal* literal block, no?)
1250   Example::
1252       Take it away, Eric the Orchestra Leader!  ;;
1254           A one, two, a one two three four
1256           Half a bee, philosophically,
1257           must, *ipso facto*, half not be.
1258           But half the bee has got to be,
1259           *vis a vis* its entity.  D'you see?
1261           But can a bee be said to be
1262           or not to be an entire bee,
1263           when half the bee is not a bee,
1264           due to some ancient injury?
1266           Singing...
1268   Kinda lame.
1270 * Another idea: in an ordinary paragraph, if the first line ends with
1271   a backslash (escaping the newline), interpret the entire paragraph
1272   as a verse block?  For example::
1274       Add just one backslash\
1275       And this paragraph becomes
1276       An awful haiku
1278   (Awful, and arguably invalid, since in Japanese the word "haiku"
1279   contains three syllables not two.)
1281   This idea was superceded by the rules for escaped whitespace, useful
1282   for `character-level inline markup`_.
1284 * In a `2004-02-22 docutils-develop message`__, Jarno Elonen proposed
1285   a "plain list" syntax (and also provided a patch)::
1287        | John Doe
1288        | President, SuperDuper Corp.
1289        | jdoe@example.org
1291   __ http://thread.gmane.org/gmane.text.docutils.devel/1187
1293   This syntax is very natural.  However, these "plain lists" seem very
1294   similar to line blocks, and I see so little intrinsic "list-ness"
1295   that I'm loathe to add a new object.  I used the term "blurbs" to
1296   remove the "list" connotation from the originally proposed name.
1297   Perhaps line blocks could be refined to add the two properties they
1298   currently lack:
1300   A) long lines wrap nicely
1301   B) HTML output doesn't look like program code in non-CSS web
1302      browsers
1304   (A) is an issue of all 3 aspects of Docutils: syntax (construct
1305   behaviour), internal representation, and output.  (B) is partly an
1306   issue of internal representation but mostly of output.
1308 ReStructuredText will redefine line blocks with the "|"-quoting
1309 syntax.  The following is my current thinking.
1312 Syntax
1313 ------
1315 Perhaps line block syntax like this would do::
1317      | M6: James Bond
1318      | MIB: Mr. J.
1319      | IMF: not decided yet, but probably one of the following:
1320      |   Ethan Hunt
1321      |   Jim Phelps
1322      |   Claire Phelps
1323      | CIA: Lea Leiter
1325 Note that the "nested" list does not have nested syntax (the "|" are
1326 not further indented); the leading whitespace would still be
1327 significant somehow (more below).  As for long lines in the input,
1328 this could suffice::
1330      | John Doe
1331      | Founder, President, Chief Executive Officer, Cook, Bottle
1332        Washer, and All-Round Great Guy
1333      | SuperDuper Corp.
1334      | jdoe@example.org
1336 The lack of "|" on the third line indicates that it's a continuation
1337 of the second line, wrapped.
1339 I don't see much point in allowing arbitrary nested content.  Multiple
1340 paragraphs or bullet lists inside a "blurb" doesn't make sense to me.
1341 Simple nested line blocks should suffice.
1344 Internal Representation
1345 -----------------------
1347 Line blocks are currently represented as text blobs as follows::
1349      <!ELEMENT line_block %text.model;>
1350      <!ATTLIST line_block
1351          %basic.atts;
1352          %fixedspace.att;>
1354 Instead, we could represent each line by a separate element::
1356      <!ELEMENT line_block (line+)>
1357      <!ATTLIST line_block %basic.atts;>
1359      <!ELEMENT line %text.model;>
1360      <!ATTLIST line %basic.atts;>
1362 We'd keep the significance of the leading whitespace of each line
1363 either by converting it to non-breaking spaces at output, or with a
1364 per-line margin.  Non-breaking spaces are simpler (for HTML, anyway)
1365 but kludgey, and wouldn't support indented long lines that wrap.  But
1366 should inter-word whitespace (i.e., not leading whitespace) be
1367 preserved?  Currently it is preserved in line blocks.
1369 Representing a more complex line block may be tricky::
1371      | But can a bee be said to be
1372      |     or not to be an entire bee,
1373      |         when half the bee is not a bee,
1374      |             due to some ancient injury?
1376 Perhaps the representation could allow for nested line blocks::
1378      <!ELEMENT line_block (line | line_block)+>
1380 With this model, leading whitespace would no longer be significant.
1381 Instead, left margins are implied by the nesting.  The example above
1382 could be represented as follows::
1384      <line_block>
1385          <line>
1386              But can a bee be said to be
1387          <line_block>
1388              <line>
1389                   or not to be an entire bee,
1390              <line_block>
1391                  <line>
1392                      when half the bee is not a bee,
1393                  <line_block>
1394                      <line>
1395                          due to some ancient injury?
1397 I wasn't sure what to do about even more complex line blocks::
1399      |     Indented
1400      | Not indented
1401      |   Indented a bit
1402      |     A bit more
1403      |  Only one space
1405 How should that be parsed and nested?  Should the first line have
1406 the same nesting level (== indentation in the output) as the fourth
1407 line, or the same as the last line?  Mark Nodine suggested that such
1408 line blocks be parsed similarly to complexly-nested block quotes,
1409 which seems reasonable.  In the example above, this would result in
1410 the nesting of first line matching the last line's nesting.  In
1411 other words, the nesting would be relative to neighboring lines
1412 only.
1415 Output
1416 ------
1418 In HTML, line blocks are currently output as "<pre>" blocks, which
1419 gives us significant whitespace and line breaks, but doesn't allow
1420 long lines to wrap and causes monospaced output without stylesheets.
1421 Instead, we could output "<div>" elements parallelling the
1422 representation above, where each nested <div class="line_block"> would
1423 have an increased left margin (specified in the stylesheet).
1425 Jarno suggested the following HTML output::
1427     <div class="line_block">
1428        <span class="line">First, top level line</span><br class="hidden"/>
1429        <div class="line_block"><span class="hidden">&nbsp;</span>
1430           <span class="line">Second, once nested</span><br class="hidden"/>
1431           <span class="line">Third, once nested</span><br class="hidden"/>
1432           ...
1433        </div>
1434        ...
1435     </div>
1437 The ``<br class="hidden" />`` and ``<span
1438 class="hidden">&nbsp;</span>`` are meant to support non-CSS and
1439 non-graphical browsers.  I understand the case for "br", but I'm not
1440 so sure about hidden "&nbsp;".  I question how much effort should be
1441 put toward supporting non-graphical and especially non-CSS browsers,
1442 at least for html4css1.py output.
1444 Should the lines themselves be ``<span>`` or ``<div>``?  I don't like
1445 mixing inline and block-level elements.
1448 Implementation Plan
1449 -------------------
1451 We'll leave the old implementation in place (via the "line-block"
1452 directive only) until all Writers have been updated to support the new
1453 syntax & implementation.  The "line-block" directive can then be
1454 updated to use the new internal representation, and its documentation
1455 will be updated to recommend the new syntax.
1458 List-Driven Tables
1459 ==================
1461 The original idea came from Dylan Jay:
1463     ... to use a two level bulleted list with something to
1464     indicate it should be rendered as a table ...
1466 It's an interesting idea.  It could be implemented in as a directive
1467 which transforms a uniform two-level list into a table.  Using a
1468 directive would allow the author to explicitly set the table's
1469 orientation (by column or by row), the presence of row headers, etc.
1471 Alternatives:
1473 1. (Implemented in Docutils 0.3.8).
1475    Bullet-list-tables might look like this::
1477        .. list-table::
1479           * - Treat
1480             - Quantity
1481             - Description
1482           * - Albatross!
1483             - 299
1484             - On a stick!
1485           * - Crunchy Frog!
1486             - 1499
1487             - If we took the bones out, it wouldn't be crunchy,
1488               now would it?
1489           * - Gannet Ripple!
1490             - 199
1491             - On a stick!
1493    This list must be written in two levels.  This wouldn't work::
1495        .. list-table::
1497           * Treat
1498           * Albatross!
1499           * Gannet!
1500           * Crunchy Frog!
1502           * Quantity
1503           * 299
1504           * 199
1505           * 1499
1507           * Description
1508           * On a stick!
1509           * On a stick!
1510           * If we took the bones out...
1512    The above is a single list of 12 items.  The blank lines are not
1513    significant to the markup.  We'd have to explicitly specify how
1514    many columns or rows to use, which isn't a good idea.
1516 2. Beni Cherniavsky suggested a field list alternative.  It could look
1517    like this::
1519        .. field-list-table::
1520           :headrows: 1
1522           - :treat: Treat
1523             :quantity: Quantity
1524             :descr: Description
1526           - :treat: Albatross!
1527             :quantity: 299
1528             :descr: On a stick!
1530           - :treat: Crunchy Frog!
1531             :quantity: 1499
1532             :descr: If we took the bones out, it wouldn't be
1533                     crunchy, now would it?
1535    Column order is determined from the order of fields in the first
1536    row.  Field order in all other rows is ignored.  As a side-effect,
1537    this allows trivial re-arrangement of columns.  By using named
1538    fields, it becomes possible to omit fields in some rows without
1539    losing track of things, which is important for spans.
1541 3. An alternative to two-level bullet lists would be to use enumerated
1542    lists for the table cells::
1544        .. list-table::
1546            * 1. Treat
1547              2. Quantity
1548              3. Description
1549            * 1. Albatross!
1550              2. 299
1551              3. On a stick!
1552            * 1. Crunchy Frog!
1553              2. 1499
1554              3. If we took the bones out, it wouldn't be crunchy,
1555                 now would it?
1557    That provides better correspondence between cells in the same
1558    column than does bullet-list syntax, but not as good as field list
1559    syntax.  I think that were only field-list-tables available, a lot
1560    of users would use the equivalent degenerate case::
1562        .. field-list-table::
1563            - :1: Treat
1564              :2: Quantity
1565              :3: Description
1566            ...
1568 4. Another natural variant is to allow a description list with field
1569    lists as descriptions::
1571        .. list-table::
1572            :headrows: 1
1574            Treat
1575                :quantity: Quantity
1576                :descr: Description
1577            Albatross!
1578                :quantity: 299
1579                :descr: On a stick!
1580            Crunchy Frog!
1581                :quantity: 1499
1582                :descr: If we took the bones out, it wouldn't be
1583                        crunchy, now would it?
1585    This would make the whole first column a header column ("stub").
1586    It's limited to a single column and a single paragraph fitting on
1587    one source line.  Also it wouldn't allow for empty cells or row
1588    spans in the first column.  But these are limitations that we could
1589    live with, like those of simple tables.
1591 The List-driven table feature could be done in many ways.  Each user
1592 will have their preferred usage.  Perhaps a single "list-table"
1593 directive could handle them all, depending on which options and
1594 content are present.
1596 Issues:
1598 * How to indicate that there's 1 header row?  Perhaps two lists?  ::
1600       .. list-table::
1602          + - Treat
1603            - Quantity
1604            - Description
1606          * - Albatross!
1607            - 299
1608            - On a stick!
1610   This is probably too subtle though.  Better would be a directive
1611   option, like ``:headrows: 1``.  An early suggestion for the header
1612   row(s) was to use a directive option::
1614       .. field-list-table::
1615          :header:
1616              - :treat: Treat
1617                :quantity: Quantity
1618                :descr: Description
1619          - :treat: Albatross!
1620            :quantity: 299
1621            :descr: On a stick!
1623   But the table data is at two levels and looks inconsistent.
1625   In general, we cannot extract the header row from field lists' field
1626   names because field names cannot contain everything one might put in
1627   a table cell.  A separate header row also allows shorter field names
1628   and doesn't force one to rewrite the whole table when the header
1629   text changes.  But for simpler cases, we can offer a ":header:
1630   fields" option, which does extract header cells from field names::
1632       .. field-list-table::
1633           :header: fields
1635           - :Treat: Albatross!
1636             :Quantity: 299
1637             :Description: On a stick!
1639 * How to indicate the column widths?  A directive option? ::
1641       .. list-table::
1642          :widths: 15 10 35
1644   Automatic defaults from the text used?
1646 * How to handle row and/or column spans?
1648   In a field list, column-spans can be indicated by specifying the
1649   first and last fields, separated by space-dash-space or ellipsis::
1651       - :foo - baz: quuux
1652       - :foo ... baz: quuux
1654   Commas were proposed for column spans::
1656       - :foo, bar: quux
1658   But non-adjacent columns become problematic.  Should we report an
1659   error, or duplicate the value into each span of adjacent columns (as
1660   was suggested)?  The latter suggestion is appealing but may be too
1661   clever.  Best perhaps to simply specify the two ends.
1663   It was suggested that comma syntax should be allowed, too, in order
1664   to allow the user to avoid trouble when changing the column order.
1665   But changing the column order of a table with spans is not trivial;
1666   we shouldn't make it easier to mess up.
1668   One possible syntax for row-spans is to simply treat any row where a
1669   field is missing as a row-span from the last row where it appeared.
1670   Leaving a field empty would still be possible by writing a field
1671   with empty content.  But this is too implicit.
1673   Another way would be to require an explicit continuation marker
1674   (``...``/``-"-``/``"``?) in all but the first row of a spanned
1675   field.  Empty comments could work ("..").  If implemented, the same
1676   marker could also be supported in simple tables, which lack
1677   row-spanning abilities.
1679   Explicit markup like ":rowspan:" and ":colspan:" was also suggested.
1681   Sometimes in a table, the first header row contains spans.  It may
1682   be necessary to provide a way to specify the column field names
1683   independently of data rows.  A directive option would do it.
1685 * We could specify "column-wise" or "row-wise" ordering, with the same
1686   markup structure.  For example, with definition data::
1688       .. list-table::
1689          :column-wise:
1691          Treat
1692              - Albatross!
1693              - Crunchy Frog!
1694          Quantity
1695              - 299
1696              - 1499
1697          Description
1698              - On a stick!
1699              - If we took the bones out, it wouldn't be
1700                crunchy, now would it?
1702 * A syntax for _`stubs in grid tables` is easy to imagine::
1704       +------------------------++------------+----------+
1705       | Header row, column 1   || Header 2   | Header 3 |
1706       +========================++============+==========+
1707       | body row 1, column 1   || column 2   | column 3 |
1708       +------------------------++------------+----------+
1710   Or this idea from Nick Moffitt::
1712       +-----+---+---+
1713       | XOR # T | F |
1714       +=====+===+===+
1715       |   T # F | T |
1716       +-----+---+---+
1717       |   F # T | F |
1718       +-----+---+---+
1721 Auto-Enumerated Lists
1722 =====================
1724 Implemented 2005-03-24: combination of variation 1 & 2.
1726 The advantage of auto-numbered enumerated lists would be similar to
1727 that of auto-numbered footnotes: lists could be written and rearranged
1728 without having to manually renumber them.  The disadvantages are also
1729 the same: input and output wouldn't match exactly; the markup may be
1730 ugly or confusing (depending on which alternative is chosen).
1732 1. Use the "#" symbol.  Example::
1734        #. Item 1.
1735        #. Item 2.
1736        #. Item 3.
1738    Advantages: simple, explicit.  Disadvantage: enumeration sequence
1739    cannot be specified (limited to arabic numerals); ugly.
1741 2. As a variation on #1, first initialize the enumeration sequence?
1742    For example::
1744        a) Item a.
1745        #) Item b.
1746        #) Item c.
1748    Advantages: simple, explicit, any enumeration sequence possible.
1749    Disadvantages: ugly; perhaps confusing with mixed concrete/abstract
1750    enumerators.
1752 3. Alternative suggested by Fred Bremmer, from experience with MoinMoin::
1754        1. Item 1.
1755        1. Item 2.
1756        1. Item 3.
1758    Advantages: enumeration sequence is explicit (could be multiple
1759    "a." or "(I)" tokens).  Disadvantages: perhaps confusing; otherwise
1760    erroneous input (e.g., a duplicate item "1.") would pass silently,
1761    either causing a problem later in the list (if no blank lines
1762    between items) or creating two lists (with blanks).
1764    Take this input for example::
1766        1. Item 1.
1768        1. Unintentional duplicate of item 1.
1770        2. Item 2.
1772    Currently the parser will produce two list, "1" and "1,2" (no
1773    warnings, because of the presence of blank lines).  Using Fred's
1774    notation, the current behavior is "1,1,2 -> 1 1,2" (without blank
1775    lines between items, it would be "1,1,2 -> 1 [WARNING] 1,2").  What
1776    should the behavior be with auto-numbering?
1778    Fred has produced a patch__, whose initial behavior is as follows::
1780        1,1,1   -> 1,2,3
1781        1,2,2   -> 1,2,3
1782        3,3,3   -> 3,4,5
1783        1,2,2,3 -> 1,2,3 [WARNING] 3
1784        1,1,2   -> 1,2 [WARNING] 2
1786    (After the "[WARNING]", the "3" would begin a new list.)
1788    I have mixed feelings about adding this functionality to the spec &
1789    parser.  It would certainly be useful to some users (myself
1790    included; I often have to renumber lists).  Perhaps it's too
1791    clever, asking the parser to guess too much.  What if you *do* want
1792    three one-item lists in a row, each beginning with "1."?  You'd
1793    have to use empty comments to force breaks.  Also, I question
1794    whether "1,2,2 -> 1,2,3" is optimal behavior.
1796    In response, Fred came up with "a stricter and more explicit rule
1797    [which] would be to only auto-number silently if *all* the
1798    enumerators of a list were identical".  In that case::
1800        1,1,1   -> 1,2,3
1801        1,2,2   -> 1,2 [WARNING] 2
1802        3,3,3   -> 3,4,5
1803        1,2,2,3 -> 1,2 [WARNING] 2,3
1804        1,1,2   -> 1,2 [WARNING] 2
1806    Should any start-value be allowed ("3,3,3"), or should
1807    auto-numbered lists be limited to begin with ordinal-1 ("1", "A",
1808    "a", "I", or "i")?
1810    __ http://sourceforge.net/tracker/index.php?func=detail&aid=548802
1811       &group_id=38414&atid=422032
1813 4. Alternative proposed by Tony Ibbs::
1815        #1. First item.
1816        #3. Aha - I edited this in later.
1817        #2. Second item.
1819    The initial proposal required unique enumerators within a list, but
1820    this limits the convenience of a feature of already limited
1821    applicability and convenience.  Not a useful requirement; dropped.
1823    Instead, simply prepend a "#" to a standard list enumerator to
1824    indicate auto-enumeration.  The numbers (or letters) of the
1825    enumerators themselves are not significant, except:
1827    - as a sequence indicator (arabic, roman, alphabetic; upper/lower),
1829    - and perhaps as a start value (first list item).
1831    Advantages: explicit, any enumeration sequence possible.
1832    Disadvantages: a bit ugly.
1835 Adjacent citation references
1836 ============================
1838 A special case for inline markup was proposed and implemented:
1839 multiple citation references could be joined into one::
1841    [cite1]_[cite2]_ instead of requiring [cite1]_ [cite2]_
1843 However, this was rejected as an unwarranted exception to the rules
1844 for inline markup.
1845 (The main motivation for the proposal, grouping citations in the latex writer,
1846 was implemented by recognising the second group in the example above and
1847 transforming it into ``\cite{cite1,cite2}``.)
1850 Math Markup
1851 ===========
1853 Using a standard, such as MathML_\ [#]_ seems a good start. However,
1855     MathML in its full XML form was never thought to be usable as an
1856     input format: for a start it is far too verbose as necessitated by
1857     its intention to be expressive.
1859     -- http://www.w3.org/Math/Roadmap/
1861 Like for non-mathematical content, a different input format is needed.
1863 .. [#] For an overview of MathML implementations and tests, see e.g.
1864    the `mathweb wiki`_ or the `ConTeXT MathML page`_.
1866 .. _MathML: http://www.w3.org/TR/MathML2/
1867 .. _mathweb wiki: http://www.mathweb.org/wiki/MathML
1868 .. _ConTeXT MathML page: http://wiki.contextgarden.net/MathML
1870 Input formats
1871 -------------
1873 LaTeX math syntax
1874   * Intended for input by a human, widely used, and well documented.
1876   * Can be used for both, input and internal storage.
1878   * Convertible to all supported output formats (building on
1879     existing extensions like `latex_math`_ (LaTeX2MathML) or the math
1880     support in Sphinx
1882   * Used by the `Math support in Sphinx`_.
1884   * Unicode input similar to the "unicode-math" package for
1885     XeTeX/LuaTeX provides for improved readability of the source.
1887   * The backtick (GRAVE ACCENT, 0x60) cannot be used in a math role.
1888     Fortunately, it is not required in LaTeX math mode, as the
1889     ``\grave`` macro is used instead of ``\```.
1891   .. _latex_math: ../../../sandbox/jensj/latex_math/
1892   .. _Math support in Sphinx: http://sphinx.pocoo.org/ext/math.html
1895 ASCIIMath_
1896   Simple, ASCII based math input language (see also `ASCIIMath tutorial`_).
1898   * The Python module ASCIIMathML_ translates a string with ASCIIMath into a
1899     MathML tree. Used, e.g., by MultiMarkdown__.
1901   * For conversion to LaTeX, there is a JavaScript script at
1902     http://dlippman.imathas.com/asciimathtex/ASCIIMath2TeX.js
1904   .. _ASCIIMath: http://www1.chapman.edu/~jipsen/mathml/asciimath.html
1905   .. _ASCIIMath tutorial:
1906      http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html
1907   .. _ASCIIMathML: http://pypi.python.org/pypi/asciimathml/
1908   __ http://fletcherpenney.net/multimarkdown/
1910 `Unicode Nearly Plain Text Encoding of Mathematics`_
1911    format for lightly marked-up representation of mathematical
1912    expressions in Unicode.
1914    (Unicode Technical Note. Sole responsibility for its contents rests
1915    with the author(s). Publication does not imply any endorsement by
1916    the Unicode Consortium.)
1918    .. _Unicode Nearly Plain Text Encoding of Mathematics:
1919       http://www.unicode.org/notes/tn28/
1921 itex
1922   See `the culmination of a relevant discussion in 2003
1923   <http://article.gmane.org/gmane.text.docutils.user/118>`__.
1926 Since Docutils 0.8, a "math" role and directive using LaTeX math
1927 syntax as input format is part of reStructuredText.
1930 -----------------
1931  Not Implemented
1932 -----------------
1934 Reworking Footnotes
1935 ===================
1937 As a further wrinkle (see `Reworking Explicit Markup (Round 1)`_
1938 above), in the wee hours of 2002-02-28 I posted several ideas for
1939 changes to footnote syntax:
1941     - Change footnote syntax from ``.. [1]`` to ``_[1]``? ...
1942     - Differentiate (with new DTD elements) author-date "citations"
1943       (``[GVR2002]``) from numbered footnotes? ...
1944     - Render footnote references as superscripts without "[]"? ...
1946 These ideas are all related, and suggest changes in the
1947 reStructuredText syntax as well as the docutils tree model.
1949 The footnote has been used for both true footnotes (asides expanding
1950 on points or defining terms) and for citations (references to external
1951 works).  Rather than dealing with one amalgam construct, we could
1952 separate the current footnote concept into strict footnotes and
1953 citations.  Citations could be interpreted and treated differently
1954 from footnotes.  Footnotes would be limited to numerical labels:
1955 manual ("1") and auto-numbered (anonymous "#", named "#label").
1957 The footnote is the only explicit markup construct (starts with ".. ")
1958 that directly translates to a visible body element.  I've always been
1959 a little bit uncomfortable with the ".. " marker for footnotes because
1960 of this; ".. " has a connotation of "special", but footnotes aren't
1961 especially "special".  Printed texts often put footnotes at the bottom
1962 of the page where the reference occurs (thus "foot note").  Some HTML
1963 designs would leave footnotes to be rendered the same positions where
1964 they're defined.  Other online and printed designs will gather
1965 footnotes into a section near the end of the document, converting them
1966 to "endnotes" (perhaps using a directive in our case); but this
1967 "special processing" is not an intrinsic property of the footnote
1968 itself, but a decision made by the document author or processing
1969 system.
1971 Citations are almost invariably collected in a section at the end of a
1972 document or section.  Citations "disappear" from where they are
1973 defined and are magically reinserted at some well-defined point.
1974 There's more of a connection to the "special" connotation of the ".. "
1975 syntax.  The point at which the list of citations is inserted could be
1976 defined manually by a directive (e.g., ".. citations::"), and/or have
1977 default behavior (e.g., a section automatically inserted at the end of
1978 the document) that might be influenced by options to the Writer.
1980 Syntax proposals:
1982 + Footnotes:
1984   - Current syntax::
1986         .. [1] Footnote 1
1987         .. [#] Auto-numbered footnote.
1988         .. [#label] Auto-labeled footnote.
1990   - The syntax proposed in the original 2002-02-28 Doc-SIG post:
1991     remove the ".. ", prefix a "_"::
1993         _[1] Footnote 1
1994         _[#] Auto-numbered footnote.
1995         _[#label] Auto-labeled footnote.
1997     The leading underscore syntax (earlier dropped because
1998     ``.. _[1]:`` was too verbose) is a useful reminder that footnotes
1999     are hyperlink targets.
2001   - Minimal syntax: remove the ".. [" and "]", prefix a "_", and
2002     suffix a "."::
2004         _1. Footnote 1.
2005         _#. Auto-numbered footnote.
2006         _#label. Auto-labeled footnote.
2008                  ``_1.``, ``_#.``, and ``_#label.`` are markers,
2009                  like list markers.
2011     Footnotes could be rendered something like this in HTML
2013         | 1. This is a footnote.  The brackets could be dropped
2014         |    from the label, and a vertical bar could set them
2015         |    off from the rest of the document in the HTML.
2017     Two-way hyperlinks on the footnote marker ("1." above) would also
2018     help to differentiate footnotes from enumerated lists.
2020     If converted to endnotes (by a directive/transform), a horizontal
2021     half-line might be used instead.  Page-oriented output formats
2022     would typically use the horizontal line for true footnotes.
2024 + Footnote references:
2026   - Current syntax::
2028         [1]_, [#]_, [#label]_
2030   - Minimal syntax to match the minimal footnote syntax above::
2032         1_, #_, #label_
2034     As a consequence, pure-numeric hyperlink references would not be
2035     possible; they'd be interpreted as footnote references.
2037 + Citation references: no change is proposed from the current footnote
2038   reference syntax::
2040       [GVR2001]_
2042 + Citations:
2044   - Current syntax (footnote syntax)::
2046         .. [GVR2001] Python Documentation; van Rossum, Drake, et al.;
2047            http://www.python.org/doc/
2049   - Possible new syntax::
2051         _[GVR2001] Python Documentation; van Rossum, Drake, et al.;
2052                    http://www.python.org/doc/
2054         _[DJG2002]
2055             Docutils: Python Documentation Utilities project; Goodger
2056             et al.; http://docutils.sourceforge.net/
2058     Without the ".. " marker, subsequent lines would either have to
2059     align as in one of the above, or we'd have to allow loose
2060     alignment (I'd rather not)::
2062         _[GVR2001] Python Documentation; van Rossum, Drake, et al.;
2063             http://www.python.org/doc/
2065 I proposed adopting the "minimal" syntax for footnotes and footnote
2066 references, and adding citations and citation references to
2067 reStructuredText's repertoire.  The current footnote syntax for
2068 citations is better than the alternatives given.
2070 From a reply by Tony Ibbs on 2002-03-01:
2072     However, I think easier with examples, so let's create one::
2074         Fans of Terry Pratchett are perhaps more likely to use
2075         footnotes [1]_ in their own writings than other people
2076         [2]_.  Of course, in *general*, one only sees footnotes
2077         in academic or technical writing - it's use in fiction
2078         and letter writing is not normally considered good
2079         style [4]_, particularly in emails (not a medium that
2080         lends itself to footnotes).
2082         .. [1] That is, little bits of referenced text at the
2083            bottom of the page.
2084         .. [2] Because Terry himself does, of course [3]_.
2085         .. [3] Although he has the distinction of being
2086            *funny* when he does it, and his fans don't always
2087            achieve that aim.
2088         .. [4] Presumably because it detracts from linear
2089            reading of the text - this is, of course, the point.
2091     and look at it with the second syntax proposal::
2093         Fans of Terry Pratchett are perhaps more likely to use
2094         footnotes [1]_ in their own writings than other people
2095         [2]_.  Of course, in *general*, one only sees footnotes
2096         in academic or technical writing - it's use in fiction
2097         and letter writing is not normally considered good
2098         style [4]_, particularly in emails (not a medium that
2099         lends itself to footnotes).
2101         _[1] That is, little bits of referenced text at the
2102              bottom of the page.
2103         _[2] Because Terry himself does, of course [3]_.
2104         _[3] Although he has the distinction of being
2105              *funny* when he does it, and his fans don't always
2106              achieve that aim.
2107         _[4] Presumably because it detracts from linear
2108              reading of the text - this is, of course, the point.
2110     (I note here that if I have gotten the indentation of the
2111     footnotes themselves correct, this is clearly not as nice.  And if
2112     the indentation should be to the left margin instead, I like that
2113     even less).
2115     and the third (new) proposal::
2117         Fans of Terry Pratchett are perhaps more likely to use
2118         footnotes 1_ in their own writings than other people
2119         2_.  Of course, in *general*, one only sees footnotes
2120         in academic or technical writing - it's use in fiction
2121         and letter writing is not normally considered good
2122         style 4_, particularly in emails (not a medium that
2123         lends itself to footnotes).
2125         _1. That is, little bits of referenced text at the
2126             bottom of the page.
2127         _2. Because Terry himself does, of course 3_.
2128         _3. Although he has the distinction of being
2129             *funny* when he does it, and his fans don't always
2130             achieve that aim.
2131         _4. Presumably because it detracts from linear
2132             reading of the text - this is, of course, the point.
2134     I think I don't, in practice, mind the targets too much (the use
2135     of a dot after the number helps a lot here), but I do have a
2136     problem with the body text, in that I don't naturally separate out
2137     the footnotes as different than the rest of the text - instead I
2138     keep wondering why there are numbers interspered in the text.  The
2139     use of brackets around the numbers ([ and ]) made me somehow parse
2140     the footnote references as "odd" - i.e., not part of the body text
2141     - and thus both easier to skip, and also (paradoxically) easier to
2142     pick out so that I could follow them.
2144     Thus, for the moment (and as always susceptable to argument), I'd
2145     say -1 on the new form of footnote reference (i.e., I much prefer
2146     the existing ``[1]_`` over the proposed ``1_``), and ambivalent
2147     over the proposed target change.
2149     That leaves David's problem of wanting to distinguish footnotes
2150     and citations - and the only thing I can propose there is that
2151     footnotes are numeric or # and citations are not (which, as a
2152     human being, I can probably cope with!).
2154 From a reply by Paul Moore on 2002-03-01:
2156     I think the current footnote syntax ``[1]_`` is *exactly* the
2157     right balance of distinctness vs unobtrusiveness.  I very
2158     definitely don't think this should change.
2160     On the target change, it doesn't matter much to me.
2162 From a further reply by Tony Ibbs on 2002-03-01, referring to the
2163 "[1]" form and actual usage in email:
2165     Clearly this is a form people are used to, and thus we should
2166     consider it strongly (in the same way that the usage of ``*..*``
2167     to mean emphasis was taken partly from email practise).
2169     Equally clearly, there is something "magical" for people in the
2170     use of a similar form (i.e., ``[1]``) for both footnote reference
2171     and footnote target - it seems natural to keep them similar.
2173     ...
2175     I think that this established plaintext usage leads me to strongly
2176     believe we should retain square brackets at both ends of a
2177     footnote.  The markup of the reference end (a single trailing
2178     underscore) seems about as minimal as we can get away with.  The
2179     markup of the target end depends on how one envisages the thing -
2180     if ".." means "I am a target" (as I tend to see it), then that's
2181     good, but one can also argue that the "_[1]" syntax has a neat
2182     symmetry with the footnote reference itself, if one wishes (in
2183     which case ".." presumably means "hidden/special" as David seems
2184     to think, which is why one needs a ".." *and* a leading underline
2185     for hyperlink targets.
2187 Given the persuading arguments voiced, we'll leave footnote & footnote
2188 reference syntax alone.  Except that these discussions gave rise to
2189 the "auto-symbol footnote" concept, which has been added.  Citations
2190 and citation references have also been added.
2193 Syntax for Questions & Answers
2194 ==============================
2196 Implement as a generic two-column marked list?  As a standalone
2197 (non-directive) construct?  (Is the markup ambiguous?)  Add support to
2198 parts.contents?
2200 New elements would be required.  Perhaps::
2202     <!ELEMENT question_list (question_list_item+)>
2203     <!ATTLIST question_list
2204         numbering  (none | local | global)
2205                             #IMPLIED
2206         start     NUMBER    #IMPLIED>
2207     <!ELEMENT question_list_item (question, answer*)>
2208     <!ELEMENT question %text.model;>
2209     <!ELEMENT answer (%body.elements;)+>
2211 Originally I thought of implementing a Q&A list with special syntax::
2213     Q: What am I?
2215     A: You are a question-and-answer
2216        list.
2218     Q: What are you?
2220     A: I am the omniscient "we".
2222 Where each "Q" and "A" could also be numbered (e.g., "Q1").  However,
2223 a simple enumerated or bulleted list will do just fine for syntax.  A
2224 directive could treat the list specially; e.g. the first paragraph
2225 could be treated as a question, the remainder as the answer (multiple
2226 answers could be represented by nested lists).  Without special
2227 syntax, this directive becomes low priority.
2229 As described in the FAQ__, no special syntax or directive is needed
2230 for this application.
2232 __ http://docutils.sf.net/FAQ.html
2233    #how-can-i-mark-up-a-faq-or-other-list-of-questions-answers
2236 --------
2237  Tabled
2238 --------
2240 Reworking Explicit Markup (Round 2)
2241 ===================================
2243 See `Reworking Explicit Markup (Round 1)`_ for an earlier discussion.
2245 In April 2004, a new thread becan on docutils-develop: `Inconsistency
2246 in RST markup`__.  Several arguments were made; the first argument
2247 begat later arguments.  Below, the arguments are paraphrased "in
2248 quotes", with responses.
2250 __ http://thread.gmane.org/gmane.text.docutils.devel/1386
2252 1. References and targets take this form::
2254        targetname_
2256        .. _targetname: stuff
2258    But footnotes, "which generate links just like targets do", are
2259    written as::
2261        [1]_
2263        .. [1] stuff
2265    "Footnotes should be written as"::
2267        [1]_
2269        .. _[1]: stuff
2271    But they're not the same type of animal.  That's not a "footnote
2272    target", it's a *footnote*.  Being a target is not a footnote's
2273    primary purpose (an arguable point).  It just happens to grow a
2274    target automatically, for convenience.  Just as a section title::
2276        Title
2277        =====
2279    isn't a "title target", it's a *title*, which happens to grow a
2280    target automatically.  The consistency is there, it's just deeper
2281    than at first glance.
2283    Also, ".. [1]" was chosen for footnote syntax because it closely
2284    resembles one form of actual footnote rendering.  ".. _[1]:" is too
2285    verbose; excessive punctuation is required to get the job done.
2287    For more of the reasoning behind the syntax, see `Problems With
2288    StructuredText (Hyperlinks) <problems.html#hyperlinks>`__ and
2289    `Reworking Footnotes`_.
2291 2. "I expect directives to also look like ``.. this:`` [one colon]
2292    because that also closely parallels the link and footnote target
2293    markup."
2295    There are good reasons for the two-colon syntax:
2297        Two colons are used after the directive type for these reasons:
2299        - Two colons are distinctive, and unlikely to be used in common
2300          text.
2302        - Two colons avoids clashes with common comment text like::
2304              .. Danger: modify at your own risk!
2306        - If an implementation of reStructuredText does not recognize a
2307          directive (i.e., the directive-handler is not installed), a
2308          level-3 (error) system message is generated, and the entire
2309          directive block (including the directive itself) will be
2310          included as a literal block.  Thus "::" is a natural choice.
2312        -- `restructuredtext.html#directives
2313        <../../ref/rst/restructuredtext.html#directives>`__
2315    The last reason is not particularly compelling; it's more of a
2316    convenient coincidence or mnemonic.
2318 3. "Comments always seemed too easy.  I almost never write comments.
2319    I'd have no problem writing '.. comment:' in front of my comments.
2320    In fact, it would probably be more readable, as comments *should*
2321    be set off strongly, because they are very different from normal
2322    text."
2324    Many people do use comments though, and some applications of
2325    reStructuredText require it.  For example, all reStructuredText
2326    PEPs (and this document!) have an Emacs stanza at the bottom, in a
2327    comment.  Having to write ".. comment::" would be very obtrusive.
2329    Comments *should* be dirt-easy to do.  It should be easy to
2330    "comment out" a block of text.  Comments in programming languages
2331    and other markup languages are invariably easy.
2333    Any author is welcome to preface their comments with "Comment:" or
2334    "Do Not Print" or "Note to Editor" or anything they like.  A
2335    "comment" directive could easily be implemented.  It might be
2336    confused with admonition directives, like "note" and "caution"
2337    though.  In unrelated (and unpublished and unfinished) work, adding
2338    a "comment" directive as a true document element was considered::
2340        If structure is necessary, we could use a "comment" directive
2341        (to avoid nonsensical DTD changes, the "comment" directive
2342        could produce an untitled topic element).
2344 4. "One of the goals of reStructuredText is to be *readable* by people
2345    who don't know it.  This construction violates that: it is not at
2346    all obvious to the uninitiated that text marked by '..' is a
2347    comment.  On the other hand, '.. comment:' would be totally
2348    transparent."
2350    Totally transparent, perhaps, but also very obtrusive.  Another of
2351    `reStructuredText's goals`_ is to be unobtrusive, and
2352    ".. comment::" would violate that.  The goals of reStructuredText
2353    are many, and they conflict.  Determining the right set of goals
2354    and finding solutions that best fit is done on a case-by-case
2355    basis.
2357    Even readability is has two aspects.  Being readable without any
2358    prior knowledge is one.  Being as easily read in raw form as in
2359    processed form is the other.  ".." may not contribute to the former
2360    aspect, but ".. comment::" would certainly detract from the latter.
2362    .. _author's note:
2363    .. _reStructuredText's goals: ../../ref/rst/introduction.html#goals
2365 5. "Recently I sent someone an rst document, and they got confused; I
2366    had to explain to them that '..' marks comments, *unless* it's a
2367    directive, etc..."
2369    The explanation of directives *is* roundabout, defining comments in
2370    terms of not being other things.  That's definitely a wart.
2372 6. "Under the current system, a mistyped directive (with ':' instead
2373    of '::') will be silently ignored.  This is an error that could
2374    easily go unnoticed."
2376    A parser option/setting like "--comments-on-stderr" would help.
2378 7. "I'd prefer to see double-dot-space / command / double-colon as the
2379    standard Docutils markup-marker.  It's unusual enough to avoid
2380    being accidently used.  Everything that starts with a double-dot
2381    should end with a double-colon."
2383    That would increase the punctuation verbosity of some constructs
2384    considerably.
2386 8. Edward Loper proposed the following plan for backwards
2387    compatibility:
2389        1. ".. foo" will generate a deprecation warning to stderr, and
2390           nothing in the output (no system messages).
2391        2. ".. foo: bar" will be treated as a directive foo.  If there
2392           is no foo directive, then do the normal error output.
2393        3. ".. foo:: bar" will generate a deprecation warning to
2394           stderr, and be treated as a directive.  Or leave it valid?
2396        So some existing documents might start printing deprecation
2397        warnings, but the only existing documents that would *break*
2398        would be ones that say something like::
2400            .. warning: this should be a comment
2402        instead of::
2404            .. warning:: this should be a comment
2406        Here, we're trading fairly common a silent error (directive
2407        falsely treated as a comment) for a fairly uncommon explicitly
2408        flagged error (comment falsely treated as directive).  To make
2409        things even easier, we could add a sentence to the
2410        unknown-directive error.  Something like "If you intended to
2411        create a comment, please use '.. comment:' instead".
2413 On one hand, I understand and sympathize with the points raised.  On
2414 the other hand, I think the current syntax strikes the right balance
2415 (but I acknowledge a possible lack of objectivity).  On the gripping
2416 hand, the comment and directive syntax has become well established, so
2417 even if it's a wart, it may be a wart we have to live with.
2419 Making any of these changes would cause a lot of breakage or at least
2420 deprecation warnings.  I'm not sure the benefit is worth the cost.
2422 For now, we'll treat this as an unresolved legacy issue.
2425 -------
2426  To Do
2427 -------
2429 Nested Inline Markup
2430 ====================
2432 These are collected notes on a long-discussed issue.  The original
2433 mailing list messages should be referred to for details.
2435 * In a 2001-10-31 discussion I wrote:
2437       Try, for example, `Ed Loper's 2001-03-21 post`_, which details
2438       some rules for nested inline markup. I think the complexity is
2439       prohibitive for the marginal benefit. (And if you can understand
2440       that tree without going mad, you're a better man than I. ;-)
2442       Inline markup is already fragile. Allowing nested inline markup
2443       would only be asking for trouble IMHO. If it proves absolutely
2444       necessary, it can be added later. The rules for what can appear
2445       inside what must be well thought out first though.
2447       .. _Ed Loper's 2001-03-21 post:
2448          http://mail.python.org/pipermail/doc-sig/2001-March/001487.html
2450       -- http://mail.python.org/pipermail/doc-sig/2001-October/002354.html
2452 * In a 2001-11-09 Doc-SIG post, I wrote:
2454       The problem is that in the
2455       what-you-see-is-more-or-less-what-you-get markup language that
2456       is reStructuredText, the symbols used for inline markup ("*",
2457       "**", "`", "``", etc.) may preclude nesting.
2459   I've rethought this position.  Nested markup is not precluded, just
2460   tricky.  People and software parse "double and 'single' quotes" all
2461   the time.  Continuing,
2463       I've thought over how we might implement nested inline
2464       markup. The first algorithm ("first identify the outer inline
2465       markup as we do now, then recursively scan for nested inline
2466       markup") won't work; counterexamples were given in my `last post
2467       <http://mail.python.org/pipermail/doc-sig/2001-November/002363.html>`__.
2469       The second algorithm makes my head hurt::
2471           while 1:
2472               scan for start-string
2473               if found:
2474                   push on stack
2475                   scan for start or end string
2476                   if new start string found:
2477                       recurse
2478                   elif matching end string found:
2479                       pop stack
2480                   elif non-matching end string found:
2481                       if its a markup error:
2482                           generate warning
2483                       elif the initial start-string was misinterpreted:
2484                           # e.g. in this case: ***strong** in emphasis*
2485                           restart with the other interpretation
2486                           # but it might be several layers back ...
2487               ...
2489       This is similar to how the parser does section title
2490       recognition, but sections are much more regular and
2491       deterministic.
2493       Bottom line is, I don't think the benefits are worth the effort,
2494       even if it is possible. I'm not going to try to write the code,
2495       at least not now. If somebody codes up a consistent, working,
2496       general solution, I'll be happy to consider it.
2498       -- http://mail.python.org/pipermail/doc-sig/2001-November/002388.html
2500 * In a `2003-05-06 Docutils-Users post`__ Paul Tremblay proposed a new
2501   syntax to allow for easier nesting.  It eventually evolved into
2502   this::
2504       :role:[inline text]
2506   The duplication with the existing interpreted text syntax is
2507   problematic though.
2509   __ http://article.gmane.org/gmane.text.docutils.user/317
2511 * Could the parser be extended to parse nested interpreted text? ::
2513       :emphasis:`Some emphasized text with :strong:`some more
2514       emphasized text` in it and **perhaps** :reference:`a link``
2516 * In a `2003-06-18 Docutils-Develop post`__, Mark Nodine reported on
2517   his implementation of a form of nested inline markup in his
2518   Perl-based parser (unpublished).  He brought up some interesting
2519   ideas.  The implementation was flawed, however, by the change in
2520   semantics required for backslash escapes.
2522   __ http://article.gmane.org/gmane.text.docutils.devel/795
2524 * Docutils-develop threads between David Abrahams, David Goodger, and
2525   Mark Nodine (beginning 2004-01-16__ and 2004-01-19__) hashed out
2526   many of the details of a potentially successful implementation, as
2527   described below.  David Abrahams checked in code to the "nesting"
2528   branch of CVS, awaiting thorough review.
2530   __ http://thread.gmane.org/gmane.text.docutils.devel/1102
2531   __ http://thread.gmane.org/gmane.text.docutils.devel/1125
2533 It may be possible to accomplish nested inline markup in general with
2534 a more powerful inline markup parser.  There may be some issues, but
2535 I'm not averse to the idea of nested inline markup in general.  I just
2536 don't have the time or inclination to write a new parser now.  Of
2537 course, a good patch would be welcome!
2539 I envisage something like this.  Explicit-role interpreted text must
2540 be nestable.  Prefix-based is probably preferred, since suffix-based
2541 will look like inline literals::
2543     ``text`:role1:`:role2:
2545 But it can be disambiguated, so it ought to be left up to the author::
2547     `\ `text`:role1:`:role2:
2549 In addition, other forms of inline markup may be nested if
2550 unambiguous::
2552     *emphasized ``literal`` and |substitution ref| and link_*
2554 IOW, the parser ought to be as permissive as possible.
2557 Index Entries & Indexes
2558 =======================
2560 Were I writing a book with an index, I guess I'd need two
2561 different kinds of index targets: inline/implicit and
2562 out-of-line/explicit.  For example::
2564     In this `paragraph`:index:, several words are being
2565     `marked`:index: inline as implicit `index`:index:
2566     entries.
2568     .. index:: markup
2569     .. index:: syntax
2571     The explicit index directives above would refer to
2572     this paragraph.  It might also make sense to allow multiple
2573     entries in an ``index`` directive:
2575     .. index::
2576         markup
2577         syntax
2579 The words "paragraph", "marked", and "index" would become index
2580 entries pointing at the words in the first paragraph.  The index
2581 entry words appear verbatim in the text.  (Don't worry about the
2582 ugly ":index:" part; if indexing is the only/main application of
2583 interpreted text in your documents, it can be implicit and
2584 omitted.)  The two directives provide manual indexing, where the
2585 index entry words ("markup" and "syntax") do not appear in the
2586 main text.  We could combine the two directives into one::
2588     .. index:: markup; syntax
2590 Semicolons instead of commas because commas could *be* part of the
2591 index target, like::
2593     .. index:: van Rossum, Guido
2595 Another reason for index directives is because other inline markup
2596 wouldn't be possible within inline index targets.
2598 Sometimes index entries have multiple levels.  Given::
2600     .. index:: statement syntax: expression statements
2602 In a hypothetical index, combined with other entries, it might
2603 look like this::
2605     statement syntax
2606         expression statements ..... 56
2607         assignment ................ 57
2608         simple statements ......... 58
2609         compound statements ....... 60
2611 Inline multi-level index targets could be done too.  Perhaps
2612 something like::
2614     When dealing with `expression statements <statement syntax:>`,
2615     we must remember ...
2617 The opposite sense could also be possible::
2619     When dealing with `index entries <:multi-level>`, there are
2620     many permutations to consider.
2622 Also "see / see also" index entries.
2624 Given::
2626     Here's a paragraph.
2628     .. index:: paragraph
2630 (The "index" directive above actually targets the *preceding*
2631 object.)  The directive should produce something like this XML::
2633     <paragraph>
2634     <index_entry text="paragraph"/>
2635     Here's a paragraph.
2636     </paragraph>
2638 This kind of content model would also allow true inline
2639 index-entries::
2641     Here's a `paragraph`:index:.
2643 If the "index" role were the default for the application, it could be
2644 dropped::
2646     Here's a `paragraph`.
2648 Both of these would result in this XML::
2650     <paragraph>
2651     Here's a <index_entry>paragraph</index_entry>.
2652     </paragraph>
2655 from 2002-06-24 docutils-develop posts
2656 --------------------------------------
2658     If all of your index entries will appear verbatim in the text,
2659     this should be sufficient.  If not (e.g., if you want "Van Rossum,
2660     Guido" in the index but "Guido van Rossum" in the text), we'll
2661     have to figure out a supplemental mechanism, perhaps using
2662     substitutions.
2664 I've thought a bit more on this, and I came up with two possibilities:
2666 1. Using interpreted text, embed the index entry text within the
2667    interpreted text::
2669        ... by `Guido van Rossum [Van Rossum, Guido]` ...
2671    The problem with this is obvious: the text becomes cluttered and
2672    hard to read.  The processed output would drop the text in
2673    brackets, which goes against the spirit of interpreted text.
2675 2. Use substitutions::
2677        ... by |Guido van Rossum| ...
2679        .. |Guido van Rossum| index:: Van Rossum, Guido
2681    A problem with this is that each substitution definition must have
2682    a unique name.  A subsequent ``.. |Guido van Rossum| index:: BDFL``
2683    would be illegal.  Some kind of anonymous substitution definition
2684    mechanism would be required, but I think that's going too far.
2686 Both of these alternatives are flawed.  Any other ideas?
2689 -------------------
2690  ... Or Not To Do?
2691 -------------------
2693 This is the realm of the possible but questionably probable.  These
2694 ideas are kept here as a record of what has been proposed, for
2695 posterity and in case any of them prove to be useful.
2698 Compound Enumerated Lists
2699 =========================
2701 Allow for compound enumerators, such as "1.1." or "1.a." or "1(a)", to
2702 allow for nested enumerated lists without indentation?
2705 Indented Lists
2706 ==============
2708 Allow for variant styles by interpreting indented lists as if they
2709 weren't indented?  For example, currently the list below will be
2710 parsed as a list within a block quote::
2712     paragraph
2714       * list item 1
2715       * list item 2
2717 But a lot of people seem to write that way, and HTML browsers make it
2718 look as if that's the way it should be.  The parser could check the
2719 contents of block quotes, and if they contain only a single list,
2720 remove the block quote wrapper.  There would be two problems:
2722 1. What if we actually *do* want a list inside a block quote?
2724 2. What if such a list comes immediately after an indented construct,
2725    such as a literal block?
2727 Both could be solved using empty comments (problem 2 already exists
2728 for a block quote after a literal block).  But that's a hack.
2730 Perhaps a runtime setting, allowing or disabling this convenience,
2731 would be appropriate.  But that raises issues too:
2733     User A, who writes lists indented (and their config file is set up
2734     to allow it), sends a file to user B, who doesn't (and their
2735     config file disables indented lists).  The result of processing by
2736     the two users will be different.
2738 It may seem minor, but it adds ambiguity to the parser, which is bad.
2740 See the `Doc-SIG discussion starting 2001-04-18`__ with Ed Loper's
2741 "Structuring: a summary; and an attempt at EBNF", item 4 (and
2742 follow-ups, here__ and here__).  Also `docutils-users, 2003-02-17`__
2743 and `beginning 2003-08-04`__.
2745 __ http://mail.python.org/pipermail/doc-sig/2001-April/001776.html
2746 __ http://mail.python.org/pipermail/doc-sig/2001-April/001789.html
2747 __ http://mail.python.org/pipermail/doc-sig/2001-April/001793.html
2748 __ http://sourceforge.net/mailarchive/message.php?msg_id=3838913
2749 __ http://sf.net/mailarchive/forum.php?thread_id=2957175&forum_id=11444
2752 Sloppy Indentation of List Items
2753 ================================
2755 Perhaps the indentation shouldn't be so strict.  Currently, this is
2756 required::
2758     1. First line,
2759        second line.
2761 Anything wrong with this? ::
2763     1. First line,
2764      second line.
2766 Problem? ::
2768     1. First para.
2770        Block quote.  (no good: requires some indent relative to first
2771        para)
2773      Second Para.
2775     2. Have to carefully define where the literal block ends::
2777          Literal block
2779        Literal block?
2781 Hmm...  Non-strict indentation isn't such a good idea.
2784 Lazy Indentation of List Items
2785 ==============================
2787 Another approach: Going back to the first draft of reStructuredText
2788 (2000-11-27 post to Doc-SIG)::
2790     - This is the fourth item of the main list (no blank line above).
2791     The second line of this item is not indented relative to the
2792     bullet, which precludes it from having a second paragraph.
2794 Change that to *require* a blank line above and below, to reduce
2795 ambiguity.  This "loosening" may be added later, once the parser's
2796 been nailed down.  However, a serious drawback of this approach is to
2797 limit the content of each list item to a single paragraph.
2800 David's Idea for Lazy Indentation
2801 ---------------------------------
2803 Consider a paragraph in a word processor.  It is a single logical line
2804 of text which ends with a newline, soft-wrapped arbitrarily at the
2805 right edge of the page or screen.  We can think of a plaintext
2806 paragraph in the same way, as a single logical line of text, ending
2807 with two newlines (a blank line) instead of one, and which may contain
2808 arbitrary line breaks (newlines) where it was accidentally
2809 hard-wrapped by an application.  We can compensate for the accidental
2810 hard-wrapping by "unwrapping" every unindented second and subsequent
2811 line.  The indentation of the first line of a paragraph or list item
2812 would determine the indentation for the entire element.  Blank lines
2813 would be required between list items when using lazy indentation.
2815 The following example shows the lazy indentation of multiple body
2816 elements::
2818     - This is the first paragraph
2819     of the first list item.
2821       Here is the second paragraph
2822     of the first list item.
2824     - This is the first paragraph
2825     of the second list item.
2827       Here is the second paragraph
2828     of the second list item.
2830 A more complex example shows the limitations of lazy indentation::
2832     - This is the first paragraph
2833     of the first list item.
2835       Next is a definition list item:
2837       Term
2838           Definition.  The indentation of the term is
2839     required, as is the indentation of the definition's
2840     first line.
2842           When the definition extends to more than
2843     one line, lazy indentation may occur.  (This is the second
2844     paragraph of the definition.)
2846     - This is the first paragraph
2847     of the second list item.
2849       - Here is the first paragraph of
2850     the first item of a nested list.
2852       So this paragraph would be outside of the nested list,
2853     but inside the second list item of the outer list.
2855     But this paragraph is not part of the list at all.
2857 And the ambiguity remains::
2859     - Look at the hyphen at the beginning of the next line
2860     - is it a second list item marker, or a dash in the text?
2862     Similarly, we may want to refer to numbers inside enumerated
2863     lists:
2865     1. How many socks in a pair? There are
2866     2. How many pants in a pair? Exactly
2867     1. Go figure.
2869 Literal blocks and block quotes would still require consistent
2870 indentation for all their lines.  For block quotes, we might be able
2871 to get away with only requiring that the first line of each contained
2872 element be indented.  For example::
2874     Here's a paragraph.
2876         This is a paragraph inside a block quote.
2877     Second and subsequent lines need not be indented at all.
2879         - A bullet list inside
2880     the block quote.
2882           Second paragraph of the
2883     bullet list inside the block quote.
2885 Although feasible, this form of lazy indentation has problems.  The
2886 document structure and hierarchy is not obvious from the indentation,
2887 making the source plaintext difficult to read.  This will also make
2888 keeping track of the indentation while writing difficult and
2889 error-prone.  However, these problems may be acceptable for Wikis and
2890 email mode, where we may be able to rely on less complex structure
2891 (few nested lists, for example).
2894 Multiple Roles in Interpreted Text
2895 ==================================
2897 In reStructuredText, inline markup cannot be nested (yet; `see
2898 above`__).  This also applies to interpreted text.  In order to
2899 simultaneously combine multiple roles for a single piece of text, a
2900 syntax extension would be necessary.  Ideas:
2902 1. Initial idea::
2904        `interpreted text`:role1,role2:
2906 2. Suggested by Jason Diamond::
2908        `interpreted text`:role1:role2:
2910 If a document is so complex as to require nested inline markup,
2911 perhaps another markup system should be considered.  By design,
2912 reStructuredText does not have the flexibility of XML.
2914 __ `Nested Inline Markup`_
2917 Parameterized Interpreted Text
2918 ==============================
2920 In some cases it may be expedient to pass parameters to interpreted
2921 text, analogous to function calls.  Ideas:
2923 1. Parameterize the interpreted text role itself (suggested by Jason
2924    Diamond)::
2926        `interpreted text`:role1(foo=bar):
2928    Positional parameters could also be supported::
2930        `CSS`:acronym(Cascading Style Sheets): is used for HTML, and
2931        `CSS`:acronym(Content Scrambling System): is used for DVDs.
2933    Technical problem: current interpreted text syntax does not
2934    recognize roles containing whitespace.  Design problem: this smells
2935    like programming language syntax, but reStructuredText is not a
2936    programming language.
2938 2. Put the parameters inside the interpreted text::
2940        `CSS (Cascading Style Sheets)`:acronym: is used for HTML, and
2941        `CSS (Content Scrambling System)`:acronym: is used for DVDs.
2943    Although this could be defined on an individual basis (per role),
2944    we ought to have a standard.  Hyperlinks with embedded URIs already
2945    use angle brackets; perhaps they could be used here too::
2947        `CSS <Cascading Style Sheets>`:acronym: is used for HTML, and
2948        `CSS <Content Scrambling System>`:acronym: is used for DVDs.
2950    Do angle brackets connote URLs too much for this to be acceptable?
2951    How about the "tag" connotation -- does it save them or doom them?
2953 3. `Nested inline markup`_ could prove useful here::
2955        `CSS :def:`Cascading Style Sheets``:acronym: is used for HTML,
2956        and `CSS :def:`Content Scrambling System``:acronym: is used for
2957        DVDs.
2959    Inline markup roles could even define the default roles of nested
2960    inline markup, allowing this cleaner syntax::
2962        `CSS `Cascading Style Sheets``:acronym: is used for HTML, and
2963        `CSS `Content Scrambling System``:acronym: is used for DVDs.
2965 Does this push inline markup too far?  Readability becomes a serious
2966 issue.  Substitutions may provide a better alternative (at the expense
2967 of verbosity and duplication) by pulling the details out of the text
2968 flow::
2970     |CSS| is used for HTML, and |CSS-DVD| is used for DVDs.
2972     .. |CSS| acronym:: Cascading Style Sheets
2973     .. |CSS-DVD| acronym:: Content Scrambling System
2974        :text: CSS
2976 ----------------------------------------------------------------------
2978 This whole idea may be going beyond the scope of reStructuredText.
2979 Documents requiring this functionality may be better off using XML or
2980 another markup system.
2982 This argument comes up regularly when pushing the envelope of
2983 reStructuredText syntax.  I think it's a useful argument in that it
2984 provides a check on creeping featurism.  In many cases, the resulting
2985 verbosity produces such unreadable plaintext that there's a natural
2986 desire *not* to use it unless absolutely necessary.  It's a matter of
2987 finding the right balance.
2990 Syntax for Interpreted Text Role Bindings
2991 =========================================
2993 The following syntax (idea from Jeffrey C. Jacobs) could be used to
2994 associate directives with roles::
2996     .. :rewrite: class:: rewrite
2998     `She wore ribbons in her hair and it lay with streaks of
2999     grey`:rewrite:
3001 The syntax is similar to that of substitution declarations, and the
3002 directive/role association may resolve implementation issues.  The
3003 semantics, ramifications, and implementation details would need to be
3004 worked out.
3006 The example above would implement the "rewrite" role as adding a
3007 ``class="rewrite"`` attribute to the interpreted text ("inline"
3008 element).  The stylesheet would then pick up on the "class" attribute
3009 to do the actual formatting.
3011 The advantage of the new syntax would be flexibility.  Uses other than
3012 "class" may present themselves.  The disadvantage is complexity:
3013 having to implement new syntax for a relatively specialized operation,
3014 and having new semantics in existing directives ("class::" would do
3015 something different).
3017 The `"role" directive`__ has been implemented.
3019 __ ../../ref/rst/directives.html#role
3022 Character Processing
3023 ====================
3025 Several people have suggested adding some form of character processing
3026 to reStructuredText:
3028 * Some sort of automated replacement of ASCII sequences:
3030   - ``--`` to em-dash (or ``--`` to en-dash, and ``---`` to em-dash).
3031   - Convert quotes to curly quote entities.  (Essentially impossible
3032     for HTML?  Unnecessary for TeX.)
3033   - Various forms of ``:-)`` to smiley icons.
3034   - ``"\ "`` to &nbsp;.  Problem with line-wrapping though: it could
3035     end up escaping the newline.
3036   - Escaped newlines to <BR>.
3037   - Escaped period or quote or dash as a disappearing catalyst to
3038     allow character-level inline markup?
3040 * XML-style character entities, such as "&copy;" for the copyright
3041   symbol.
3043 Docutils has no need of a character entity subsystem.  Supporting
3044 Unicode and text encodings, character entities should be directly
3045 represented in the text: a copyright symbol should be represented by
3046 the copyright symbol character.  If this is not possible in an
3047 authoring environment, a pre-processing stage can be added, or a table
3048 of substitution definitions can be devised.
3050 A "unicode" directive has been implemented to allow direct
3051 specification of esoteric characters.  In combination with the
3052 substitution construct, "include" files defining common sets of
3053 character entities can be defined and used.  `A set of character
3054 entity set definition files have been defined`__ (`tarball`__).
3055 There's also `a description and instructions for use`__.
3057 __ http://docutils.sf.net/tmp/charents/
3058 __ http://docutils.sf.net/tmp/charents.tgz
3059 __ http://docutils.sf.net/tmp/charents/README.html
3061 To allow for `character-level inline markup`_, a limited form of
3062 character processing has been added to the spec and parser: escaped
3063 whitespace characters are removed from the processed document.  Any
3064 further character processing will be of this functional type, rather
3065 than of the character-encoding type.
3067 .. _character-level inline markup:
3068    ../../ref/rst/restructuredtext.html#character-level-inline-markup
3070 * Directive idea::
3072       .. text-replace:: "pattern" "replacement"
3074   - Support Unicode "U+XXXX" codes.
3075   - Support regexps, perhaps with alternative "regexp-replace"
3076     directive.
3077   - Flags for regexps; ":flags:" option, or individuals.
3078   - Specifically, should the default be case-sensistive or
3079     -insensitive?
3082 Page Or Line Breaks
3083 ===================
3085 * Should ^L (or something else in reST) be defined to mean
3086   force/suggest page breaks in whatever output we have?
3088   A "break" or "page-break" directive would be easy to add.  A new
3089   doctree element would be required though (perhaps "break").  The
3090   final behavior would be up to the Writer.  The directive argument
3091   could be one of page/column/recto/verso for added flexibility.
3093   Currently ^L (Python's ``\f``) characters are treated as whitespace.
3094   They're converted to single spaces, actually, as are vertical tabs
3095   (^K, Python's ``\v``).  It would be possible to recognize form feeds
3096   as markup, but it requires some thought and discussion first.  Are
3097   there any downsides?  Many editing environments do not allow the
3098   insertion of control characters.  Will it cause any harm?  It would
3099   be useful as a shorthand for the directive.
3101   It's common practice to use ^L before Emacs "Local Variables"
3102   lists::
3104       ^L
3105       ..
3106          Local Variables:
3107          mode: indented-text
3108          indent-tabs-mode: nil
3109          sentence-end-double-space: t
3110          fill-column: 70
3111          End:
3113   These are already present in many PEPs and Docutils project
3114   documents.  From the Emacs manual (info):
3116       A "local variables list" goes near the end of the file, in the
3117       last page.  (It is often best to put it on a page by itself.)
3119   It would be unfortunate if this construct caused a final blank page
3120   to be generated (for those Writers that recognize the page breaks).
3121   We'll have to add a transform that looks for a "break" plus zero or
3122   more comments at the end of a document, and removes them.
3124   Probably a bad idea because there is no such thing as a page in a
3125   generic document format.
3127 * Could the "break" concept above be extended to inline forms?
3128   E.g. "^L" in the middle of a sentence could cause a line break.
3129   Only recognize it at the end of a line (i.e., ``\f\n``)?
3131   Or is formfeed inappropriate?  Perhaps vertical tab (``\v``), but
3132   even that's a stretch.  Can't use carriage returns, since they're
3133   commonly used for line endings.
3135   Probably a bad idea as well because we do not want to use control
3136   characters for well-readable and well-writable markup, and after all
3137   we have the line block syntax for line breaks.
3140 Superscript Markup
3141 ==================
3143 Add ``^superscript^`` inline markup?  The only common non-markup uses
3144 of "^" I can think of are as short hand for "superscript" itself and
3145 for describing control characters ("^C to cancel").  The former
3146 supports the proposed syntax, and it could be argued that the latter
3147 ought to be literal text anyhow (e.g. "``^C`` to cancel").
3149 However, superscripts are seldom needed, and new syntax would break
3150 existing documents.  When it's needed, the ``:superscript:``
3151 (``:sup:``) role can we used as well.
3154 Code Execution
3155 ==============
3157 Add the following directives?
3159 - "exec": Execute Python code & insert the results.  Call it
3160   "python" to allow for other languages?
3162 - "system": Execute an ``os.system()`` call, and insert the results
3163   (possibly as a literal block).  Definitely dangerous!  How to make
3164   it safe?  Perhaps such processing should be left outside of the
3165   document, in the user's production system (a makefile or a script or
3166   whatever).  Or, the directive could be disabled by default and only
3167   enabled with an explicit command-line option or config file setting.
3168   Even then, an interactive prompt may be useful, such as:
3170       The file.txt document you are processing contains a "system"
3171       directive requesting that the ``sudo rm -rf /`` command be
3172       executed.  Allow it to execute?  (y/N)
3174 - "eval": Evaluate an expression & insert the text.  At parse
3175   time or at substitution time?  Dangerous?  Perhaps limit to canned
3176   macros; see text.date_.
3178   .. _text.date: ../todo.html#text-date
3180 It's too dangerous (or too complicated in the case of "eval").  We do
3181 not want to have such things in the core.
3184 ``encoding`` Directive
3185 ======================
3187 Add an "encoding" directive to specify the character encoding of the
3188 input data?  Not a good idea for the following reasons:
3190 - When it sees the directive, the parser will already have read the
3191   input data, and encoding determination will already have been done.
3193 - If a file with an "encoding" directive is edited and saved with
3194   a different encoding, the directive may cause data corruption.
3197 Support for Annotations
3198 =======================
3200 Add an "annotation" role, as the equivalent of the HTML "title"
3201 attribute?  This is secondary information that may "pop up" when the
3202 pointer hovers over the main text.  A corresponding directive would be
3203 required to associate annotations with the original text (by name, or
3204 positionally as in anonymous targets?).
3206 There have not been many requests for such feature, though.  Also,
3207 cluttering WYSIWYG plaintext with annotations may not seem like a good
3208 idea, and there is no "tool tip" in formats other than HTML.
3211 ``term`` Role
3212 =============
3214 Add a "term" role for unfamiliar or specialized terminology?  Probably
3215 not; there is no real use case, and emphasis is enough for most cases.
3218 Object references
3219 =================
3221 We need syntax for `object references`_.
3223   - Parameterized substitutions?  For example::
3225         See |figure (figure name)| on |page (figure name)|.
3227         .. |figure (name)| figure-ref:: (name)
3228         .. |page (name)| page-ref:: (name)
3230     The result would be::
3232         See figure 3.11 on page 157.
3234     But this would require substitution directives to be processed at
3235     reference-time, not at definition-time as they are now.  Or,
3236     perhaps the directives could just leave ``pending`` elements
3237     behind, and the transforms do the work?  How to pass the data
3238     through? Too complicated. Use interpreted text roles.
3240 .. _object references:
3241    ../todo.html#object-numbering-and-object-references
3246    Local Variables:
3247    mode: indented-text
3248    indent-tabs-mode: nil
3249    sentence-end-double-space: t
3250    fill-column: 70
3251    End: