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