Debian Codegraph @

test/expensive_benchmarks/docutils_data/docs/dev/rst/alternatives.txt

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