added history entries for changed transition handling
[docutils.git] / FAQ.txt
blobbbbe20db5a2e43c6e52ee9aec4b605d2644d52c3
1 ===========================================
2  Docutils FAQ (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 list`__
21 [1]_.  Project members should feel free to edit the source text file
22 directly.
24 .. [1] Due to overwhelming amounts of spam, the
25    docutils-users@lists.sourceforge.net mailing list has been set up
26    for subscriber posting only.  Non-subscribers who post to
27    docutils-users will receive a message with "Subject: Your message
28    to Docutils-users awaits moderator approval".  Legitimate messages
29    are accepted and posted as soon as possible (a list administrator
30    must verify the message manually).  If you'd like to subscribe to
31    docutils-users, please visit
32    <http://lists.sourceforge.net/lists/listinfo/docutils-users>.
34 .. _let us know:
35 __ mailto:docutils-users@lists.sourceforge.net
36 __ http://lists.sourceforge.net/lists/listinfo/docutils-users
39 Docutils
40 ========
42 What is Docutils?
43 -----------------
45 Docutils_ is a system for processing plaintext documentation into
46 useful formats, such as HTML, XML, and LaTeX.  It supports multiple
47 types of input, such as standalone files (implemented), inline
48 documentation from Python modules and packages (under development),
49 `PEPs (Python Enhancement Proposals)`_ (implemented), and others as
50 discovered.
52 For an overview of the Docutils project implementation, see `PEP
53 258`_, "Docutils Design Specification".
55 Docutils is implemented in Python_.
57 .. _Docutils: http://docutils.sourceforge.net/
58 .. _PEPs (Python Enhancement Proposals):
59    http://www.python.org/peps/pep-0012.html
60 .. _PEP 258: http://www.python.org/peps/pep-0258.html
61 .. _Python: http://www.python.org/
64 Why is it called "Docutils"?
65 ----------------------------
67 Docutils is short for "Python Documentation Utilities".  The name
68 "Docutils" was inspired by "Distutils", the Python Distribution
69 Utilities architected by Greg Ward, a component of Python's standard
70 library.
72 The earliest known use of the term "docutils" in a Python context was
73 a `fleeting reference`__ in a message by Fred Drake on 1999-12-02 in
74 the Python Doc-SIG mailing list.  It was suggested `as a project
75 name`__ on 2000-11-27 on Doc-SIG, again by Fred Drake, in response to
76 a question from Tony "Tibs" Ibbs: "What do we want to *call* this
77 thing?".  This was shortly after David Goodger first `announced
78 reStructuredText`__ on Doc-SIG.
80 Tibs used the name "Docutils" for `his effort`__ "to document what the
81 Python docutils package should support, with a particular emphasis on
82 documentation strings".  Tibs joined the current project (and its
83 predecessors) and graciously donated the name.
85 For more history of reStructuredText and the Docutils project, see `An
86 Introduction to reStructuredText`_.
88 Please note that the name is "Docutils", not "DocUtils" or "Doc-Utils"
89 or any other variation.
91 .. _An Introduction to reStructuredText:
92    http://docutils.sourceforge.net/docs/ref/rst/introduction.html
93 __ http://mail.python.org/pipermail/doc-sig/1999-December/000878.html
94 __ http://mail.python.org/pipermail/doc-sig/2000-November/001252.html
95 __ http://mail.python.org/pipermail/doc-sig/2000-November/001239.html
96 __ http://homepage.ntlworld.com/tibsnjoan/docutils/STpy.html
99 Is there a GUI authoring environment for Docutils?
100 --------------------------------------------------
102 DocFactory_ is under development.  It uses wxPython and looks very
103 promising.
105 .. _DocFactory:
106    http://docutils.sf.net/sandbox/gschwant/docfactory/doc/
109 What is the status of the Docutils project?
110 -------------------------------------------
112 Although useful and relatively stable, Docutils is experimental code,
113 with APIs and architecture subject to change.
115 Our highest priority is to fix bugs as they are reported.  So the
116 latest code from CVS (or `development snapshots`_) is almost always
117 the most stable (bug-free) as well as the most featureful.
120 What is the Docutils project release policy?
121 --------------------------------------------
123 It ought to be "release early & often", but official releases are a
124 significant effort and aren't done that often.  We have
125 automatically-generated `development snapshots`_ which always contain
126 the latest code from CVS.  As the project matures, we may formalize on
127 a stable/development-branch scheme, but we're not using anything like
128 that yet.
130 .. _development snapshots:
131    http://docutils.sourceforge.net/#development-snapshots
134 reStructuredText
135 ================
137 What is reStructuredText?
138 -------------------------
140 reStructuredText_ is an easy-to-read, what-you-see-is-what-you-get
141 plaintext markup syntax and parser system.  The reStructuredText
142 parser is a component of Docutils_.  reStructuredText is a revision
143 and reinterpretation of the StructuredText_ and Setext_ lightweight
144 markup systems.
146 If you are reading this on the web, you can see for yourself.  `The
147 source for this FAQ <FAQ.txt>`_ is written in reStructuredText; open
148 it in another window and compare them side by side.
150 `A ReStructuredText Primer`_ and the `Quick reStructuredText`_ user
151 reference are a good place to start.  The `reStructuredText Markup
152 Specification`_ is a detailed technical specification.
154 .. _A ReStructuredText Primer:
155    http://docutils.sourceforge.net/docs/user/rst/quickstart.html
156 .. _Quick reStructuredText:
157    http://docutils.sourceforge.net/docs/user/rst/quickref.html
158 .. _reStructuredText Markup Specification:
159    http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html
160 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
161 .. _StructuredText:
162    http://dev.zope.org/Members/jim/StructuredTextWiki/FrontPage/
163 .. _Setext: http://docutils.sourceforge.net/mirror/setext.html
166 Why is it called "reStructuredText"?
167 ------------------------------------
169 The name came from a combination of "StructuredText", one of
170 reStructuredText's predecessors, with "re": "revised", "reworked", and
171 "reinterpreted", and as in the ``re.py`` regular expression module.
172 For a detailed history of reStructuredText and the Docutils project,
173 see `An Introduction to reStructuredText`_.
176 What's the standard abbreviation for "reStructuredText"?
177 --------------------------------------------------------
179 "RST" and "ReST" (or "reST") are both acceptable.  Care should be
180 taken with capitalization, to avoid confusion with "REST__", an
181 acronym for "Representational State Transfer".
183 The abbreviations "reSTX" and "rSTX"/"rstx" should **not** be used;
184 they overemphasize reStructuredText's precedessor, Zope's
185 StructuredText.
187 __ http://www.xml.com/pub/a/2002/02/06/rest.html
190 What's the standard filename extension for a reStructuredText file?
191 -------------------------------------------------------------------
193 It's ".txt".  Some people would like to use ".rest" or ".rst" or
194 ".restx", but why bother?  ReStructuredText source files are meant to
195 be readable as plaintext, and most operating systems already associate
196 ".txt" with text files.  Using a specialized filename extension would
197 require that users alter their OS settings, which is something that
198 many users will not be willing or able to do.
201 Are there any reStructuredText editor extensions?
202 -------------------------------------------------
204 See `Editor Support for reStructuredText`__.
206 __ http://docutils.sf.net/tools/editors/README.html
209 How can I indicate the document title?  Subtitle?
210 -------------------------------------------------
212 A uniquely-adorned section title at the beginning of a document is
213 treated specially, as the document title.  Similarly, a
214 uniquely-adorned section title immediately after the document title
215 becomes the document subtitle.  For example::
217     This is the Document Title
218     ==========================
220     This is the Document Subtitle
221     -----------------------------
223     Here's an ordinary paragraph.
225 Counterexample::
227     Here's an ordinary paragraph.
229     This is *not* a Document Title
230     ==============================
232     The "ordinary paragraph" above the section title
233     prevents it from becoming the document title.
235 Another counterexample::
237     This is not the Document Title,  because...
238     ===========================================
240     Here's an ordinary paragraph.
242     ... the title adornment is not unique
243     =====================================
245     Another ordinary paragraph.
248 How can I represent esoteric characters (e.g. character entities) in a document?
249 --------------------------------------------------------------------------------
251 For example, say you want an em-dash (XML character entity &mdash;,
252 Unicode character ``\u2014``) in your document: use a real em-dash.
253 Insert concrete characters (e.g. type a *real* em-dash) into your
254 input file, using whatever encoding suits your application, and tell
255 Docutils the input encoding.  Docutils uses Unicode internally, so the
256 em-dash character is a real em-dash internally.
258 Emacs users should refer to the `Emacs Support for reStructuredText`__
259 document.  Tips for other editors are welcome.
261 __ http://docutils.sourceforge.net/tools/editors/emacs/README.html
263 ReStructuredText has no character entity subsystem; it doesn't know
264 anything about XML charents.  To Docutils, "&mdash;" in input text is
265 7 discrete characters; no interpretation happens.  When writing HTML,
266 the "&" is converted to "&amp;", so in the raw output you'd see
267 "&amp;mdash;".  There's no difference in interpretation for text
268 inside or outside inline literals or literal blocks -- there's no
269 character entity interpretation in either case.
271 If you can't use a Unicode-compatible encoding and must rely on 7-bit
272 ASCII, there is a workaround.  Files containing character entity set
273 substitution definitions using the "unicode" directive `are
274 available`_ (tarball_).  Please read the `description and
275 instructions`_ for use.  Thanks to David Priest for the original idea.
276 Incorporating these files into Docutils is on the `to-do list`_.
278 .. _are available: http://docutils.sourceforge.net/tmp/charents/
279 .. _tarball: http://docutils.sourceforge.net/tmp/charents.tgz
280 .. _description and instructions:
281    http://docutils.sourceforge.net/tmp/charents/README.html
282 .. _to-do list: http://docutils.sourceforge.net/docs/dev/todo.html
283    
284 If you insist on using XML-style charents, you'll have to implement a
285 pre-processing system to convert to UTF-8 or something.  That
286 introduces complications though; you can no longer *write* about
287 charents naturally; instead of writing "&mdash;" you'd have to write
288 "&amp;mdash;".
291 How can I generate backticks using a Scandinavian keyboard?
292 -----------------------------------------------------------
294 The use of backticks in reStructuredText is a bit awkward with
295 Scandinavian keyboards, where the backtick is a "dead" key.  To get
296 one ` character one must press SHIFT-` + SPACE.
298 Unfortunately, with all the variations out there, there's no way to
299 please everyone.  For Scandinavian programmers and technical writers,
300 this is not limited to reStructuredText but affects many languages and
301 environments.
303 Possible solutions include
305 * If you have to input a lot of backticks, simply type one in the
306   normal/awkward way, select it, copy and then paste the rest (CTRL-V
307   is a lot faster than SHIFT-` + SPACE).
309 * Use keyboard macros.
311 * Remap the keyboard.  The Scandinavian keyboard layout is awkward for
312   other programming/technical characters too; for example, []{}
313   etc. are a bit awkward compared to US keyboards.
315   According to Axel Kollmorgen,
317       Under Windows, you can use the `Microsoft Keyboard Layout Creator
318       <http://www.microsoft.com/globaldev/tools/msklc.mspx>`__ to easily
319       map the backtick key to a real backtick (no dead key). took me
320       five minutes to load my default (german) keyboard layout, untick
321       "Dead Key?" from the backtick key properties ("in all shift
322       states"), "build dll and setup package", install the generated
323       .msi, and add my custom keyboard layout via Control Panel >
324       Regional and Language Options > Languages > Details > Add
325       Keyboard layout (and setting it as default "when you start your
326       computer").
328 * Use a virtual/screen keyboard or character palette, such as:
330   - `Web-based keyboards <http://keyboard.lab.co.il/>`__ (IE only
331     unfortunately).
332   - Windows: `Click-N-Type <http://www.lakefolks.org/cnt/>`__.
333   - Mac OS X: the Character Palette can store a set of favorite
334     characters for easy input.  Open System Preferences,
335     International, Input Menu tab, enable "Show input menu in menu
336     bar", and be sure that Character Palette is enabled in the list.
338   Other options are welcome.
340 If anyone knows of other/better solutions, please `let us know`_.
343 Are there any tools for HTML/XML-to-reStructuredText?  (Round-tripping)
344 -----------------------------------------------------------------------
346 People have tossed the idea around, but little if any actual work has
347 ever been done.  There's no reason why reStructuredText should not be
348 round-trippable to/from XML; any technicalities which prevent
349 round-tripping would be considered bugs.  Whitespace would not be
350 identical, but paragraphs shouldn't suffer.  The tricky parts would be
351 the smaller details, like links and IDs and other bookkeeping.
353 For HTML, true round-tripping may not be possible.  Even adding lots
354 of extra "class" attributes may not be enough.  A "simple HTML" to RST
355 filter is possible -- for some definition of "simple HTML" -- but HTML
356 is used as dumb formatting so much that such a filter may not be
357 particularly useful.  No general-purpose filter exists.  An 80/20
358 approach should work though: build a tool that does 80% of the work
359 automatically, leaving the other 20% for manual tweaks.
362 Are there any Wikis that use reStructuredText syntax?
363 -----------------------------------------------------
365 There are several, with various degrees of completeness.  With no
366 implied endorsement or recommendation, and in no particular order:
368 * `Ian Bicking's experimental code
369   <http://docutils.sf.net/sandbox/ianb/wiki/WikiPage.py>`__
370 * `MoinMoin <http://moin.sf.net>`__ has some support; `here's a sample
371   <http://twistedmatrix.com/users/jh.twistd/moin/moin.cgi/RestSample>`__
372 * Zope-based `Zwiki <http://zwiki.org/>`__
373 * Zope3-based Zwiki (in the Zope 3 source tree as ``zope.products.zwiki``)
374 * `StikiWiki <http://mithrandr.moria.org/code/stikiwiki/>`__
375 * `Trac <http://projects.edgewall.com/trac/>`__ `supports using reStructuredText
376   <http://projects.edgewall.com/trac/wiki/WikiRestructuredText>`__ as an
377   alternative to wiki markup. This includes support for `TracLinks
378   <http://projects.edgewall.com/trac/wiki/TracLinks>`__ from within RST
379   text via a custom RST reference-directive or, even easier, an interpreted text
380   role 'trac'
381 * `Vogontia <http://www.ososo.de/vogontia/>`__, a Wiki-like FAQ system
383 Please `let us know`_ of any other reStructuredText Wikis.
385 The example application for the `Web Framework Shootout
386 <http://colorstudy.com/docs/shootout.html>`__ article is a Wiki using
387 reStructuredText.
390 Are there any Weblog (Blog) projects that use reStructuredText syntax?
391 ----------------------------------------------------------------------
393 With no implied endorsement or recommendation, and in no particular
394 order:
396 * `Python Desktop Server <http://pyds.muensterland.org/>`__
397 * `PyBloxsom <http://roughingit.subtlehints.net/pyblosxom/>`__
398 * `rst2ht <http://www.rutherfurd.net/articles/rst-ht2html.html>`__
399 * `htmlnav <http://docutils.sourceforge.net/sandbox/gschwant/htmlnav/>`__
400 * `restblog <http://docutils.sourceforge.net/sandbox/mly/restblog/>`__
401 * `ReSTWeb <http://wingide.com/opensource/restweb>`__
402 * `Lino WebMan <http://lino.sourceforge.net/webman.html>`__
404 Please `let us know`_ of any other reStructuredText Blogs.
407 Can lists be indented without generating block quotes?
408 ------------------------------------------------------
410 Some people like to write lists with indentation, without intending a
411 block quote context, like this::
413     paragraph
415       * list item 1
416       * list item 2
418 There has been a lot of discussion about this, but there are some
419 issues that would need to be resolved before it could be implemented.
420 There is a summary of the issues and pointers to the discussions in
421 `the to-do list`__.
423 __ http://docutils.sourceforge.net/docs/dev/todo.html#indented-lists
426 Could the requirement for blank lines around lists be relaxed?
427 --------------------------------------------------------------
429 Short answer: no.
431 In reStructuredText, it would be impossible to unambigously mark up
432 and parse lists without blank lines before and after.  Deeply nested
433 lists may look ugly with so many blank lines, but it's a price we pay
434 for unambiguous markup.  Some other plaintext markup systems do not
435 require blank lines in nested lists, but they have to compromise
436 somehow, either accepting ambiguity or requiring extra complexity.
437 For example, `Epytext <http://epydoc.sf.net/epytext.html#list>`__ does
438 not require blank lines around lists, but it does require that lists
439 be indented and that ambiguous cases be escaped.
442 How can I include mathematical equations in documents?
443 ------------------------------------------------------
445 There is no elegant built-in way, yet.  There are several ideas, but
446 no obvious winner.  This issue requires a champion to solve the
447 technical and aesthetic issues and implement a generic solution.
448 Here's the `to-do list entry`__.
450 __ http://docutils.sourceforge.net/docs/dev/todo.html#math-markup
452 There are several quick & dirty ways to include equations in
453 documents:
455 * For HTML there is MathML but its rendering is still quite broken (or
456   absent) on most browsers.  See an `example of raw MathML
457   <http://sf.net/mailarchive/message.php?msg_id=2177102>`__.
459 * If you use LaTeX output only, a simple way is to use the "raw"
460   directive; examples are `here
461   <http://article.gmane.org/gmane.text.docutils.devel/521>`__.
463 * Images of the equations can be used, typically generated by TeX.
464   Beni Cherniavsky has written some `preprocessing scripts`__ for
465   making inline TeX (for LaTeX and other [HTML etc.] output) math much
466   easier; `instructions here`__.
468   __ http://docutils.sourceforge.net/sandbox/cben/rolehack/
469   __ http://docutils.sourceforge.net/sandbox/cben/rolehack/README.html
471 * Here is an example of potential `itex math markup
472   <http://article.gmane.org/gmane.text.docutils.user/118>`__.
475 Is nested inline markup possible?
476 ---------------------------------
478 Not currently, no.  It's on the `to-do list`__ (`details here`__), and
479 hopefully will be part of the reStructuredText parser soon.  At that
480 time, markup like this will become possible::
482     Here is some *emphasized text containing a `hyperlink`_ and
483     ``inline literals``*.
485 __ http://docutils.sf.net/docs/dev/todo.html#nested-inline-markup
486 __ http://docutils.sf.net/docs/dev/rst/alternatives.html#nested-inline-markup
488 There are workarounds, but they are either convoluted or ugly or both.
489 They are not recommended.
491 * Inline markup can be combined with hyperlinks using `substitution
492   definitions`__ and references__ with the `"replace" directive`__.
493   For example::
495       Here is an |emphasized hyperlink|_.
497       .. |emphasized hyperlink| replace:: *emphasized hyperlink*
498       .. _emphasized hyperlink: http://example.org
500   It is not possible for just a portion of the replacement text to be
501   a hyperlink; it's the entire replacement text or nothing.
503   __ http://docutils.sf.net/docs/ref/rst/restructuredtext.html#substitution-definitions
504   __ http://docutils.sf.net/docs/ref/rst/restructuredtext.html#substitution-references
505   __ http://docutils.sf.net/docs/ref/rst/directives.html#replace
507 * The `"raw" directive`__ can be used to insert raw HTML into HTML
508   output::
510       Here is some |stuff|.
512       .. |stuff| raw:: html
514          <em>emphasized text containing a
515          <a href="http://example.org">hyperlink</a> and
516          <tt>inline literals</tt></em>
518   Raw LaTeX is supported for LaTeX output, etc.
520   __ http://docutils.sf.net/docs/ref/rst/directives.html#raw
523 How to indicate a line break or a significant newline?
524 ------------------------------------------------------
526 The `"line-block" directive`__ is designed for address blocks, verse,
527 and other cases where line breaks are significant and must be
528 preserved.  Unlike literal blocks, the typeface is not changed, and
529 inline markup is recognized.  For example::
531     .. line-block::
533        A one, two, a one two three four
535        Half a bee, philosophically,
536            must, *ipso facto*, half not be.
537        But half the bee has got to be,
538            *vis a vis* its entity.  D'you see?
540        But can a bee be said to be
541            or not to be an entire bee,
542                when half the bee is not a bee,
543                    due to some ancient injury?
545        Singing...
547 __ http://docutils.sf.net/docs/ref/rst/directives.html#line-block
549 In the near future, we will be implementing `new syntax for line
550 blocks`__, like this::
552     | Lend us a couple of bob till Thursday.
553     | I'm absolutely skint.
554     | But I'm expecting a postal order and I can pay you back
555       as soon as it comes.
556     | Love, Ewan.
558 __ http://docutils.sf.net/docs/dev/rst/alternatives.html#syntax-for-line-blocks
560 Here's a workaround for manually inserting explicit line breaks in
561 HTML output::
563     .. |br| raw:: html
565        <br />
567     I want to break this line here: |br| this is after the break.
569     If the extra whitespace bothers you, |br|\ backslash-escape it.
572 A URL containing asterisks doesn't work.  What to do?
573 -----------------------------------------------------
575 Asterisks are valid URL characters (see :RFC:`2396`), sometimes used
576 in URLs.  For example::
578     http://cvs.example.org/viewcvs.py/*checkout*/module/file
580 Unfortunately, the parser thinks the asterisks are indicating
581 emphasis.  The slashes serve as delineating punctuation, allowing the
582 asterisks to be recognized as markup.  The example above is separated
583 by the parser into a truncated URL, an emphasized word, and some
584 regular text::
586     http://cvs.example.org/viewcvs.py/
587     *checkout*
588     /module/file
590 To turn off markup recognition, use a backslash to escape at least the
591 first asterisk, like this::
593     http://cvs.example.org/viewcvs.py/\*checkout*/module/file
595 Escaping the second asterisk doesn't hurt, but it isn't necessary.
598 How can I make a literal block with *some* formatting?
599 ------------------------------------------------------
601 Use the `parsed-literal`_ directive.
603 .. _parsed-literal: docs/ref/rst/directives.html#parsed-literal
605 Scenario: a document contains some source code, which calls for a
606 literal block to preserve linebreaks and whitespace.  But part of the
607 source code should be formatted, for example as emphasis or as a
608 hyperlink.  This calls for a *parsed* literal block::
610     .. parsed-literal::
612        print "Hello world!"  # *tricky* code [1]_
614 The emphasis (``*tricky*``) and footnote reference (``[1]_``) will be
615 parsed.
618 Can reStructuredText be used for web or generic templating?
619 -----------------------------------------------------------
621 Docutils and reStructuredText can be used with or as a component of a
622 templating system, but they do not themselves include templating
623 functionality.  Templating should simply be left to dedicated
624 templating systems.  Users can choose a templating system to apply to
625 their reStructuredText documents as best serves their interests.
627 There are many good templating systems for Python (ht2html_, YAPTU_,
628 Quixote_'s PTL, Cheetah_, etc.; see this non-exhaustive list of `some
629 other templating systems`_), and many more for other languages, each
630 with different approaches.  We invite you to try several and find one
631 you like.  If you adapt it to use Docutils/reStructuredText, please
632 consider contributing the code to Docutils or `let us know`_ and we'll
633 keep a list here.
635 .. _ht2html: http://ht2html.sourceforge.net/
636 .. _YAPTU:
637    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52305
638 .. _Quixote: http://www.mems-exchange.org/software/quixote/
639 .. _Cheetah: http://www.cheetahtemplate.org/
640 .. _some other templating systems:
641    http://webware.sourceforge.net/Papers/Templates/
644 HTML Writer
645 ===========
647 What is the status of the HTML Writer?
648 --------------------------------------
650 The HTML Writer module, ``docutils/writers/html4css1.py``, is a
651 proof-of-concept reference implementation.  While it is a complete
652 implementation, some aspects of the HTML it produces may be
653 incompatible with older browsers or specialized applications (such as
654 web templating).  Alternate implementations are welcome.
657 What kind of HTML does it produce?
658 ----------------------------------
660 It produces XHTML compatible with the `HTML 4.01`_ and `XHTML 1.0`_
661 specifications (within reason; there are some incompatibilities
662 between the specs).  A cascading style sheet ("default.css" by
663 default) is required for proper viewing with a modern graphical
664 browser.  Correct rendering of the HTML produced depends on the CSS
665 support of the browser.
667 .. _HTML 4.01: http://www.w3.org/TR/html4/
668 .. _XHTML 1.0: http://www.w3.org/TR/xhtml1/
671 What browsers are supported?
672 ----------------------------
674 No specific browser is targeted; all modern graphical browsers should
675 work.  Some older browsers, text-only browsers, and browsers without
676 full CSS support are known to produce inferior results.  Mozilla
677 (version 1.0 and up) and MS Internet Explorer (version 5.0 and up) are
678 known to give good results.  Reports of experiences with other
679 browsers are welcome.
682 Unexpected results from tools/rst2html.py: H1, H1 instead of H1, H2.  Why?
683 --------------------------------------------------------------------------
685 Here's the question in full:
687     I have this text::
689         Heading 1
690         =========
692         All my life, I wanted to be H1.
694         Heading 1.1
695         -----------
697         But along came H1, and so shouldn't I be H2?
698         No!  I'm H1!
700         Heading 1.1.1
701         *************
703         Yeah, imagine me, I'm stuck at H3!  No?!?
705     When I run it through tools/rst2html.py, I get unexpected results
706     (below).  I was expecting H1, H2, then H3; instead, I get H1, H1,
707     H2::
709         ...
710         <html lang="en">
711         <head>
712         ...
713         <title>Heading 1</title>
714         <link rel="stylesheet" href="default.css" type="text/css" />
715         </head>
716         <body>
717         <div class="document" id="heading-1">
718         <h1 class="title">Heading 1</h1>                <-- first H1
719         <p>All my life, I wanted to be H1.</p>
720         <div class="section" id="heading-1-1">
721         <h1><a name="heading-1-1">Heading 1.1</a></h1>        <-- H1
722         <p>But along came H1, and so now I must be H2.</p>
723         <div class="section" id="heading-1-1-1">
724         <h2><a name="heading-1-1-1">Heading 1.1.1</a></h2>
725         <p>Yeah, imagine me, I'm stuck at H3!</p>
726         ...
728     What gives?
730 Check the "class" attribute on the H1 tags, and you will see a
731 difference.  The first H1 is actually ``<h1 class="title">``; this is
732 the document title, and the default stylesheet renders it centered.
733 There can also be an ``<h2 class="subtitle">`` for the document
734 subtitle.
736 If there's only one highest-level section title at the beginning of a
737 document, it is treated specially, as the document title.  (Similarly, a
738 lone second-highest-level section title may become the document
739 subtitle.)  See `How can I indicate the document title?  Subtitle?`_ for
740 details.  Rather than use a plain H1 for the document title, we use ``<h1
741 class="title">`` so that we can use H1 again within the document.  Why
742 do we do this?  HTML only has H1-H6, so by making H1 do double duty, we
743 effectively reserve these tags to provide 6 levels of heading beyond the
744 single document title.
746 HTML is being used for dumb formatting for nothing but final display.
747 A stylesheet *is required*, and one is provided:
748 tools/stylesheets/default.css.  Of course, you're welcome to roll your
749 own.  The default stylesheet provides rules to format ``<h1
750 class="title">`` and ``<h2 class="subtitle">`` differently from
751 ordinary ``<h1>`` and ``<h2>``::
753     h1.title {
754       text-align: center }
756     h2.subtitle {
757       text-align: center }
759 If you don't want the top section heading to be interpreted as a
760 title at all, disable the `doctitle_xform`_ setting
761 (``--no-doc-title`` option).  This will interpret your document
762 differently from the standard settings, which might not be a good
763 idea.  If you don't like the reuse of the H1 in the HTML output, you
764 can tweak the `initial_header_level`_ setting
765 (``--initial-header-level`` option) -- but unless you match its value
766 to your specific document, you might end up with bad HTML (e.g. H3
767 without H2).
769 .. _doctitle_xform:
770    http://docutils.sourceforge.net/docs/user/config.html#doctitle-xform
771 .. _initial_header_level:
772    http://docutils.sourceforge.net/docs/user/config.html#initial-header-level
774 (Thanks to Mark McEahern for the question and much of the answer.)
777 Why do enumerated lists only use numbers (no letters or roman numerals)?
778 ------------------------------------------------------------------------
780 The rendering of enumerators (the numbers or letters acting as list
781 markers) is completely governed by the stylesheet, so either the
782 browser can't find the stylesheet (try using the "--embed-stylesheet"
783 option), or the browser can't understand it (try a recent Firefox,
784 Mozilla, Konqueror, Opera, Safari, or even MSIE).
787 There appear to be garbage characters in the HTML.  What's up?
788 --------------------------------------------------------------
790 What you're seeing is most probably not garbage, but the result of a
791 mismatch between the actual encoding of the HTML output and the
792 encoding your browser is expecting.  Your browser is misinterpreting
793 the HTML data, which is encoded text.  A discussion of text encodings
794 is beyond the scope of this FAQ; see one or more of these documents
795 for more info:
797 * `UTF-8 and Unicode FAQ for Unix/Linux
798   <http://www.cl.cam.ac.uk/~mgk25/unicode.html>`_
800 * Chapters 3 and 4 of `Introduction to i18n [Internationalization]
801   <http://www.debian.org/doc/manuals/intro-i18n/>`_
803 * `Python Unicode Tutorial
804   <http://www.reportlab.com/i18n/python_unicode_tutorial.html>`_
806 * `Python Unicode Objects: Some Observations on Working With Non-ASCII
807   Character Sets <http://effbot.org/zone/unicode-objects.htm>`_
809 The common case is with the default output encoding (UTF-8), when
810 either numbered sections are used (via the "sectnum_" directive) or
811 symbol-footnotes.  3 non-breaking spaces are inserted in each numbered
812 section title, between the generated number and the title text.  Most
813 footnote symbols are not available in ASCII, nor are non-breaking
814 spaces.  When encoded with UTF-8 and viewed with ordinary ASCII tools,
815 these characters will appear to be multi-character garbage.
817 You may have an decoding problem in your browser (or editor, etc.).
818 The encoding of the output is set to "utf-8", but your browswer isn't
819 recognizing that.  You can either try to fix your browser (enable
820 "UTF-8 character set", sometimes called "Unicode"), or choose a
821 different encoding for the HTML output.  You can also try
822 ``--output-encoding=ascii:xmlcharrefreplace`` for HTML (not applicable
823 to non-XMLish outputs).
825 If you're generating document fragments, the "Content-Type" metadata
826 (between the HTML ``<head>`` and ``</head>`` tags) must agree with the
827 encoding of the rest of the document.  For UTF-8, it should be::
829     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
831 Also, Docutils normally generates an XML declaration as the first line
832 of the output.  It must also match the document encoding.  For UTF-8::
834     <?xml version="1.0" encoding="utf-8" ?>
836 .. _sectnum:
837    http://docutils.sourceforge.net/docs/ref/rst/directives.html#sectnum
840 Python Source Reader
841 ====================
843 Can I use Docutils for Python auto-documentation?
844 -------------------------------------------------
846 Yes, in conjunction with other projects.
848 Docstring extraction functionality from within Docutils is still under
849 development.  There is most of a source code parsing module in
850 docutils/readers/python/moduleparser.py.  We do plan to finish it
851 eventually.  Ian Bicking wrote an initial front end for the
852 moduleparser.py module, in sandbox/ianb/extractor/extractor.py.  Ian
853 also did some work on the Python Source Reader
854 (docutils.readers.python) component at PyCon DC 2004.
856 Version 2.0 of Ed Loper's `Epydoc <http://epydoc.sourceforge.net/>`_
857 supports reStructuredText-format docstrings for HTML output.  Docutils
858 0.3 or newer is required.  Development of a Docutils-specific
859 auto-documentation tool will continue.  Epydoc works by importing
860 Python modules to be documented, whereas the Docutils-specific tool,
861 described above, will parse modules without importing them (as with
862 `HappyDoc <http://happydoc.sourceforge.net/>`_, which doesn't support
863 reStructuredText).
865 The advantages of parsing over importing are security and flexibility;
866 the disadvantage is complexity/difficulty.
868 * Security: untrusted code that shouldn't be executed can be parsed;
869   importing a module executes its top-level code.
870 * Flexibility: comments and unofficial docstrings (those not supported
871   by Python syntax) can only be processed by parsing.
872 * Complexity/difficulty: it's a lot harder to parse and analyze a
873   module than it is to ``import`` and analyze one.
875 For more details, please see "Docstring Extraction Rules" in `PEP
876 258`_, item 3 ("How").
879 Miscellaneous
880 =============
882 Is the Docutils document model based on any existing XML models?
883 ----------------------------------------------------------------
885 Not directly, no.  It borrows bits from DocBook, HTML, and others.  I
886 (David Goodger) have designed several document models over the years,
887 and have my own biases.  The Docutils document model is designed for
888 simplicity and extensibility, and has been influenced by the needs of
889 the reStructuredText markup.