Commit e061caf7 authored by Andreas Jung's avatar Andreas Jung

moving third_party/docutils back to lib/python

parent 8b103cca
......@@ -4,8 +4,8 @@
:Author: David Goodger; open to all Docutils developers
:Contact: goodger@python.org
:Date: $Date: 2004/10/29 19:08:15 $
:Revision: $Revision: 1.1.4.1 $
:Date: $Date: 2005/01/07 15:11:43 $
:Revision: $Revision: 1.1.2.1 $
:Copyright: This document has been placed in the public domain.
.. _Docutils: http://docutils.sourceforge.net/
......@@ -119,6 +119,31 @@ Known Bugs
Also see the `SourceForge Bug Tracker`_.
* .. _unencoded stylesheet reference:
``--stylesheet='foo&bar'`` causes an invalid stylesheet reference to
be inserted in an HTML file, because the ``&`` isn't encoded as
``&``.
* ``utils.relative_path()`` sometimes returns absolute _`paths on
Windows` (like ``C:/test/foo.css``) where it could have chosen a
relative path.
Furthermore, absolute pathnames are inserted verbatim, like
``href="C:/test/foo.css"`` instead of
``href="file:///C:/test/foo.css"``.
For details, see `this posting by Alan G. Isaac
<http://article.gmane.org/gmane.text.docutils.user/1569>`_.
* .. _empty csv-table:
When supplying an empty file for the csv-table directive, Docutils
crashes with a zero-division error. Example::
.. csv-table::
:file: empty.txt
* _`Line numbers` in system messages are inconsistent in the parser.
- In text inserted by the "include" directive, errors are often not
......@@ -157,7 +182,7 @@ Also see the `SourceForge Bug Tracker`_.
This is tricky. Substitutions have to propagate back completely.
* .. _subsitutions and references:
* .. _substitutions and references:
Another bug from David Abrahams (run with ``rst2html.py --traceback``)::
......@@ -174,6 +199,51 @@ Also see the `SourceForge Bug Tracker`_.
all IDs from definitions after the first substitution reference is
processed.
* Footnote label "5" should be "4"::
$ rst2pseudoxml.py <<EOF
> ref [#abc]_ [#]_ [1]_ [#4]_
>
> .. [#abc] footnote
> .. [#] two
> .. [1] one
> .. [#4] four
> EOF
<document source="<stdin>">
<paragraph>
ref
<footnote_reference auto="1" id="id1" refid="abc">
2
<footnote_reference auto="1" id="id2" refid="id5">
3
<footnote_reference id="id3" refid="id6">
1
<footnote_reference auto="1" id="id4" refid="id7">
5
<footnote auto="1" backrefs="id1" id="abc" name="abc">
<label>
2
<paragraph>
footnote
<footnote auto="1" backrefs="id2" id="id5" name="3">
<label>
3
<paragraph>
two
<footnote backrefs="id3" id="id6" name="1">
<label>
1
<paragraph>
one
<footnote auto="1" backrefs="id4" id="id7" name="4">
<label>
5
<paragraph>
four
..
Local Variables:
......
......@@ -4,7 +4,7 @@
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date: 2004/10/29 19:08:15 $
:Date: $Date: 2005/01/07 15:11:43 $
:Web site: http://docutils.sourceforge.net/
:Copyright: This document has been placed in the public domain.
......
......@@ -4,13 +4,178 @@
:Author: David Goodger; open to all Docutils developers
:Contact: goodger@python.org
:Date: $Date: 2004/10/29 19:08:15 $
:Date: $Date: 2005/01/07 15:11:43 $
:Web site: http://docutils.sourceforge.net/
:Copyright: This document has been placed in the public domain.
.. contents::
Release 0.3.7 (2004-12-24)
==========================
* docutils/frontend.py:
- Added options: --input-encoding-error-handler,
--record-dependencies, --leave-footnote-reference-space,
--strict-visitor.
- Added command-line and config file support for "overrides" setting
parameter.
* docutils/io.py:
- Added support for input encoding error handler.
* docutils/nodes.py:
- Added dispatch_visit and dispatch_departure methods to
NodeVisitor; useful as a hook for Visitors.
- Changed structure of ``line_block``; added ``line``.
- Added ``compound`` node class.
- Added a mechanism for Visitors to transitionally ignore new node
classes.
* docutils/utils.py:
- Moved ``escape2null`` and ``unescape`` functions from
docutils/parsers/rst/states.py.
* docutils/parsers/rst/roles.py:
- Added "raw" role.
- Changed role function API: the "text" parameter now takes
null-escaped interpreted text content.
* docutils/parsers/rst/states.py:
- Fixed bug where a "role" directive in a nested parse would crash
the parser; the state machine's "language" attribute was not being
copied over.
- Added support for line block syntax.
- Fixed directive parsing bug: argument-less directives didn't
notice that arguments were present.
- Removed error checking for transitions.
- Added support for multiple classifiers in definition list items.
- Moved ``escape2null`` and ``unescape`` functions to docutils/utils.py.
- Changed role function API: the "text" parameter now takes
null-escaped interpreted text content.
- Empty sections and documents are allowed now.
* docutils/parsers/rst/directives/__init__.py:
- Added ``encoding`` directive option conversion function.
- Allow multiple class names in class_option conversion function.
* docutils/parsers/rst/directives/body.py:
- Converted the line-block directive to use the new structure.
- Extracted the old line-block functionality to the ``block``
function (still used).
- Added ``compound`` directive (thanks to Felix Wiemann).
* docutils/parsers/rst/directives/misc.py:
- Added "encoding" option to "include" and "raw" directives.
- Added "trim", "ltrim", and "rtrim" options to "unicode" directive.
- Allow multiple class names in the "class" directive.
* docutils/parsers/rst/directives/parts.py:
- Directive "sectnum" now accepts "prefix", "suffix", and "start"
options. Thanks to Lele Gaifax.
* docutils/parsers/rst/directives/tables.py:
- Added "encoding" directive to "csv-table" directive.
- Added workaround for lack of Unicode support in csv.py, for
non-ASCII CSV input.
* docutils/transforms/misc.py:
- Fixed bug when multiple "class" directives are applied to a single
element.
- Enabled multiple format names for "raw" directive.
* docutils/transforms/references.py:
- Added support for trimming whitespace from beside substitution
references.
* docutils/transforms/universal.py:
- FinalChecks now checks for illegal transitions and moves
transitions between sections.
* docutils/writers/html4css1.py:
- HTMLTranslator.encode now converts U+00A0 to "&nbsp;".
- "stylesheet" and "stylesheet_path" settings are now mutually
exclusive.
- Added support for the new line_block/line structure.
- --footnote-references now overrides
--trim-footnote-reference-space, if applicable.
- Added support for ``compound`` elements.
- Enabled multiple format names for "raw" directive.
- ``<p>`` tags of a paragraph which is the only visible child of the
document node are no longer stripped.
- Moved paragraph-compacting logic (for stripping ``<p>`` tags) to
new method ``should_be_compact_paragraph()``.
- Added class="docutils" to ``dl``, ``hr``, ``table`` and ``tt``
elements.
- "raw" elements are now surrounded by ``span`` or ``div`` tags in
the output if they have their ``class`` attribute set.
- The whole document is now surrounded by a ``<div
class="document">`` element.
- Body-level images are now wrapped by their own ``<div>`` elements,
with image classes copied to the wrapper, and for images which
have the ``:align:`` option set, the surrounding ``<div>`` now
receives a class attribute (like ``class="align-left"``).
* docutils/writers/latex2e.py:
- no newline after depart_term.
- Added translations for some Unicode quotes.
- Added option "font-encoding", made package AE the default.
- "stylesheet" and "stylesheet_path" settings are now mutually
exclusive.
- --footnote-references now overrides
--trim-footnote-reference-space, if applicable.
- The footnote label style now matches the footnote reference style
("brackets" or "superscript").
- Added support for ``compound`` elements.
- Enabled multiple format names for "raw" directive.
* docs/ref/docutils.dtd:
- Changed structure of the ``line_block`` element; added ``line``.
- Added ``compound`` element.
- Added "ltrim" and "rtrim" attributes to
``substitution_definition`` element.
- Enabled multiple format names for ``raw`` element.
- Enabled multiple classifiers in ``definition_list_item`` elements.
* docs/ref/rst/directives.txt
- Marked "line-block" as deprecated.
- "Class" directive now allows multiple class names.
- Added "Rationale for Class Attribute Value Conversion".
- Added warning about "raw" overuse/abuse.
* docs/ref/rst/restructuredtext.txt:
- Added syntax for line blocks.
- Definition list items may have multiple classifiers.
* docs/ref/rst/roles.txt:
- Added "raw" role.
* tools/stylesheets/default.css:
- Added support for the new line_block structure.
- Added "docutils" class to ``dl``, ``hr``, ``table`` and ``tt``.
Release 0.3.5 (2004-07-29)
==========================
......@@ -172,9 +337,11 @@ Specific:
* tools/buildhtml.py: Fixed bug with config file handling.
* tools/html.py: Removed from project.
* tools/html.py: Removed from project (duplicate of rst2html.py).
* tools/pep2html.py: Removed from project.
* tools/pep2html.py: Removed from project (duplicate of Python's
nondist/peps/pep2html.py; Docutils' tools/pep.py can be used for
Docutils-related PEPs in docs/peps/).
* tools/rst2pseudoxml.py: Renamed from publish.py.
......
Metadata-Version: 1.0
Name: docutils
Version: 0.3.5
Version: 0.3.7
Summary: Docutils -- Python Documentation Utilities
Home-page: http://docutils.sourceforge.net/
Author: David Goodger
......
......@@ -4,7 +4,7 @@
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date: 2004/10/29 19:08:15 $
:Date: $Date: 2005/01/07 15:11:43 $
:Web site: http://docutils.sourceforge.net/
:Copyright: This document has been placed in the public domain.
......@@ -48,7 +48,8 @@ complete details.
directory as in step 3. For example::
cd tools
./rst2html.py ../FAQ.txt ../FAQ.html
./rst2html.py ../FAQ.txt ../FAQ.html (Unix)
python rst2html.py ..\FAQ.txt ..\FAQ.html (Windows)
See Usage_ below for details.
......@@ -260,13 +261,19 @@ shell commands will generate HTML for all included documentation::
cd <archive_directory_path>/tools
./buildhtml.py ../
On Windows systems, type::
cd <archive_directory_path>\tools
python buildhtml.py ..
The final directory name of the ``<archive_directory_path>`` is
"docutils" for snapshots. For official releases, the directory may be
called "docutils-X.Y", where "X.Y" is the release version.
called "docutils-X.Y.Z", where "X.Y.Z" is the release version.
Alternatively::
cd <archive_directory_path>
tools/buildhtml.py --config=tools/docutils.conf
tools/buildhtml.py --config=tools/docutils.conf (Unix)
python tools\buildhtml.py --config=tools\docutils.conf (Windows)
Some files may generate system messages (warnings and errors). The
``docs/user/rst/demo.txt`` file (under the archive directory) contains
......@@ -295,6 +302,11 @@ the following commands::
cd <archive_directory_path>/test
./alltests.py
Under Windows, type::
cd <archive_directory_path>\test
python alltests.py
You should see a long line of periods, one for each test, and then a
summary like this::
......@@ -311,11 +323,16 @@ modules, create data structures, etc.).
If any of the tests fail, please `open a bug report`_ or `send email`_
[2]_. Please include all relevant output, information about your
operating system, Python version, and Docutils version. To see the
Docutils version, use these commands::
Docutils version, use these commands in the shell::
cd ../tools
./quicktest.py --version
Windows users type these commands::
cd ..\tools
python quicktest.py --version
.. _open a bug report:
http://sourceforge.net/tracker/?group_id=38414&atid=422030
.. _send email: mailto:docutils-users@lists.sourceforge.net
......
......@@ -3,8 +3,8 @@ Acknowledgements
:Author: David Goodger
:Contact: goodger@python.org
:Date: $Date: 2004/10/29 19:08:15 $
:Revision: $Revision: 1.1.4.1 $
:Date: $Date: 2005/01/07 15:11:43 $
:Revision: $Revision: 1.1.2.1 $
:Copyright: This document has been placed in the public domain.
I would like to acknowledge the people who have made a direct impact
......@@ -62,6 +62,7 @@ donations, tasty treats, and related projects:
* Jeremy Hylton
* Tony Ibbs
* Alan Jaffray
* Joe YS Jaw
* Dmitry Jemerov
* Richard Jones
* Andreas Jung
......@@ -83,7 +84,6 @@ donations, tasty treats, and related projects:
* Mark McEahern
* Vincent McIntyre
* John F Meinel Jr
* Vasko Miroslav
* Skip Montanaro
* Paul Moore
* Nigel W. Moriarty
......@@ -101,14 +101,17 @@ donations, tasty treats, and related projects:
* Tavis Rudd
* Tracy Ruggles
* Oliver Rutherfurd
* Luc Saffre
* Kenichi Sato
* Ueli Schlaepfer
* Gunnar Schwant
* Bill Sconce
* Frank Siebenlist
* Bruce Smith
* Asko Soukka
* Darek Suchojad
* Roman Suzi
* Janet Swisher
* tav
* Kent Tenney
* Bob Tolbert
......@@ -116,6 +119,7 @@ donations, tasty treats, and related projects:
* Laurence Tratt
* Adrian van den Dries
* Guido van Rossum
* Miroslav Vasko
* Paul Viren
* Martin von Loewis
* Greg Ward
......
# Author: David Goodger
# Contact: goodger@python.org
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:20 $
# Revision: $Revision: 1.2.10.9 $
# Date: $Date: 2005/01/07 13:26:01 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -51,7 +51,7 @@ Subpackages:
__docformat__ = 'reStructuredText'
__version__ = '0.3.5'
__version__ = '0.3.7'
"""``major.minor.micro`` version number. The micro number is bumped for API
changes, for new functionality, and for interim project releases. The minor
number is bumped whenever there is a significant project release. The major
......
# Authors: David Goodger
# Contact: goodger@python.org
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:20 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:01 $
# Copyright: This module has been placed in the public domain.
"""
......
# Authors: David Goodger
# Contact: goodger@python.org
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:20 $
# Revision: $Revision: 1.1.4.3 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:20 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -30,10 +30,14 @@ class Input(TransformSpec):
default_source_path = None
def __init__(self, source=None, source_path=None, encoding=None):
def __init__(self, source=None, source_path=None, encoding=None,
error_handler='strict'):
self.encoding = encoding
"""Text encoding for the input source."""
self.error_handler = error_handler
"""Text decoding error handler."""
self.source = source
"""The source of input data."""
......@@ -43,6 +47,9 @@ class Input(TransformSpec):
if not source_path:
self.source_path = self.default_source_path
self.successful_encoding = None
"""The encoding that successfully decoded the source data."""
def __repr__(self):
return '%s: source=%r, source_path=%r' % (self.__class__, self.source,
self.source_path)
......@@ -62,7 +69,7 @@ class Input(TransformSpec):
"""
if (self.encoding and self.encoding.lower() == 'unicode'
or isinstance(data, UnicodeType)):
return unicode(data)
return data
encodings = [self.encoding, 'utf-8']
try:
encodings.append(locale.nl_langinfo(locale.CODESET))
......@@ -81,7 +88,9 @@ class Input(TransformSpec):
if not enc:
continue
try:
return unicode(data, enc)
decoded = unicode(data, enc, self.error_handler)
self.successful_encoding = enc
return decoded
except (UnicodeError, LookupError):
pass
raise UnicodeError(
......@@ -156,16 +165,20 @@ class FileInput(Input):
"""
def __init__(self, source=None, source_path=None,
encoding=None, autoclose=1, handle_io_errors=1):
encoding=None, error_handler='strict',
autoclose=1, handle_io_errors=1):
"""
:Parameters:
- `source`: either a file-like object (which is read directly), or
`None` (which implies `sys.stdin` if no `source_path` given).
- `source_path`: a path to a file, which is opened and then read.
- `encoding`: the expected text encoding of the input file.
- `error_handler`: the encoding error handler to use.
- `autoclose`: close automatically after read (boolean); always
false if `sys.stdin` is the source.
- `handle_io_errors`: summarize I/O errors here, and exit?
"""
Input.__init__(self, source, source_path, encoding)
Input.__init__(self, source, source_path, encoding, error_handler)
self.autoclose = autoclose
self.handle_io_errors = handle_io_errors
if source is None:
......@@ -194,9 +207,11 @@ class FileInput(Input):
"""
Read and decode a single file and return the data (Unicode string).
"""
data = self.source.read()
if self.autoclose:
self.close()
try:
data = self.source.read()
finally:
if self.autoclose:
self.close()
return self.decode(data)
def close(self):
......@@ -257,9 +272,11 @@ class FileOutput(Output):
output = self.encode(data)
if not self.opened:
self.open()
self.destination.write(output)
if self.autoclose:
self.close()
try:
self.destination.write(output)
finally:
if self.autoclose:
self.close()
return output
def close(self):
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# Internationalization details are documented in
......
# Author: Jannie Hofmeyr
# Contact: jhsh@sun.ac.za
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.1.2.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Marek Blaha
# Contact: mb@dat.cz
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.1.4.4 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Authors: David Goodger; Gunnar Schwant
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Marcelo Huerta San Martin
# Contact: richieadler@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.1.2.5 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# -*- coding: iso-8859-1 -*-
# Author: Marcelo Huerta San Martn
# Contact: mghsm@uol.com.ar
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.1.2.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Asko Soukka
# Contact: asko.soukka@iki.fi
# Revision: $Revision: 1.1.2.1 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
# translated for each language: one in docutils/languages, the other in
# docutils/parsers/rst/languages.
"""
Finnish-language mappings for language-dependent features of Docutils.
"""
__docformat__ = 'reStructuredText'
labels = {
# fixed: language-dependent
u'author': u'Tekij\u00e4',
u'authors': u'Tekij\u00e4t',
u'organization': u'Yhteis\u00f6',
u'address': u'Osoite',
u'contact': u'Yhteystiedot',
u'version': u'Versio',
u'revision': u'Vedos',
u'status': u'Tila',
u'date': u'P\u00e4iv\u00e4ys',
u'copyright': u'Tekij\u00e4noikeudet',
u'dedication': u'Omistuskirjoitus',
u'abstract': u'Tiivistelm\u00e4',
u'attention': u'Huomio!',
u'caution': u'Varo!',
u'danger': u'!VAARA!',
u'error': u'Virhe',
u'hint': u'Vihje',
u'important': u'T\u00e4rke\u00e4\u00e4',
u'note': u'Huomautus',
u'tip': u'Neuvo',
u'warning': u'Varoitus',
u'contents': u'Sis\u00e4llys'}
"""Mapping of node class name to label text."""
bibliographic_fields = {
# language-dependent: fixed
u'tekij\u00e4': u'author',
u'tekij\u00e4t': u'authors',
u'yhteis\u00f6': u'organization',
u'osoite': u'address',
u'yhteystiedot': u'contact',
u'versio': u'version',
u'vedos': u'revision',
u'tila': u'status',
u'p\u00e4iv\u00e4ys': u'date',
u'tekij\u00e4noikeudet': u'copyright',
u'omistuskirjoitus': u'dedication',
u'tiivistelm\u00e4': u'abstract'}
"""Finnish (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in
order."""
# Author: Stefane Fermigier
# Contact: sf@fermigier.com
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Nicola Larosa
# Contact: docutils@tekNico.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.1.4.4 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Roman Suzi
# Contact: rnd@onego.ru
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.1.2.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# :Author: Miroslav Vasko
# :Contact: zemiak@zoznam.sk
# :Revision: $Revision: 1.1.4.1 $
# :Date: $Date: 2004/10/29 19:08:21 $
# :Revision: $Revision: 1.2.10.7 $
# :Date: $Date: 2005/01/07 13:26:02 $
# :Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Adam Chodorowski
# Contact: chodorowski@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......
# Author: Joe YS Jaw
# Contact: joeysj@users.sourceforge.net
# Revision: $Revision: 1.1.2.1 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
# translated for each language: one in docutils/languages, the other in
# docutils/parsers/rst/languages.
"""
Traditional Chinese language mappings for language-dependent features of Docutils.
"""
__docformat__ = 'reStructuredText'
labels = {
# fixed: language-dependent
'author': u'\u4f5c\u8005', # 'Author',
'authors': u'\u4f5c\u8005\u7fa4', # 'Authors',
'organization': u'\u7d44\u7e54', # 'Organization',
'address': u'\u5730\u5740', # 'Address',
'contact': u'\u9023\u7d61', # 'Contact',
'version': u'\u7248\u672c', # 'Version',
'revision': u'\u4fee\u8a02', # 'Revision',
'status': u'\u72c0\u614b', # 'Status',
'date': u'\u65e5\u671f', # 'Date',
'copyright': u'\u7248\u6b0a', # 'Copyright',
'dedication': u'\u984c\u737b', # 'Dedication',
'abstract': u'\u6458\u8981', # 'Abstract',
'attention': u'\u6ce8\u610f\uff01', # 'Attention!',
'caution': u'\u5c0f\u5fc3\uff01', # 'Caution!',
'danger': u'\uff01\u5371\u96aa\uff01', # '!DANGER!',
'error': u'\u932f\u8aa4', # 'Error',
'hint': u'\u63d0\u793a', # 'Hint',
'important': u'\u91cd\u8981', # 'Important',
'note': u'\u8a3b\u89e3', # 'Note',
'tip': u'\u79d8\u8a23', # 'Tip',
'warning': u'\u8b66\u544a', # 'Warning',
'contents': u'\u76ee\u9304' # 'Contents'
}
"""Mapping of node class name to label text."""
bibliographic_fields = {
# language-dependent: fixed
'author': 'author',
'authors': 'authors',
'organization': 'organization',
'address': 'address',
'contact': 'contact',
'version': 'version',
'revision': 'revision',
'status': 'status',
'date': 'date',
'copyright': 'copyright',
'dedication': 'dedication',
'abstract': 'abstract'}
"""Traditional Chinese to canonical name mapping for bibliographic fields."""
author_separators = [u'\uff1b', u'\uff0c', u'\u3001',
';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in
order."""
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:21 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:03 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:03 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -108,7 +108,11 @@ class Parser(docutils.parsers.Parser):
{'metavar': '<width>', 'type': 'int', 'default': 8}),
('Remove spaces before footnote references.',
['--trim-footnote-reference-space'],
{'action': 'store_true', 'validator': frontend.validate_boolean}),))
{'action': 'store_true', 'validator': frontend.validate_boolean}),
('Leave spaces before footnote references.',
['--leave-footnote-reference-space'],
{'action': 'store_false', 'dest': 'trim_footnote_reference_space',
'validator': frontend.validate_boolean}),))
config_section = 'restructuredtext parser'
config_section_dependencies = ('parsers',)
......
# Author: David Goodger
# Contact: goodger@python.org
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.8 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -85,6 +85,7 @@ See `Creating reStructuredText Directives`_ for more information.
__docformat__ = 'reStructuredText'
import re
import codecs
from docutils import nodes
from docutils.parsers.rst.languages import en as _fallback_language_module
......@@ -108,6 +109,7 @@ _directive_registry = {
'epigraph': ('body', 'epigraph'),
'highlights': ('body', 'highlights'),
'pull-quote': ('body', 'pull_quote'),
'compound': ('body', 'compound'),
#'questions': ('body', 'question_list'),
'table': ('tables', 'table'),
'csv-table': ('tables', 'csv_table'),
......@@ -270,7 +272,6 @@ def nonnegative_int(argument):
raise ValueError('negative value; must be positive or zero')
return value
def class_option(argument):
"""
Convert the argument into an ID-compatible string and return it.
......@@ -280,10 +281,14 @@ def class_option(argument):
"""
if argument is None:
raise ValueError('argument required but none supplied')
class_name = nodes.make_id(argument)
if not class_name:
raise ValueError('cannot make "%s" into a class name' % argument)
return class_name
names = argument.split()
class_names = []
for name in names:
class_name = nodes.make_id(name)
if not class_name:
raise ValueError('cannot make "%s" into a class name' % name)
class_names.append(class_name)
return ' '.join(class_names)
unicode_pattern = re.compile(
r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE)
......@@ -309,7 +314,6 @@ def unicode_code(code):
except OverflowError, detail:
raise ValueError('code too large (%s)' % detail)
def single_char_or_unicode(argument):
char = unicode_code(argument)
if len(char) > 1:
......@@ -339,9 +343,12 @@ def positive_int_list(argument):
entries = argument.split()
return [positive_int(entry) for entry in entries]
def format_values(values):
return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]),
values[-1])
def encoding(argument):
try:
codecs.lookup(argument)
except LookupError:
raise ValueError('unknown encoding: "%s"' % argument)
return argument
def choice(argument, values):
"""
......@@ -368,3 +375,7 @@ def choice(argument, values):
else:
raise ValueError('"%s" unknown; choose from %s'
% (argument, format_values(values)))
def format_values(values):
return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]),
values[-1])
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@python.org
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -66,31 +66,51 @@ sidebar.options = {'subtitle': directives.unchanged_required,
sidebar.content = 1
def line_block(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine,
node_class=nodes.line_block):
content_offset, block_text, state, state_machine):
if not content:
warning = state_machine.reporter.warning(
'Content block expected for the "%s" directive; none found.'
% name, nodes.literal_block(block_text, block_text), line=lineno)
return [warning]
text = '\n'.join(content)
text_nodes, messages = state.inline_text(text, lineno)
node = node_class(text, '', *text_nodes, **options)
node.line = content_offset + 1
return [node] + messages
block = nodes.line_block()
node_list = [block]
for line_text in content:
text_nodes, messages = state.inline_text(line_text.strip(),
lineno + content_offset)
line = nodes.line(line_text, '', *text_nodes)
if line_text.strip():
line.indent = len(line_text) - len(line_text.lstrip())
block += line
node_list.extend(messages)
content_offset += 1
state.nest_line_block_lines(block)
return node_list
line_block.options = {'class': directives.class_option}
line_block.content = 1
def parsed_literal(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
return line_block(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine,
node_class=nodes.literal_block)
return block(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine,
node_class=nodes.literal_block)
parsed_literal.options = {'class': directives.class_option}
parsed_literal.content = 1
def block(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine, node_class):
if not content:
warning = state_machine.reporter.warning(
'Content block expected for the "%s" directive; none found.'
% name, nodes.literal_block(block_text, block_text), line=lineno)
return [warning]
text = '\n'.join(content)
text_nodes, messages = state.inline_text(text, lineno)
node = node_class(text, '', *text_nodes, **options)
node.line = content_offset + 1
return [node] + messages
def rubric(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
rubric_text = arguments[0]
......@@ -124,3 +144,20 @@ def pull_quote(name, arguments, options, content, lineno,
return [block_quote] + messages
pull_quote.content = 1
def compound(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
text = '\n'.join(content)
if not text:
error = state_machine.reporter.error(
'The "%s" directive is empty; content required.' % name,
nodes.literal_block(block_text, block_text), line=lineno)
return [error]
node = nodes.compound(text)
if options.has_key('class'):
node.set_class(options['class'])
state.nested_parse(content, content_offset, node)
return [node]
compound.options = {'class': directives.class_option}
compound.content = 1
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -85,6 +85,7 @@ def figure(name, arguments, options, content, lineno,
except (IOError, UnicodeError):
pass
else:
state.document.settings.record_dependencies.add(reference)
figure_node['width'] = i.size[0]
elif figwidth is not None:
figure_node['width'] = figwidth
......
# Authors: David Goodger, Dethe Elza
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""Miscellaneous directives."""
......@@ -35,9 +35,12 @@ def include(name, arguments, options, content, lineno,
return [error]
path = os.path.normpath(os.path.join(source_dir, path))
path = utils.relative_path(None, path)
encoding = options.get('encoding', state.document.settings.input_encoding)
try:
state.document.settings.record_dependencies.add(path)
include_file = io.FileInput(
source_path=path, encoding=state.document.settings.input_encoding,
source_path=path, encoding=encoding,
error_handler=state.document.settings.input_encoding_error_handler,
handle_io_errors=None)
except IOError, error:
severe = state_machine.reporter.severe(
......@@ -58,7 +61,8 @@ def include(name, arguments, options, content, lineno,
return []
include.arguments = (1, 0, 1)
include.options = {'literal': directives.flag}
include.options = {'literal': directives.flag,
'encoding': directives.encoding}
def raw(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
......@@ -70,7 +74,8 @@ def raw(name, arguments, options, content, lineno,
Content may be included inline (content section of directive) or
imported from a file or url.
"""
attributes = {'format': arguments[0]}
attributes = {'format': ' '.join(arguments[0].lower().split())}
encoding = options.get('encoding', state.document.settings.input_encoding)
if content:
if options.has_key('file') or options.has_key('url'):
error = state_machine.reporter.error(
......@@ -91,14 +96,17 @@ def raw(name, arguments, options, content, lineno,
path = os.path.normpath(os.path.join(source_dir, options['file']))
path = utils.relative_path(None, path)
try:
raw_file = open(path)
state.document.settings.record_dependencies.add(path)
raw_file = io.FileInput(
source_path=path, encoding=encoding,
error_handler=state.document.settings.input_encoding_error_handler,
handle_io_errors=None)
except IOError, error:
severe = state_machine.reporter.severe(
'Problems with "%s" directive path:\n%s.' % (name, error),
nodes.literal_block(block_text, block_text), line=lineno)
return [severe]
text = raw_file.read()
raw_file.close()
attributes['source'] = path
elif options.has_key('url'):
if not urllib2:
......@@ -108,17 +116,20 @@ def raw(name, arguments, options, content, lineno,
'"urllib2" module).' % name,
nodes.literal_block(block_text, block_text), line=lineno)
return [severe]
source = options['url']
try:
raw_file = urllib2.urlopen(options['url'])
raw_text = urllib2.urlopen(source).read()
except (urllib2.URLError, IOError, OSError), error:
severe = state_machine.reporter.severe(
'Problems with "%s" directive URL "%s":\n%s.'
% (name, options['url'], error),
nodes.literal_block(block_text, block_text), line=lineno)
return [severe]
raw_file = io.StringInput(
source=raw_text, source_path=source, encoding=encoding,
error_handler=state.document.settings.input_encoding_error_handler)
text = raw_file.read()
raw_file.close()
attributes['source'] = options['file']
attributes['source'] = source
else:
error = state_machine.reporter.warning(
'The "%s" directive requires content; none supplied.' % (name),
......@@ -129,7 +140,8 @@ def raw(name, arguments, options, content, lineno,
raw.arguments = (1, 0, 1)
raw.options = {'file': directives.path,
'url': directives.path}
'url': directives.path,
'encoding': directives.encoding}
raw.content = 1
def replace(name, arguments, options, content, lineno,
......@@ -167,7 +179,7 @@ def replace(name, arguments, options, content, lineno,
replace.content = 1
def unicode_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
content_offset, block_text, state, state_machine):
r"""
Convert Unicode character codes (numbers) to characters. Codes may be
decimal numbers, hexadecimal numbers (prefixed by ``0x``, ``x``, ``\x``,
......@@ -181,6 +193,14 @@ def unicode_directive(name, arguments, options, content, lineno,
'substitution definition.' % (name),
nodes.literal_block(block_text, block_text), line=lineno)
return [error]
substitution_definition = state_machine.node
if options.has_key('trim'):
substitution_definition.attributes['ltrim'] = 1
substitution_definition.attributes['rtrim'] = 1
if options.has_key('ltrim'):
substitution_definition.attributes['ltrim'] = 1
if options.has_key('rtrim'):
substitution_definition.attributes['rtrim'] = 1
codes = unicode_comment_pattern.split(arguments[0])[0].split()
element = nodes.Element()
for code in codes:
......@@ -196,26 +216,32 @@ def unicode_directive(name, arguments, options, content, lineno,
return element.children
unicode_directive.arguments = (1, 0, 1)
unicode_directive.options = {'trim': directives.flag,
'ltrim': directives.flag,
'rtrim': directives.flag}
unicode_comment_pattern = re.compile(r'( |\n|^)\.\. ')
def class_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
""""""
class_value = nodes.make_id(arguments[0])
if class_value:
pending = nodes.pending(misc.ClassAttribute,
{'class': class_value, 'directive': name},
block_text)
state_machine.document.note_pending(pending)
return [pending]
else:
"""
Set a "class" attribute on the next element.
A "pending" element is inserted, and a transform does the work later.
"""
try:
class_value = directives.class_option(arguments[0])
except ValueError:
error = state_machine.reporter.error(
'Invalid class attribute value for "%s" directive: "%s".'
% (name, arguments[0]),
nodes.literal_block(block_text, block_text), line=lineno)
return [error]
pending = nodes.pending(misc.ClassAttribute,
{'class': class_value, 'directive': name},
block_text)
state_machine.document.note_pending(pending)
return [pending]
class_directive.arguments = (1, 0, 0)
class_directive.arguments = (1, 0, 1)
class_directive.content = 1
role_arg_pat = re.compile(r'(%s)\s*(\(\s*(%s)\s*\)\s*)?$'
......
# Author: David Goodger, Dmitry Jemerov
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -78,4 +78,7 @@ def sectnum(name, arguments, options, content, lineno,
state_machine.document.note_pending(pending)
return [pending]
sectnum.options = {'depth': int}
sectnum.options = {'depth': int,
'start': int,
'prefix': directives.unchanged_required,
'suffix': directives.unchanged_required}
# Author: David Goodger, Dmitry Jemerov
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......
# Authors: David Goodger, David Priest
# Contact: goodger@python.org
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.1.2.3 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText'
import sys
import os.path
from docutils import nodes, statemachine, utils
from docutils import io, nodes, statemachine, utils
from docutils.utils import SystemMessagePropagation
from docutils.parsers.rst import directives
......@@ -154,6 +154,7 @@ csv_table.options = {'header-rows': directives.nonnegative_int,
'widths': directives.positive_int_list,
'file': directives.path,
'url': directives.path,
'encoding': directives.encoding,
'class': directives.class_option,
# field delimiter char
'delim': directives.single_char_or_whitespace_or_unicode,
......@@ -180,6 +181,7 @@ def get_csv_data(name, options, content, lineno, block_text,
CSV data can come from the directive content, from an external file, or
from a URL reference.
"""
encoding = options.get('encoding', state.document.settings.input_encoding)
if content: # CSV data is from directive content
if options.has_key('file') or options.has_key('url'):
error = state_machine.reporter.error(
......@@ -201,11 +203,12 @@ def get_csv_data(name, options, content, lineno, block_text,
source = os.path.normpath(os.path.join(source_dir, options['file']))
source = utils.relative_path(None, source)
try:
csv_file = open(source, 'rb')
try:
csv_data = csv_file.read().splitlines()
finally:
csv_file.close()
state.document.settings.record_dependencies.add(source)
csv_file = io.FileInput(
source_path=source, encoding=encoding,
error_handler=state.document.settings.input_encoding_error_handler,
handle_io_errors=None)
csv_data = csv_file.read().splitlines()
except IOError, error:
severe = state_machine.reporter.severe(
'Problems with "%s" directive path:\n%s.' % (name, error),
......@@ -221,13 +224,17 @@ def get_csv_data(name, options, content, lineno, block_text,
raise SystemMessagePropagation(severe)
source = options['url']
try:
csv_data = urllib2.urlopen(source).read().splitlines()
csv_text = urllib2.urlopen(source).read()
except (urllib2.URLError, IOError, OSError, ValueError), error:
severe = state_machine.reporter.severe(
'Problems with "%s" directive URL "%s":\n%s.'
% (name, options['url'], error),
nodes.literal_block(block_text, block_text), line=lineno)
raise SystemMessagePropagation(severe)
csv_file = io.StringInput(
source=csv_text, source_path=source, encoding=encoding,
error_handler=state.document.settings.input_encoding_error_handler)
csv_data = csv_file.read().splitlines()
else:
error = state_machine.reporter.warning(
'The "%s" directive requires content; none supplied.' % (name),
......@@ -246,14 +253,18 @@ def process_header_option(options, state_machine, lineno):
return table_head, max_header_cols
def parse_csv_data_into_rows(csv_data, dialect, source, options):
csv_reader = csv.reader(csv_data, dialect=dialect)
# csv.py doesn't do Unicode; encode temporarily as UTF-8
csv_reader = csv.reader([line.encode('utf-8') for line in csv_data],
dialect=dialect)
rows = []
max_cols = 0
for row in csv_reader:
row_data = []
for cell in row:
cell_data = (0, 0, 0, statemachine.StringList(cell.splitlines(),
source=source))
# decode UTF-8 back to Unicode
cell_text = unicode(cell, 'utf-8')
cell_data = (0, 0, 0, statemachine.StringList(
cell_text.splitlines(), source=source))
row_data.append(cell_data)
rows.append(row_data)
max_cols = max(max_cols, len(row))
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# Internationalization details are documented in
......
# Author: Jannie Hofmeyr
# Contact: jhsh@sun.ac.za
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.1.2.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -36,6 +36,7 @@ directives = {
'epigraaf': 'epigraph',
'hoogtepunte': 'highlights',
'pull-quote (translation required)': 'pull-quote',
u'compound (translation required)': 'compound',
#'vrae': 'questions',
#'qa': 'questions',
#'faq': 'questions',
......@@ -90,6 +91,7 @@ roles = {
'teiken': 'target',
'uri-verwysing': 'uri-reference',
'uri': 'uri-reference',
'url': 'uri-reference',}
'url': 'uri-reference',
'rou': 'raw',}
"""Mapping of Afrikaans role names to canonical role names for interpreted text.
"""
# Author: Marek Blaha
# Contact: mb@dat.cz
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.1.4.4 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -20,78 +20,80 @@ __docformat__ = 'reStructuredText'
directives = {
# language-dependent: fixed
u'pozor': 'attention',
u'caution': 'caution', # jak rozlisit caution a warning?
u'caution (translation required)': 'caution', # jak rozlisit caution a warning?
u'nebezpe\u010D\u00ED': 'danger',
u'chyba': 'error',
u'rada': 'hint',
u'd\u016Fle\u017Eit\u00E9': 'important',
u'pozn\u00E1mka': 'note',
u'tip': 'tip',
u'tip (translation required)': 'tip',
u'varov\u00E1n\u00ED': 'warning',
u'admonition': 'admonition',
u'sidebar': 'sidebar',
u'admonition (translation required)': 'admonition',
u'sidebar (translation required)': 'sidebar',
u't\u00E9ma': 'topic',
u'line-block': 'line-block',
u'parsed-literal': 'parsed-literal',
u'line-block (translation required)': 'line-block',
u'parsed-literal (translation required)': 'parsed-literal',
u'odd\u00EDl': 'rubric',
u'moto': 'epigraph',
u'highlights': 'highlights',
u'pull-quote': 'pull-quote',
u'highlights (translation required)': 'highlights',
u'pull-quote (translation required)': 'pull-quote',
u'compound (translation required)': 'compound',
#'questions': 'questions',
#'qa': 'questions',
#'faq': 'questions',
u'table (translation required)': 'table',
u'csv-table (translation required)': 'csv-table',
u'meta': 'meta',
u'meta (translation required)': 'meta',
#'imagemap': 'imagemap',
u'image': 'image', # obrazek
u'figure': 'figure', # a tady?
u'include': 'include',
u'raw': 'raw',
u'replace': 'replace',
u'unicode': 'unicode',
u'image (translation required)': 'image', # obrazek
u'figure (translation required)': 'figure', # a tady?
u'include (translation required)': 'include',
u'raw (translation required)': 'raw',
u'replace (translation required)': 'replace',
u'unicode (translation required)': 'unicode',
u't\u0159\u00EDda': 'class',
u'role (translation required)': 'role',
u'obsah': 'contents',
u'sectnum': 'sectnum',
u'section-numbering': 'sectnum',
u'sectnum (translation required)': 'sectnum',
u'section-numbering (translation required)': 'sectnum',
#'footnotes': 'footnotes',
#'citations': 'citations',
u'target-notes': 'target-notes',
u'target-notes (translation required)': 'target-notes',
u'restructuredtext-test-directive': 'restructuredtext-test-directive'}
"""Czech name to registered (in directives/__init__.py) directive name
mapping."""
roles = {
# language-dependent: fixed
u'abbreviation': 'abbreviation',
u'ab': 'abbreviation',
u'acronym': 'acronym',
u'ac': 'acronym',
u'index': 'index',
u'i': 'index',
u'subscript': 'subscript',
u'sub': 'subscript',
u'superscript': 'superscript',
u'sup': 'superscript',
u'title-reference': 'title-reference',
u'title': 'title-reference',
u't': 'title-reference',
u'pep-reference': 'pep-reference',
u'pep': 'pep-reference',
u'rfc-reference': 'rfc-reference',
u'rfc': 'rfc-reference',
u'emphasis': 'emphasis',
u'strong': 'strong',
u'literal': 'literal',
u'named-reference': 'named-reference',
u'anonymous-reference': 'anonymous-reference',
u'footnote-reference': 'footnote-reference',
u'citation-reference': 'citation-reference',
u'substitution-reference': 'substitution-reference',
u'target': 'target',
u'uri-reference': 'uri-reference',
u'uri': 'uri-reference',
u'url': 'uri-reference',}
u'abbreviation (translation required)': 'abbreviation',
u'ab (translation required)': 'abbreviation',
u'acronym (translation required)': 'acronym',
u'ac (translation required)': 'acronym',
u'index (translation required)': 'index',
u'i (translation required)': 'index',
u'subscript (translation required)': 'subscript',
u'sub (translation required)': 'subscript',
u'superscript (translation required)': 'superscript',
u'sup (translation required)': 'superscript',
u'title-reference (translation required)': 'title-reference',
u'title (translation required)': 'title-reference',
u't (translation required)': 'title-reference',
u'pep-reference (translation required)': 'pep-reference',
u'pep (translation required)': 'pep-reference',
u'rfc-reference (translation required)': 'rfc-reference',
u'rfc (translation required)': 'rfc-reference',
u'emphasis (translation required)': 'emphasis',
u'strong (translation required)': 'strong',
u'literal (translation required)': 'literal',
u'named-reference (translation required)': 'named-reference',
u'anonymous-reference (translation required)': 'anonymous-reference',
u'footnote-reference (translation required)': 'footnote-reference',
u'citation-reference (translation required)': 'citation-reference',
u'substitution-reference (translation required)': 'substitution-reference',
u'target (translation required)': 'target',
u'uri-reference (translation required)': 'uri-reference',
u'uri (translation required)': 'uri-reference',
u'url (translation required)': 'uri-reference',
u'raw (translation required)': 'raw',}
"""Mapping of Czech role names to canonical role names for interpreted text.
"""
# -*- coding: iso-8859-1 -*-
# Author: Engelbert Gruber
# Authors: Engelbert Gruber; Felix Wiemann
# Contact: grubert@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -26,61 +25,66 @@ directives = {
'hinweis': 'hint',
'wichtig': 'important',
'notiz': 'note',
'tip': 'tip',
'tipp': 'tip',
'warnung': 'warning',
'ermahnung': 'admonition',
'kasten': 'sidebar', # seitenkasten ?
'thema': 'topic',
'line-block': 'line-block',
'parsed-literal': 'parsed-literal',
'kasten': 'sidebar',
'seitenkasten': 'sidebar',
'thema': 'topic',
'zeilen-block': 'line-block',
'parsed-literal (translation required)': 'parsed-literal',
'rubrik': 'rubric',
'epigraph (translation required)': 'epigraph',
'epigraph': 'epigraph',
'highlights (translation required)': 'highlights',
'pull-quote (translation required)': 'pull-quote', # kasten too ?
#'questions': 'questions',
#'qa': 'questions',
#'faq': 'questions',
'table (translation required)': 'table',
'csv-table (translation required)': 'csv-table',
'zusammengesetzt': 'compound',
'verbund': 'compound',
#'fragen': 'questions',
'tabelle': 'table',
'csv-tabelle': 'csv-table',
'meta': 'meta',
#'imagemap': 'imagemap',
'bild': 'image',
'abbildung': 'figure',
'raw': 'raw', # unbearbeitet
'include': 'include', # einfügen, "füge ein" would be more like a command.
# einfügung would be the noun.
'ersetzung': 'replace', # ersetzen, ersetze
u'unver\xe4ndert': 'raw',
u'roh': 'raw',
u'einf\xfcgen': 'include',
'ersetzung': 'replace',
'ersetzen': 'replace',
'ersetze': 'replace',
'unicode': 'unicode',
'klasse': 'class', # offer "class" too ?
'role (translation required)': 'role',
'klasse': 'class',
'rolle': 'role',
'inhalt': 'contents',
'sectnum': 'sectnum',
'section-numbering': 'sectnum',
'target-notes': 'target-notes',
#'footnotes': 'footnotes',
#'citations': 'citations',
'restructuredtext-test-directive': 'restructuredtext-test-directive'}
'kapitel-nummerierung': 'sectnum',
'abschnitts-nummerierung': 'sectnum',
u'linkziel-fu\xdfnoten': 'target-notes',
#u'fu\xdfnoten': 'footnotes',
#'zitate': 'citations',
}
"""German name to registered (in directives/__init__.py) directive name
mapping."""
roles = {
'abbreviation (translation required)': 'abbreviation',
'acronym (translation required)': 'acronym',
'index (translation required)': 'index',
'subscript (translation required)': 'subscript',
'superscript (translation required)': 'superscript',
'title-reference (translation required)': 'title-reference',
'pep-reference (translation required)': 'pep-reference',
'rfc-reference (translation required)': 'rfc-reference',
'emphasis (translation required)': 'emphasis',
'strong (translation required)': 'strong',
'literal (translation required)': 'literal',
'named-reference (translation required)': 'named-reference',
'anonymous-reference (translation required)': 'anonymous-reference',
'footnote-reference (translation required)': 'footnote-reference',
'citation-reference (translation required)': 'citation-reference',
'substitution-reference (translation required)': 'substitution-reference',
'target (translation required)': 'target',
'uri-reference (translation required)': 'uri-reference',}
u'abk\xfcrzung': 'abbreviation',
'akronym': 'acronym',
'index': 'index',
'tiefgestellt': 'subscript',
'hochgestellt': 'superscript',
'titel-referenz': 'title-reference',
'pep-referenz': 'pep-reference',
'rfc-referenz': 'rfc-reference',
'betonung': 'emphasis',
'fett': 'strong',
u'w\xf6rtlich': 'literal',
'benannte-referenz': 'named-reference',
'unbenannte-referenz': 'anonymous-reference',
u'fu\xdfnoten-referenz': 'footnote-reference',
'zitat-referenz': 'citation-reference',
'ersetzungs-referenz': 'substitution-reference',
'ziel': 'target',
'uri-referenz': 'uri-reference',
u'unver\xe4ndert': 'raw',
u'roh': 'raw',}
"""Mapping of German role names to canonical role names for interpreted text.
"""
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -37,6 +37,7 @@ directives = {
'epigraph': 'epigraph',
'highlights': 'highlights',
'pull-quote': 'pull-quote',
'compound': 'compound',
#'questions': 'questions',
'table': 'table',
'csv-table': 'csv-table',
......@@ -92,6 +93,7 @@ roles = {
'target': 'target',
'uri-reference': 'uri-reference',
'uri': 'uri-reference',
'url': 'uri-reference',}
'url': 'uri-reference',
'raw': 'raw',}
"""Mapping of English role names to canonical role names for interpreted text.
"""
# Author: Marcelo Huerta San Martin
# Contact: richieadler@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.1.2.5 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -40,6 +40,8 @@ directives = {
u'elstara\u0135oj': 'highlights',
u'ekstera-citajxo': 'pull-quote',
u'ekstera-cita\u0135o': 'pull-quote',
u'kombinajxo': 'compound',
u'kombina\u0135o': 'compound',
#'questions': 'questions',
#'qa': 'questions',
#'faq': 'questions',
......@@ -51,7 +53,7 @@ directives = {
u'bildo': 'image',
u'figuro': 'figure',
u'inkludi': 'include',
u'senformata': 'raw',
u'senanaliza': 'raw',
u'anstatauxi': 'replace',
u'anstata\u016di': 'replace',
u'unicode': 'unicode',
......@@ -99,6 +101,8 @@ roles = {
u'celo': 'target',
u'uri-referenco': 'uri-reference',
u'uri': 'uri-reference',
u'url': 'uri-reference',}
u'url': 'uri-reference',
u'senanaliza': 'raw',
}
"""Mapping of Esperanto role names to canonical role names for interpreted text.
"""
# -*- coding: iso-8859-1 -*-
# Author: Marcelo Huerta San Martn
# Contact: richieadler@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.1.2.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -42,6 +42,8 @@ directives = {
u'epigrafe': 'epigraph',
u'destacado': 'highlights',
u'cita-destacada': 'pull-quote',
u'combinacion': 'compound',
u'combinaci\u00f3n': 'compound',
#'questions': 'questions',
#'qa': 'questions',
#'faq': 'questions',
......@@ -53,7 +55,8 @@ directives = {
u'imagen': 'image',
u'figura': 'figure',
u'incluir': 'include',
u'raw': 'raw',
u'sin-analisis': 'raw',
u'sin-an\u00e1lisis': 'raw',
u'reemplazar': 'replace',
u'unicode': 'unicode',
u'clase': 'class',
......@@ -92,7 +95,7 @@ roles = {
u'enfasis': 'emphasis',
u'\u00e9nfasis': 'emphasis',
u'destacado': 'strong',
u'literal': 'literal',
u'literal': 'literal', # "literal" is also a word in Spanish :-)
u'referencia-con-nombre': 'named-reference',
u'referencia-anonima': 'anonymous-reference',
u'referencia-an\u00f3nima': 'anonymous-reference',
......@@ -104,6 +107,8 @@ roles = {
u'referencia-uri': 'uri-reference',
u'uri': 'uri-reference',
u'url': 'uri-reference',
}
u'sin-analisis': 'raw',
u'sin-an\u00e1lisis': 'raw',
}
"""Mapping of Spanish role names to canonical role names for interpreted text.
"""
# Author: Asko Soukka
# Contact: asko.soukka@iki.fi
# Revision: $Revision: 1.1.2.1 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
# translated for each language: one in docutils/languages, the other in
# docutils/parsers/rst/languages.
"""
Finnish-language mappings for language-dependent features of
reStructuredText.
"""
__docformat__ = 'reStructuredText'
directives = {
# language-dependent: fixed
u'huomio': u'attention',
u'varo': u'caution',
u'vaara': u'danger',
u'virhe': u'error',
u'vihje': u'hint',
u't\u00e4rke\u00e4\u00e4': u'important',
u'huomautus': u'note',
u'neuvo': u'tip',
u'varoitus': u'warning',
u'kehotus': u'admonition',
u'sivupalkki': u'sidebar',
u'aihe': u'topic',
u'rivi': u'line-block',
u'tasalevyinen': u'parsed-literal',
u'ohje': u'rubric',
u'epigraafi': u'epigraph',
u'kohokohdat': u'highlights',
u'lainaus': u'pull-quote',
u'taulukko': u'table',
u'csv-taulukko': u'csv-table',
u'compound (translation required)': 'compound',
#u'kysymykset': u'questions',
u'meta': u'meta',
#u'kuvakartta': u'imagemap',
u'kuva': u'image',
u'kaavio': u'figure',
u'sis\u00e4llyt\u00e4': u'include',
u'raaka': u'raw',
u'korvaa': u'replace',
u'unicode': u'unicode',
u'luokka': u'class',
u'rooli': u'role',
u'sis\u00e4llys': u'contents',
u'kappale': u'sectnum',
#u'alaviitteet': u'footnotes',
#u'viitaukset': u'citations',
u'target-notes (translation required)': u'target-notes'}
"""Finnish name to registered (in directives/__init__.py) directive name
mapping."""
roles = {
# language-dependent: fixed
u'lyhennys': u'abbreviation',
u'akronyymi': u'acronym',
u'kirjainsana': u'acronym',
u'hakemisto': u'index',
u'luettelo': u'index',
u'alaindeksi': u'subscript',
u'indeksi': u'subscript',
u'yl\u00e4indeksi': u'superscript',
u'title-reference (translation required)': u'title-reference',
u'title (translation required)': u'title-reference',
u'pep-reference (translation required)': u'pep-reference',
u'rfc-reference (translation required)': u'rfc-reference',
u'korostus': u'emphasis',
u'vahvistus': u'strong',
u'tasalevyinen': u'literal',
u'named-reference (translation required)': u'named-reference',
u'anonymous-reference (translation required)': u'anonymous-reference',
u'footnote-reference (translation required)': u'footnote-reference',
u'citation-reference (translation required)': u'citation-reference',
u'substitution-reference (translation required)': u'substitution-reference',
u'kohde': u'target',
u'uri-reference (translation required)': u'uri-reference',
u'raw (translation required)': 'raw',}
"""Mapping of Finnish role names to canonical role names for interpreted text.
"""
# Authors: David Goodger; William Dode
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -38,6 +38,7 @@ directives = {
u'\u00E9pigraphe': 'epigraph',
u'chapeau': 'highlights',
u'accroche': 'pull-quote',
u'compound (translation required)': 'compound',
#u'questions': 'questions',
#u'qr': 'questions',
#u'faq': 'questions',
......@@ -87,6 +88,7 @@ roles = {
u'citation-r\u00E9f\u00E9rence': 'citation-reference',
u'substitution-r\u00E9f\u00E9rence': 'substitution-reference',
u'lien': 'target',
u'uri-r\u00E9f\u00E9rence': 'uri-reference',}
u'uri-r\u00E9f\u00E9rence': 'uri-reference',
u'brut': 'raw',}
"""Mapping of French role names to canonical role names for interpreted text.
"""
# Author: Nicola Larosa, Lele Gaifax
# Contact: docutils@tekNico.net, lele@seldati.it
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -36,6 +36,7 @@ directives = {
'epigrafe': 'epigraph',
'evidenzia': 'highlights',
'pull-quote (translation required)': 'pull-quote',
'compound (translation required)': 'compound',
#'questions': 'questions',
#'qa': 'questions',
#'faq': 'questions',
......@@ -79,6 +80,7 @@ roles = {
'riferimento-citazione': 'citation-reference',
'riferimento-sostituzione': 'substitution-reference',
'destinazione': 'target',
'riferimento-uri': 'uri-reference',}
'riferimento-uri': 'uri-reference',
'grezzo': 'raw',}
"""Mapping of Italian role names to canonical role names for interpreted text.
"""
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.1.4.4 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -37,6 +37,7 @@ directives = {
u'ep\u00EDgrafo': 'epigraph',
'destaques': 'highlights',
u'cita\u00E7\u00E3o-destacada': 'pull-quote',
u'compound (translation required)': 'compound',
#'perguntas': 'questions',
#'qa': 'questions',
#'faq': 'questions',
......@@ -83,7 +84,7 @@ roles = {
'rfc': 'rfc-reference',
u'\u00EAnfase': 'emphasis',
'forte': 'strong',
'literal': 'literal',
'literal': 'literal', # translation required?
u'refer\u00EAncia-por-nome': 'named-reference',
u'refer\u00EAncia-an\u00F4nima': 'anonymous-reference',
u'refer\u00EAncia-a-nota-de-rodap\u00E9': 'footnote-reference',
......@@ -92,6 +93,7 @@ roles = {
'alvo': 'target',
u'refer\u00EAncia-a-uri': 'uri-reference',
'uri': 'uri-reference',
'url': 'uri-reference',}
'url': 'uri-reference',
'cru': 'raw',}
"""Mapping of Brazilian Portuguese role names to canonical role names
for interpreted text."""
# Author: Roman Suzi
# Contact: rnd@onego.ru
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.1.2.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -23,6 +23,7 @@ directives = {
u'parsed-literal',
u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430':
u'pull-quote',
u'compound (translation required)': 'compound',
u'table (translation required)': 'table',
u'csv-table (translation required)': 'csv-table',
u'\u0441\u044b\u0440\u043e\u0439': u'raw',
......@@ -91,6 +92,7 @@ roles = {
'footnote-reference',
u'\u0446\u0438\u0442\u0430\u0442\u043d\u0430\u044f-\u0441\u0441\u044b\u043b\u043a\u0430':
'citation-reference',
u'\u0446\u0435\u043b\u044c': 'target'}
u'\u0446\u0435\u043b\u044c': 'target',
u'raw (translation required)': 'raw',}
"""Mapping of Russian role names to canonical role names for interpreted text.
"""
# Author: Miroslav Vasko
# Contact: zemiak@zoznam.sk
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -25,7 +25,7 @@ directives = {
u'rada': 'hint',
u'd\xf4le\x9eit\xe9': 'important',
u'pozn\xe1mka': 'note',
u'tip': 'tip',
u'tip (translation required)': 'tip',
u'varovanie': 'warning',
u'admonition (translation required)': 'admonition',
u'sidebar (translation required)': 'sidebar',
......@@ -36,6 +36,7 @@ directives = {
u'epigraph (translation required)': 'epigraph',
u'highlights (translation required)': 'highlights',
u'pull-quote (translation required)': 'pull-quote',
u'compound (translation required)': 'compound',
#u'questions': 'questions',
#u'qa': 'questions',
#u'faq': 'questions',
......@@ -46,7 +47,7 @@ directives = {
u'obr\xe1zok': 'image',
u'tvar': 'figure',
u'vlo\x9ei\x9d': 'include',
u'raw': 'raw',
u'raw (translation required)': 'raw',
u'nahradi\x9d': 'replace',
u'unicode': 'unicode',
u'class (translation required)': 'class',
......@@ -79,6 +80,7 @@ roles = {
u'citation-reference (translation required)': 'citation-reference',
u'substitution-reference (translation required)': 'substitution-reference',
u'target (translation required)': 'target',
u'uri-reference (translation required)': 'uri-reference',}
u'uri-reference (translation required)': 'uri-reference',
u'raw (translation required)': 'raw',}
"""Mapping of Slovak role names to canonical role names for interpreted text.
"""
# Author: Adam Chodorowski
# Contact: chodorowski@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
......@@ -35,6 +35,7 @@ directives = {
u'epigraph (translation required)': 'epigraph',
u'highlights (translation required)': 'highlights',
u'pull-quote (translation required)': 'pull-quote',
u'compound (translation required)': 'compound',
# u'fr\u00e5gor': 'questions',
# NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/:
# u'fr\u00e5gor-och-svar': 'questions',
......@@ -78,6 +79,7 @@ roles = {
u'citation-reference (translation required)': 'citation-reference',
u'substitution-reference (translation required)': 'substitution-reference',
u'target (translation required)': 'target',
u'uri-reference (translation required)': 'uri-reference',}
u'uri-reference (translation required)': 'uri-reference',
u'r\u00e5': 'raw',}
"""Mapping of Swedish role names to canonical role names for interpreted text.
"""
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.2.1 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
# translated for each language: one in docutils/languages, the other in
# docutils/parsers/rst/languages.
"""
Traditional Chinese language mappings for language-dependent features of
reStructuredText.
"""
__docformat__ = 'reStructuredText'
directives = {
# language-dependent: fixed
'attention (translation required)': 'attention',
'caution (translation required)': 'caution',
'danger (translation required)': 'danger',
'error (translation required)': 'error',
'hint (translation required)': 'hint',
'important (translation required)': 'important',
'note (translation required)': 'note',
'tip (translation required)': 'tip',
'warning (translation required)': 'warning',
'admonition (translation required)': 'admonition',
'sidebar (translation required)': 'sidebar',
'topic (translation required)': 'topic',
'line-block (translation required)': 'line-block',
'parsed-literal (translation required)': 'parsed-literal',
'rubric (translation required)': 'rubric',
'epigraph (translation required)': 'epigraph',
'highlights (translation required)': 'highlights',
'pull-quote (translation required)': 'pull-quote',
'compound (translation required)': 'compound',
#'questions (translation required)': 'questions',
'table (translation required)': 'table',
'csv-table (translation required)': 'csv-table',
#'qa (translation required)': 'questions',
#'faq (translation required)': 'questions',
'meta (translation required)': 'meta',
#'imagemap (translation required)': 'imagemap',
'image (translation required)': 'image',
'figure (translation required)': 'figure',
'include (translation required)': 'include',
'raw (translation required)': 'raw',
'replace (translation required)': 'replace',
'unicode (translation required)': 'unicode',
'class (translation required)': 'class',
'role (translation required)': 'role',
'contents (translation required)': 'contents',
'sectnum (translation required)': 'sectnum',
'section-numbering (translation required)': 'sectnum',
#'footnotes (translation required)': 'footnotes',
#'citations (translation required)': 'citations',
'target-notes (translation required)': 'target-notes',
'restructuredtext-test-directive': 'restructuredtext-test-directive'}
"""Traditional Chinese name to registered (in directives/__init__.py)
directive name mapping."""
roles = {
# language-dependent: fixed
'abbreviation (translation required)': 'abbreviation',
'ab (translation required)': 'abbreviation',
'acronym (translation required)': 'acronym',
'ac (translation required)': 'acronym',
'index (translation required)': 'index',
'i (translation required)': 'index',
'subscript (translation required)': 'subscript',
'sub (translation required)': 'subscript',
'superscript (translation required)': 'superscript',
'sup (translation required)': 'superscript',
'title-reference (translation required)': 'title-reference',
'title (translation required)': 'title-reference',
't (translation required)': 'title-reference',
'pep-reference (translation required)': 'pep-reference',
'pep (translation required)': 'pep-reference',
'rfc-reference (translation required)': 'rfc-reference',
'rfc (translation required)': 'rfc-reference',
'emphasis (translation required)': 'emphasis',
'strong (translation required)': 'strong',
'literal (translation required)': 'literal',
'named-reference (translation required)': 'named-reference',
'anonymous-reference (translation required)': 'anonymous-reference',
'footnote-reference (translation required)': 'footnote-reference',
'citation-reference (translation required)': 'citation-reference',
'substitution-reference (translation required)': 'substitution-reference',
'target (translation required)': 'target',
'uri-reference (translation required)': 'uri-reference',
'uri (translation required)': 'uri-reference',
'url (translation required)': 'uri-reference',
'raw (translation required)': 'raw',}
"""Mapping of Traditional Chinese role names to canonical role names for
interpreted text."""
# Author: Edward Loper
# Contact: edloper@gradient.cis.upenn.edu
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.1.4.4 $
# Date: $Date: 2005/01/07 13:26:03 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -28,7 +28,8 @@ Parameters:
Return it as a ``problematic`` node linked to a system message if there is a
problem.
- ``text`` is the interpreted text content.
- ``text`` is the interpreted text content, with backslash escapes converted
to nulls (``\x00``).
- ``lineno`` is the line number where the interpreted text beings.
......@@ -73,7 +74,7 @@ Interpreted role functions return a tuple of two values:
__docformat__ = 'reStructuredText'
from docutils import nodes
from docutils import nodes, utils
from docutils.parsers.rst import directives
from docutils.parsers.rst.languages import en as _fallback_language_module
......@@ -194,7 +195,7 @@ class GenericRole:
def __call__(self, role, rawtext, text, lineno, inliner,
options={}, content=[]):
return [self.node_class(rawtext, text, **options)], []
return [self.node_class(rawtext, utils.unescape(text), **options)], []
class CustomRole:
......@@ -232,7 +233,7 @@ def generic_custom_role(role, rawtext, text, lineno, inliner,
""""""
# Once nested inline markup is implemented, this and other methods should
# recursively call inliner.nested_parse().
return [nodes.inline(rawtext, text, **options)], []
return [nodes.inline(rawtext, utils.unescape(text), **options)], []
generic_custom_role.options = {'class': directives.class_option}
......@@ -264,7 +265,8 @@ def pep_reference_role(role, rawtext, text, lineno, inliner,
return [prb], [msg]
# Base URL mainly used by inliner.pep_reference; so this is correct:
ref = inliner.document.settings.pep_base_url + inliner.pep_url % pepnum
return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref, **options)], []
return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref,
**options)], []
register_canonical_role('pep-reference', pep_reference_role)
......@@ -282,11 +284,28 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner,
return [prb], [msg]
# Base URL mainly used by inliner.rfc_reference, so this is correct:
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum
node = nodes.reference(rawtext, 'RFC ' + text, refuri=ref, **options)
node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref,
**options)
return [node], []
register_canonical_role('rfc-reference', rfc_reference_role)
def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
if not options.has_key('format'):
msg = inliner.reporter.error(
'No format (Writer name) is associated with this role: "%s".\n'
'The "raw" role cannot be used directly.\n'
'Instead, use the "role" directive to create a new role with '
'an associated format.' % role, line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
node = nodes.raw(rawtext, utils.unescape(text, 1), **options)
return [node], []
raw_role.options = {'format': directives.class_option}
register_canonical_role('raw', raw_role)
######################################################################
# Register roles that are currently unimplemented.
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:22 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:04 $
# Copyright: This module has been placed in the public domain.
"""
......
# Authors: David Goodger; Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:05 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:05 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.3.2.5 $
# Date: $Date: 2005/01/07 13:26:05 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.3.2.5 $
# Date: $Date: 2005/01/07 13:26:05 $
# Copyright: This module has been placed in the public domain.
"""
......
......@@ -3,8 +3,8 @@
"""
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Revision: $Revision: 1.1.4.1 $
:Date: $Date: 2004/10/29 19:08:24 $
:Revision: $Revision: 1.1.4.4 $
:Date: $Date: 2005/01/07 13:26:05 $
:Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:23 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:05 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:20 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
"""
......
# Authors: David Goodger, Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:05 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......
# Authors: David Goodger, Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -36,6 +36,11 @@ class CallBack(Transform):
class ClassAttribute(Transform):
"""
Move the "class" attribute specified in the "pending" node into the
immediately following non-comment element.
"""
default_priority = 210
def apply(self):
......@@ -44,14 +49,17 @@ class ClassAttribute(Transform):
parent = pending.parent
child = pending
while parent:
# Check for appropriate following siblings:
for index in range(parent.index(child) + 1, len(parent)):
element = parent[index]
if isinstance(element, nodes.comment):
if (isinstance(element, nodes.Invisible) or
isinstance(element, nodes.system_message)):
continue
element.set_class(class_value)
pending.parent.remove(pending)
return
else:
# At end of section or container; apply to sibling
child = parent
parent = parent.parent
error = self.document.reporter.error(
......
# Authors: David Goodger, Ueli Schlaepfer, Dmitry Jemerov
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -33,20 +33,28 @@ class SectNum(Transform):
def apply(self):
self.maxdepth = self.startnode.details.get('depth', sys.maxint)
self.startvalue = self.startnode.details.get('start', 1)
self.prefix = self.startnode.details.get('prefix', '')
self.suffix = self.startnode.details.get('suffix', '')
self.startnode.parent.remove(self.startnode)
if self.document.settings.sectnum_xform:
self.update_section_numbers(self.document)
def update_section_numbers(self, node, prefix=(), depth=0):
depth += 1
sectnum = 1
if prefix:
sectnum = 1
else:
sectnum = self.startvalue
for child in node:
if isinstance(child, nodes.section):
numbers = prefix + (str(sectnum),)
title = child[0]
# Use &nbsp; for spacing:
generated = nodes.generated(
'', '.'.join(numbers) + u'\u00a0' * 3, CLASS='sectnum')
'', (self.prefix + '.'.join(numbers) + self.suffix
+ u'\u00a0' * 3),
CLASS='sectnum')
title.insert(0, generated)
title['auto'] = 1
if depth < self.maxdepth:
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -700,7 +700,22 @@ class Substitutions(Transform):
msg.add_backref(prbid)
ref.parent.replace(ref, prb)
else:
ref.parent.replace(ref, defs[key].get_children())
subdef = defs[key]
parent = ref.parent
index = parent.index(ref)
if (subdef.attributes.has_key('ltrim')
or subdef.attributes.has_key('trim')):
if index > 0 and isinstance(parent[index - 1],
nodes.Text):
parent.replace(parent[index - 1],
parent[index - 1].rstrip())
if (subdef.attributes.has_key('rtrim')
or subdef.attributes.has_key('trim')):
if (len(parent) > index + 1
and isinstance(parent[index + 1], nodes.Text)):
parent.replace(parent[index + 1],
parent[index + 1].lstrip())
parent.replace(ref, subdef.get_children())
self.document.substitution_refs = None # release replaced references
......@@ -767,7 +782,7 @@ class TargetNotes(Transform):
self.document.note_footnote_ref(refnode)
index = ref.parent.index(ref) + 1
reflist = [refnode]
if not self.document.settings.trim_footnote_reference_space:
if not utils.get_trim_footnote_ref_space(self.document.settings):
reflist.insert(0, nodes.Text(' '))
ref.parent.insert(index, reflist)
return footnote
# Authors: David Goodger, Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:24 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -151,9 +151,10 @@ class TestMessages(Transform):
class FinalChecks(Transform):
"""
Perform last-minute checks.
Perform last-minute checks and transforms.
- Check for dangling references (incl. footnote & citation).
- Check for illegal transitions, move transitions.
"""
default_priority = 840
......@@ -210,6 +211,72 @@ class FinalCheckVisitor(nodes.SparseNodeVisitor):
visit_footnote_reference = visit_citation_reference = visit_reference
def visit_transition(self, node):
"""
Move transitions at the end of sections up the tree. Complain
on transitions after a title, at the beginning or end of the
document, and after another transition.
For example, transform this::
<section>
...
<transition>
<section>
...
into this::
<section>
...
<transition>
<section>
...
"""
index = node.parent.index(node)
error = None
if (index == 0 or
isinstance(node.parent[0], nodes.title) and
(index == 1 or
isinstance(node.parent[1], nodes.subtitle) and
index == 2)):
assert (isinstance(node.parent, nodes.document) or
isinstance(node.parent, nodes.section))
error = self.document.reporter.error(
'Document or section may not begin with a transition.',
line=node.line)
elif isinstance(node.parent[index - 1], nodes.transition):
error = self.document.reporter.error(
'At least one body element must separate transitions; '
'adjacent transitions are not allowed.', line=node.line)
if error:
# Insert before node and update index.
node.parent.insert(index, error)
index += 1
assert index < len(node.parent)
if index != len(node.parent) - 1:
# No need to move the node.
return
# Node behind which the transition is to be moved.
sibling = node
# While sibling is the last node of its parent.
while index == len(sibling.parent) - 1:
sibling = sibling.parent
# If sibling is the whole document (i.e. it has no parent).
if sibling.parent is None:
# Transition at the end of document. Do not move the
# transition up, and place an error behind.
error = self.document.reporter.error(
'Document may not end with a transition.',
line=node.line)
node.parent.insert(node.parent.index(node) + 1, error)
return
index = sibling.parent.index(sibling)
# Remove the original transition node.
node.parent.remove(node)
# Insert the transition after the sibling.
sibling.parent.insert(index + 1, node)
class InternalAttributeExposer(nodes.GenericNodeVisitor):
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:20 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:02 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -92,7 +92,7 @@ class Reporter:
exceptions will be raised, halting execution.
- `debug`: Show debug (level=0) system messages?
- `stream`: Where warning output is sent. Can be file-like (has a
``.write`` method), a string (file name, opened for writing),
``.write`` method), a string (file name, opened for writing),
'' (empty string, for discarding all stream messages) or
`None` (implies `sys.stderr`; default).
- `encoding`: The encoding for stderr output.
......@@ -100,7 +100,7 @@ class Reporter:
"""
self.source = source
"""The path to or description of the source data."""
if stream is None:
stream = sys.stderr
elif type(stream) in (StringType, UnicodeType):
......@@ -450,6 +450,34 @@ def relative_path(source, target):
parts = ['..'] * (len(source_parts) - 1) + target_parts
return '/'.join(parts)
def get_stylesheet_reference(settings, relative_to=None):
"""
Retrieve a stylesheet reference from the settings object.
"""
if settings.stylesheet_path:
assert not settings.stylesheet, \
'stylesheet and stylesheet_path are mutually exclusive.'
if relative_to == None:
relative_to = settings._destination
return relative_path(relative_to, settings.stylesheet_path)
else:
return settings.stylesheet
def get_trim_footnote_ref_space(settings):
"""
Return whether or not to trim footnote space.
If trim_footnote_reference_space is not None, return it.
If trim_footnote_reference_space is None, return False unless the
footnote reference style is 'superscript'.
"""
if settings.trim_footnote_reference_space is None:
return hasattr(settings, 'footnote_references') and \
settings.footnote_references == 'superscript'
else:
return settings.trim_footnote_reference_space
def get_source_line(node):
"""
Return the "source" and "line" attributes from the `node` given or from
......@@ -460,3 +488,92 @@ def get_source_line(node):
return node.source, node.line
node = node.parent
return None, None
def escape2null(text):
"""Return a string with escape-backslashes converted to nulls."""
parts = []
start = 0
while 1:
found = text.find('\\', start)
if found == -1:
parts.append(text[start:])
return ''.join(parts)
parts.append(text[start:found])
parts.append('\x00' + text[found+1:found+2])
start = found + 2 # skip character after escape
def unescape(text, restore_backslashes=0):
"""
Return a string with nulls removed or restored to backslashes.
Backslash-escaped spaces are also removed.
"""
if restore_backslashes:
return text.replace('\x00', '\\')
else:
for sep in ['\x00 ', '\x00\n', '\x00']:
text = ''.join(text.split(sep))
return text
class DependencyList:
"""
List of dependencies, with file recording support.
Note that the output file is not automatically closed. You have
to explicitly call the close() method.
"""
def __init__(self, output_file=None, dependencies=[]):
"""
Initialize the dependency list, automatically setting the
output file to `output_file` (see `set_output()`) and adding
all supplied dependencies.
"""
self.set_output(output_file)
for i in dependencies:
self.add(i)
def set_output(self, output_file):
"""
Set the output file and clear the list of already added
dependencies.
`output_file` must be a string. The specified file is
immediately overwritten.
If output_file is '-', the output will be written to stdout.
If it is None, no file output is done when calling add().
"""
self.list = []
if output_file == '-':
self.file = sys.stdout
elif output_file:
self.file = open(output_file, 'w')
else:
self.file = None
def add(self, filename):
"""
If the dependency `filename` has not already been added,
append it to self.list and print it to self.file if self.file
is not None.
"""
if not filename in self.list:
self.list.append(filename)
if self.file is not None:
print >>self.file, filename
def close(self):
"""
Close the output file.
"""
self.file.close()
self.file = None
def __repr__(self):
if self.file:
output_file = self.file.name
else:
output_file = None
return '%s(%r, %s)' % (self.__class__.__name__, output_file, self.list)
# Authors: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:25 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......
# Authors: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:25 $
# Revision: $Revision: 1.2.10.7 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:25 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......@@ -11,6 +11,7 @@ PEP HTML Writer.
__docformat__ = 'reStructuredText'
import random
import sys
import docutils
from docutils import frontend, nodes, utils
......@@ -31,12 +32,7 @@ class Writer(html4css1.Writer):
{'default': '..', 'metavar': '<URL>'}),
('Home URL prefix for PEPs. Default is "." (current directory).',
['--pep-home'],
{'default': '.', 'metavar': '<URL>'}),
# Workaround for SourceForge's broken Python
# (``import random`` causes a segfault).
(frontend.SUPPRESS_HELP,
['--no-random'],
{'action': 'store_true', 'validator': frontend.validate_boolean}),))
{'default': '.', 'metavar': '<URL>'}),))
settings_default_overrides = {'footnote_references': 'brackets'}
......@@ -70,14 +66,10 @@ class Writer(html4css1.Writer):
header = self.document[index]
pepnum = header[0][1].astext()
subs['pep'] = pepnum
if settings.no_random:
subs['banner'] = 0
else:
import random
subs['banner'] = random.randrange(64)
subs['banner'] = random.randrange(64)
try:
subs['pepnum'] = '%04i' % int(pepnum)
except:
except ValueError:
subs['pepnum'] = pepnum
subs['title'] = header[1][1].astext()
subs['body'] = ''.join(
......
# Authors: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1.4.1 $
# Date: $Date: 2004/10/29 19:08:25 $
# Revision: $Revision: 1.2.10.6 $
# Date: $Date: 2005/01/07 13:26:06 $
# Copyright: This module has been placed in the public domain.
"""
......
import sys, os
dirname = os.path.dirname(__file__)
sys.path.append(os.path.join(dirname, 'third_party', 'docutils'))
sys.path.append(os.path.join(dirname, 'third_party', 'docutils', 'extras'))
This directory contains some third party packages.
To upgrade docutils:
- untar docutils-XX.tar.gz inside the third_party directoy
- rename it to 'docutils'
- remove docutils/tools/editors/emacs/* (files are GPLed)
- update the files in the CVS
===============================================
Inside A Docutils Command-Line Front-End Tool
===============================================
:Author: David Goodger
:Contact: goodger@python.org
:Date: $Date: 2004/10/29 19:08:16 $
:Revision: $Revision: 1.1.4.1 $
:Copyright: This document has been placed in the public domain.
`The Docutils Publisher`_ class was set up to make building
command-line tools easy. All that's required is to choose components
and supply settings for variations. Let's take a look at a typical
command-line front-end tool, ``tools/rst2html.py``, from top to
bottom.
On Unixish systems, it's best to make the file executable (``chmod +x
file``), and supply an interpreter on the first line, the "shebang" or
"hash-bang" line::
#!/usr/bin/env python
Windows systems can be set up to associate the Python interpreter with
the ``.py`` extension.
Next are some comments providing metadata::
# Author: David Goodger
# Contact: goodger@python.org
# Revision: $Revision: ...
# Date: $Date: ...
# Copyright: This module has been placed in the public domain.
The module docstring describes the purpose of the tool::
"""
A minimal front end to the Docutils Publisher, producing HTML.
"""
This next block attempts to invoke locale support for
internationalization services, specifically text encoding. It's not
supported on all platforms though, so it's forgiving::
try:
import locale
locale.setlocale(locale.LC_ALL, '')
except:
pass
The real work will be done by the code that's imported here::
from docutils.core import publish_cmdline, default_description
We construct a description of the tool, for command-line help::
description = ('Generates (X)HTML documents from standalone '
'reStructuredText sources. ' + default_description)
Now we call the Publisher convenience function, which takes over.
Most of it's defaults are used ("standalone" Reader,
"reStructuredText" Parser, etc.). The HTML Writer is chosen by name,
and a description for command-line help is passed in::
publish_cmdline(writer_name='html', description=description)
That's it! `The Docutils Publisher`_ takes care of the rest.
.. _The Docutils Publisher: ./publisher.html
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment