Chg: literal_block with fluxhleft outside of tables.
[docutils.git] / FAQ.txt
blobd097a0e1d2a7192b15f1e021f21851fd04c69896
1 =====================================
2  Docutils Frequently Asked Questions
3 =====================================
5 :Date: $Date$
6 :Web site: http://docutils.sourceforge.net/
7 :Copyright: This document has been placed in the public domain.
9 .. Please note that until there's a Q&A-specific construct available,
10    this FAQ will use section titles for questions.  Therefore
11    questions must fit on one line.  The title may be a summary of the
12    question, with the full question in the section body.
15 .. contents::
16 .. sectnum::
19 This is a work in progress.  Please feel free to ask questions and/or
20 provide answers; `send email`__ to the `Docutils-Users mailing
21 list`__.  Project members should feel free to edit the source text
22 file directly.
24 .. _let us know:
25 __ mailto:docutils-users@lists.sourceforge.net
26 __ http://lists.sourceforge.net/lists/listinfo/docutils-users
29 Docutils
30 ========
32 What is Docutils?
33 -----------------
35 Docutils_ is a system for processing plaintext documentation into
36 useful formats, such as HTML, XML, and TeX.  It supports multiple
37 types of input, such as standalone files (implemented), inline
38 documentation from Python modules and packages (under development),
39 `PEPs (Python Enhancement Proposals)`_ (implemented), and others as
40 discovered.
42 For an overview of the Docutils project implementation, see `PEP
43 258`_, "Docutils Design Specification".
45 Docutils is implemented in Python_.
47 .. _Docutils: http://docutils.sourceforge.net/
48 .. _PEPs (Python Enhancement Proposals):
49    http://www.python.org/peps/pep-0012.html
50 .. _PEP 258: spec/pep-0258.html
51 .. _Python: http://www.python.org/
54 Why is it called "Docutils"?
55 ----------------------------
57 Docutils is short for "Python Documentation Utilities".  The name
58 "Docutils" was inspired by "Distutils", the Python Distribution
59 Utilities architected by Greg Ward, a component of Python's standard
60 library.
62 The earliest known use of the term "docutils" in a Python context was
63 a `fleeting reference`__ in a message by Fred Drake on 1999-12-02 in
64 the Python Doc-SIG mailing list.  It was suggested `as a project
65 name`__ on 2000-11-27 on Doc-SIG, again by Fred Drake, in response to
66 a question from Tony "Tibs" Ibbs: "What do we want to *call* this
67 thing?".  This was shortly after David Goodger first `announced
68 reStructuredText`__ on Doc-SIG.
70 Tibs used the name "Docutils" for `his effort`__ "to document what the
71 Python docutils package should support, with a particular emphasis on
72 documentation strings".  Tibs joined the current project (and its
73 predecessors) and graciously donated the name.
75 For more history of reStructuredText and the Docutils project, see `An
76 Introduction to reStructuredText`_.
78 Please note that the name is "Docutils", not "DocUtils" or "Doc-Utils"
79 or any other variation.
81 .. _An Introduction to reStructuredText: spec/rst/introduction.html
82 __ http://mail.python.org/pipermail/doc-sig/1999-December/000878.html
83 __ http://mail.python.org/pipermail/doc-sig/2000-November/001252.html
84 __ http://mail.python.org/pipermail/doc-sig/2000-November/001239.html
85 __ http://homepage.ntlworld.com/tibsnjoan/docutils/STpy.html
88 Is there a GUI authoring environment for Docutils?
89 --------------------------------------------------
91 DocFactory_ is under development.  It uses wxPython and looks very
92 promising.
94 .. _DocFactory:
95    http://docutils.sf.net/sandbox/gschwant/docfactory/doc/
98 What is the status of the Docutils project?
99 -------------------------------------------
101 Although useful and relatively stable, Docutils is experimental code,
102 with APIs and architecture subject to change.
104 Our highest priority is to fix bugs as they are reported.  So the
105 latest code from CVS (or `development snapshots`_) is almost always
106 the most stable (bug-free) as well as the most featureful.
109 What is the Docutils project release policy?
110 --------------------------------------------
112 It ought to be "release early & often", but official releases are a
113 significant effort and aren't done that often.  We have
114 automatically-generated `development snapshots`_ which always contain
115 the latest code from CVS.  As the project matures, we may formalize on
116 a stable/development-branch scheme, but we're not using anything like
117 that yet.
119 If anyone would like to volunteer as a release coordinator, please
120 `contact the project coordinator`_.
122 .. _development snapshots:
123    http://docutils.sf.net/#development-snapshots
125 .. _contact the project coordinator:
126    mailto:goodger@python.org
129 reStructuredText
130 ================
132 What is reStructuredText?
133 -------------------------
135 reStructuredText_ is an easy-to-read, what-you-see-is-what-you-get
136 plaintext markup syntax and parser system.  The reStructuredText
137 parser is a component of Docutils_.  reStructuredText is a revision
138 and reinterpretation of the StructuredText_ and Setext_ lightweight
139 markup systems.
141 If you are reading this on the web, you can see for yourself.  `The
142 source for this FAQ <FAQ.txt>`_ is written in reStructuredText; open
143 it in another window and compare them side by side.
145 `A ReStructuredText Primer <docs/rst/quickstart.html>`_ and the `Quick
146 reStructuredText <docs/rst/quickref.html>`_ user reference are a good
147 place to start.  The `reStructuredText Markup Specification
148 <spec/rst/reStructuredText.html>`_ is a detailed technical
149 specification.
151 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
152 .. _StructuredText:
153    http://dev.zope.org/Members/jim/StructuredTextWiki/FrontPage/
154 .. _Setext: mirror/setext.html
157 Why is it called "reStructuredText"?
158 ------------------------------------
160 The name came from a combination of "StructuredText", one of
161 reStructuredText's predecessors, with "re": "revised", "reworked", and
162 "reinterpreted", and as in the ``re.py`` regular expression module.
163 For a detailed history of reStructuredText and the Docutils project,
164 see `An Introduction to reStructuredText`_.
167 What's the standard abbreviation for "reStructuredText"?
168 --------------------------------------------------------
170 "RST" and "ReST" (or "reST") are both acceptable.  Care should be
171 taken with capitalization, to avoid confusion with "REST__", an
172 acronym for "Representational State Transfer".
174 The abbreviations "reSTX" and "rSTX"/"rstx" should **not** be used;
175 they overemphasize reStructuredText's precedessor, Zope's
176 StructuredText.
178 __ http://www.xml.com/pub/a/2002/02/06/rest.html
181 What's the standard filename extension for a reStructuredText file?
182 -------------------------------------------------------------------
184 It's ".txt".  Some people would like to use ".rest" or ".rst" or
185 ".restx", but why bother?  ReStructuredText source files are meant to
186 be readable as plaintext, and most operating systems already associate
187 ".txt" with text files.  Using a specialized filename extension would
188 require that users alter their OS settings, which is something that
189 many users will not be willing or able to do.
192 Are there any reStructuredText editor extensions?
193 -------------------------------------------------
195 There is `some code under development for Emacs`__.
197 Extensions for other editors are welcome.
199 __ http://docutils.sf.net/tools/editors/emacs/
202 How can I indicate the document title?  Subtitle?
203 -------------------------------------------------
205 A uniquely-adorned section title at the beginning of a document is
206 treated specially, as the document title.  Similarly, a
207 uniquely-adorned section title immediately after the document title
208 becomes the document subtitle.  For example::
210     This is the Document Title
211     ==========================
213     This is the Document Subtitle
214     -----------------------------
216     Here's an ordinary paragraph.
218 Counterexample::
220     Here's an ordinary paragraph.
222     This is *not* a Document Title
223     ==============================
225     The "ordinary paragraph" above the section title
226     prevents it from becoming the document title.
228 Another counterexample::
230     This is not the Document Title,  because...
231     ===========================================
233     Here's an ordinary paragraph.
235     ... the title adornment is not unique
236     =====================================
238     Another ordinary paragraph.
241 How can I represent esoteric characters (e.g. character entities) in a document?
242 --------------------------------------------------------------------------------
244 For example, say you want an em-dash (XML character entity &mdash;,
245 Unicode character ``\u2014``) in your document: use a real em-dash.
246 Insert concrete characters (e.g. type a *real* em-dash) into your
247 input file, using whatever encoding suits your application, and tell
248 Docutils the input encoding.  Docutils uses Unicode internally, so the
249 em-dash character is a real em-dash internally.
251 ReStructuredText has no character entity subsystem; it doesn't know
252 anything about XML charents.  To Docutils, "&mdash;" in input text is
253 7 discrete characters; no interpretation happens.  When writing HTML,
254 the "&" is converted to "&amp;", so in the raw output you'd see
255 "&amp;mdash;".  There's no difference in interpretation for text
256 inside or outside inline literals or literal blocks -- there's no
257 character entity interpretation in either case.
259 If you can't use a Unicode-compatible encoding and must rely on 7-bit
260 ASCII, there is a workaround.  Files containing character entity set
261 substitution definitions using the "unicode" directive `are available
262 <tmp/charents/>`__ (`tarball <tmp/charents.tgz>`__).  A description
263 and instructions for use `are here <tmp/charents/README.html>`__.
264 Thanks to David Priest for the original idea.  Incorporating these
265 files into Docutils is on the `to-do list <spec/notes.html#to-do>`_.
267 If you insist on using XML-style charents, you'll have to implement a
268 pre-processing system to convert to UTF-8 or something.  That
269 introduces complications though; you can no longer *write* about
270 charents naturally; instead of writing "&mdash;" you'd have to write
271 "&amp;mdash;".
274 How can I generate backticks using a Scandinavian keyboard?
275 -----------------------------------------------------------
277 The use of backticks in reStructuredText is a bit awkward with
278 Scandinavian keyboards, where the backtick is a "dead" key.  To get
279 one ` character one must press SHIFT-` + SPACE.
281 Unfortunately, with all the variations out there, there's no way to
282 please everyone.  For Scandinavian programmers and technical writers,
283 this is not limited to reStructuredText but affects many languages and
284 environments.
286 Possible solutions include
288 * If you have to input a lot of backticks, simply type one in the
289   normal/awkward way, select it, copy and then paste the rest (CTRL-V
290   is a lot faster than SHIFT-` + SPACE).
292 * Use keyboard macros.
294 * Remap the keyboard.  The Scandinavian keyboard layout is awkward for
295   other programming/technical characters too; for example, []{}
296   etc. are a bit awkward compared to US keyboards.
298   According to Axel Kollmorgen,
300       Under Windows, you can use the `Microsoft Keyboard Layout Creator
301       <http://www.microsoft.com/globaldev/tools/msklc.mspx>`__ to easily
302       map the backtick key to a real backtick (no dead key). took me
303       five minutes to load my default (german) keyboard layout, untick
304       "Dead Key?" from the backtick key properties ("in all shift
305       states"), "build dll and setup package", install the generated
306       .msi, and add my custom keyboard layout via Control Panel >
307       Regional and Language Options > Languages > Details > Add
308       Keyboard layout (and setting it as default "when you start your
309       computer").
311 If anyone knows of other/better solutions, please `let us know`_.
314 Are there any tools for HTML/XML-to-reStructuredText?  (Round-tripping)
315 -----------------------------------------------------------------------
317 People have tossed the idea around, but little if any actual work has
318 ever been done.  There's no reason why reStructuredText should not be
319 round-trippable to/from XML; any technicalities which prevent
320 round-tripping would be considered bugs.  Whitespace would not be
321 identical, but paragraphs shouldn't suffer.  The tricky parts would be
322 the smaller details, like links and IDs and other bookkeeping.
324 For HTML, true round-tripping may not be possible.  Even adding lots
325 of extra "class" attributes may not be enough.  A "simple HTML" to RST
326 filter is possible -- for some definition of "simple HTML" -- but HTML
327 is used as dumb formatting so much that such a filter may not be
328 particularly useful.  No general-purpose filter exists.  An 80/20
329 approach should work though: build a tool that does 80% of the work
330 automatically, leaving the other 20% for manual tweaks.
333 Are there any Wikis that use reStructuredText syntax?
334 -----------------------------------------------------
336 There are several, with various degrees of completeness.  With no
337 implied endorsement or recommendation, and in no particular order:
339 * `Ian Bicking's experimental code <sandbox/ianb/wiki/WikiPage.py>`__
340 * `MoinMoin <http://moin.sf.net>`__ has some support; `here's a sample
341   <http://twistedmatrix.com/users/jh.twistd/moin/moin.cgi/RestSample>`__
342 * Zope-based `Zwiki <http://zwiki.org/>`__
343 * Zope3-based Zwiki (in the Zope 3 source tree as ``zope.products.zwiki``)
344 * `StikiWiki <http://mithrandr.moria.org/code/stikiwiki/>`__
346 Please `let us know`_ of any other reStructuredText Wikis.
348 The example application for the `Web Framework Shootout
349 <http://colorstudy.com/docs/shootout.html>`__ article is a Wiki using
350 reStructuredText.
353 Are there any Weblog (Blog) projects that use reStructuredText syntax?
354 ----------------------------------------------------------------------
356 With no implied endorsement or recommendation, and in no particular
357 order:
359 * `Python Desktop Server <http://pyds.muensterland.org/>`__
360 * `PyBloxsom <http://roughingit.subtlehints.net/pyblosxom>`__
361 * `rst2ht <http://www.rutherfurd.net/articles/rst-ht2html.html>`__
362 * `htmlnav <http://docutils.sourceforge.net/sandbox/gschwant/htmlnav/>`__
363 * `restblog <http://docutils.sourceforge.net/sandbox/mly/restblog/>`__
364 * `ReSTWeb <http://wingide.com/opensource/restweb>`__
365 * `Lino WebMan <http://lino.sourceforge.net/webman.html>`__
367 Please `let us know`_ of any other reStructuredText Blogs.
370 Can lists be indented without generating block quotes?
371 ------------------------------------------------------
373 Some people like to write lists with indentation, without intending a
374 block quote context, like this::
376     paragraph
378       * list item 1
379       * list item 2
381 There has been a lot of discussion about this, but there are some
382 issues that would need to be resolved before it could be implemented.
383 There is a summary of the issues and pointers to the discussions in
384 `the to-do list
385 <http://docutils.sf.net/spec/notes.html#indented-lists>`__.
388 Could the requirement for blank lines around lists be relaxed?
389 --------------------------------------------------------------
391 Short answer: no.
393 In reStructuredText, it would be impossible to unambigously mark up
394 and parse lists without blank lines before and after.  Deeply nested
395 lists may look ugly with so many blank lines, but it's a price we pay
396 for unambiguous markup.  Some other plaintext markup systems do not
397 require blank lines in nested lists, but they have to compromise
398 somehow, either accepting ambiguity or requiring extra complexity.
399 For example, `Epytext <http://epydoc.sf.net/epytext.html#list>`__ does
400 not require blank lines around lists, but it does require that lists
401 be indented and that ambiguous cases be escaped.
404 How can I include mathematical equations in documents?
405 ------------------------------------------------------
407 There is no elegant built-in way, yet.  There are several ideas, but
408 no obvious winner.  This issue requires a champion to solve the
409 technical and aesthetic issues and implement a generic solution.
410 Here's the `to-do list entry <spec/notes.html#math-markup>`__.
412 There are several quick & dirty ways to include equations in
413 documents:
415 * For HTML there is MathML but its rendering is still quite broken (or
416   absent) on most browsers.  An example of raw MathML is `here
417   <http://sf.net/mailarchive/message.php?msg_id=2177102>`__.
419 * If you use LaTeX output only, a simple way is to use the "raw"
420   directive; examples are `here
421   <http://article.gmane.org/gmane.text.docutils.devel/521>`__.
423 * Images of the equations can be used, typically generated by TeX.
424   Beni Cherniavsky has written some `preprocessing scripts`__ for
425   making inline TeX (for LaTeX and other [HTML etc.] output) math much
426   easier; `instructions here`__.
428   __ http://docutils.sourceforge.net/sandbox/cben/rolehack/
429   __ http://docutils.sourceforge.net/sandbox/cben/rolehack/README.html
431 * Here is an example of potential `itex math markup
432   <http://article.gmane.org/gmane.text.docutils.user/118>`__.
435 HTML Writer
436 ===========
438 What is the status of the HTML Writer?
439 --------------------------------------
441 The HTML Writer module, ``docutils/writers/html4css1.py``, is a
442 proof-of-concept reference implementation.  While it is a complete
443 implementation, some aspects of the HTML it produces may be
444 incompatible with older browsers or specialized applications (such as
445 web templating).  Alternate implementations are welcome.
448 What kind of HTML does it produce?
449 ----------------------------------
451 It produces XHTML compatible with the `HTML 4.01`_ and `XHTML 1.0`_
452 specifications.  A cascading style sheet ("default.css" by default) is
453 required for proper viewing with a modern graphical browser.  Correct
454 rendering of the HTML produced depends on the CSS support of the
455 browser.
457 .. _HTML 4.01: http://www.w3.org/TR/html4/
458 .. _XHTML 1.0: http://www.w3.org/TR/xhtml1/
461 What browsers are supported?
462 ----------------------------
464 No specific browser is targeted; all modern graphical browsers should
465 work.  Some older browsers, text-only browsers, and browsers without
466 full CSS support are known to produce inferior results.  Mozilla
467 (version 1.0 and up) and MS Internet Explorer (version 5.0 and up) are
468 known to give good results.  Reports of experiences with other
469 browsers are welcome.
472 Unexpected results from tools/html.py: H1, H1 instead of H1, H2.  Why?
473 ----------------------------------------------------------------------
475 Here's the question in full:
477     I have this text::
479         Heading 1
480         =========
482         All my life, I wanted to be H1.
484         Heading 1.1
485         -----------
487         But along came H1, and so shouldn't I be H2?
488         No!  I'm H1!
490         Heading 1.1.1
491         *************
493         Yeah, imagine me, I'm stuck at H3!  No?!?
495     When I run it through tools/html.py, I get unexpected results
496     (below).  I was expecting H1, H2, then H3; instead, I get H1, H1,
497     H2::
499         ...
500         <html lang="en">
501         <head>
502         ...
503         <title>Heading 1</title>
504         <link rel="stylesheet" href="default.css" type="text/css" />
505         </head>
506         <body>
507         <div class="document" id="heading-1">
508         <h1 class="title">Heading 1</h1>                <-- first H1
509         <p>All my life, I wanted to be H1.</p>
510         <div class="section" id="heading-1-1">
511         <h1><a name="heading-1-1">Heading 1.1</a></h1>        <-- H1
512         <p>But along came H1, and so now I must be H2.</p>
513         <div class="section" id="heading-1-1-1">
514         <h2><a name="heading-1-1-1">Heading 1.1.1</a></h2>
515         <p>Yeah, imagine me, I'm stuck at H3!</p>
516         ...
518     What gives?
520 Check the "class" attribute on the H1 tags, and you will see a
521 difference.  The first H1 is actually ``<h1 class="title">``; this is
522 the document title, and the default stylesheet renders it centered.
523 There can also be an ``<h2 class="subtitle">`` for the document
524 subtitle.
526 If there's only one highest-level section title at the beginning of a
527 document, it is treated specially, as the document title.  (Similarly, a
528 lone second-highest-level section title may become the document
529 subtitle.)  See `How can I indicate the document title?  Subtitle?`_ for
530 details.  Rather than use a plain H1 for the document title, we use ``<h1
531 class="title">`` so that we can use H1 again within the document.  Why
532 do we do this?  HTML only has H1-H6, so by making H1 do double duty, we
533 effectively reserve these tags to provide 6 levels of heading beyond the
534 single document title.
536 HTML is being used for dumb formatting for nothing but final display.
537 A stylesheet *is required*, and one is provided:
538 tools/stylesheets/default.css.  Of course, you're welcome to roll your
539 own.  The default stylesheet provides rules to format ``<h1
540 class="title">`` and ``<h2 class="subtitle">`` differently from
541 ordinary ``<h1>`` and ``<h2>``::
543     h1.title {
544       text-align: center }
546     h2.subtitle {
547       text-align: center }
549 If you don't want the top section heading to be interpreted as a
550 title at all, disable the `doctitle_xform`_ setting
551 (``--no-doc-title`` option).  This will interpret your document
552 differently from the standard settings, which might not be a good
553 idea.  If you don't like the reuse of the H1 in the HTML output, you
554 can tweak the `initial_header_level`_ setting
555 (``--initial-header-level`` option) -- but unless you match its value
556 to your specific document, you might end up with bad HTML (e.g. H3
557 without H2).
559 .. _doctitle_xform: docs/config.html#doctitle-xform
560 .. _initial_header_level: docs/config.html#initial-header-level
562 (Thanks to Mark McEahern for the question and much of the answer.)
565 Why do enumerated lists only use numbers (no letters or roman numerals)?
566 ------------------------------------------------------------------------
568 The rendering of enumerators (the numbers or letters acting as list
569 markers) is completely governed by the stylesheet, so either the
570 browser can't find the stylesheet (try using the "--embed-stylesheet"
571 option), or the browser can't understand it (try a recent Mozilla or
572 MSIE).
575 Python Source Reader
576 ====================
578 Can I use Docutils for Python auto-documentation?
579 -------------------------------------------------
581 Yes, in conjunction with other projects.
583 Docstring extraction functionality from within Docutils is still under
584 development.  There is most of a source code parsing module in
585 docutils/readers/python/moduleparser.py.  We do plan to finish it
586 eventually.  Ian Bicking wrote an initial front end for the
587 moduleparser.py module, in sandbox/ianb/extractor/extractor.py.  Ian
588 also did some work on the Python Source Reader
589 (docutils.readers.python) component at PyCon DC 2004.
591 Version 2.0 of Ed Loper's `Epydoc <http://epydoc.sourceforge.net/>`_
592 supports reStructuredText-format docstrings for HTML output.  Docutils
593 0.3 or newer is required.  Development of a Docutils-specific
594 auto-documentation tool will continue.  Epydoc works by importing
595 Python modules to be documented, whereas the Docutils-specific tool,
596 described above, will parse modules without importing them (as with
597 `HappyDoc <http://happydoc.sourceforge.net/>`_, which doesn't support
598 reStructuredText).
600 The advantages of parsing over importing are security and flexibility;
601 the disadvantage is complexity/difficulty.
603 * Security: untrusted code that shouldn't be executed can be parsed;
604   importing a module executes its top-level code.
605 * Flexibility: comments and unofficial docstrings (those not supported
606   by Python syntax) can only be processed by parsing.
607 * Complexity/difficulty: it's a lot harder to parse and analyze a
608   module than it is to ``import`` and analyze one.
610 For more details, please see "Docstring Extraction Rules" in `PEP
611 258`_, item 3 ("How").
614 Miscellaneous
615 =============
617 Is the Docutils document model based on any existing XML models?
618 ----------------------------------------------------------------
620 Not directly, no.  It borrows bits from DocBook, HTML, and others.  I
621 (David Goodger) have designed several document models over the years,
622 and have my own biases.  The Docutils document model is designed for
623 simplicity and extensibility, and has been influenced by the needs of
624 the reStructuredText markup.