~ubuntu-branches/ubuntu/karmic/python-docutils/karmic

« back to all changes in this revision

Viewing changes to spec/rst/alternatives.txt

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

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