summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstrank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2008-07-28 15:24:27 +0000
committerstrank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2008-07-28 15:24:27 +0000
commit2ec2ed70dfae0edfb9c8df437cfa20b41e971fd1 (patch)
tree94b3b00b24408e3df8c0ef6ade26549f7355dcec
parentce856ebd1cf2b6781a5c84b4627db2e47c9ffa04 (diff)
downloaddocutils-2ec2ed70dfae0edfb9c8df437cfa20b41e971fd1.tar.gz
Merged trunk r5043:5619 to adjacent-citations branch.
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/adjacent-citations@5621 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--FAQ.txt16
-rw-r--r--HISTORY.txt45
-rw-r--r--README.txt5
-rw-r--r--RELEASE-NOTES.txt47
-rw-r--r--THANKS.txt2
-rw-r--r--docs/api/cmdline-tool.txt2
-rw-r--r--docs/api/publisher.txt49
-rw-r--r--docs/dev/distributing.txt4
-rw-r--r--docs/dev/hacking.txt4
-rw-r--r--docs/dev/release.txt6
-rw-r--r--docs/dev/repository.txt8
-rw-r--r--docs/dev/rst/alternatives.txt2
-rw-r--r--docs/dev/testing.txt2
-rw-r--r--docs/dev/todo.txt2
-rw-r--r--docs/dev/website.txt62
-rw-r--r--docs/howto/html-stylesheets.txt4
-rw-r--r--docs/howto/rst-directives.txt4
-rw-r--r--docs/ref/rst/restructuredtext.txt20
-rw-r--r--docs/user/config.txt6
-rw-r--r--docs/user/emacs.txt629
-rw-r--r--docs/user/latex.txt44
-rw-r--r--docs/user/links.txt144
-rw-r--r--docs/user/mailing-lists.txt4
-rw-r--r--docutils/__init__.py2
-rw-r--r--docutils/core.py8
-rw-r--r--docutils/frontend.py17
-rw-r--r--docutils/languages/__init__.py2
-rw-r--r--docutils/languages/pt_br.py2
-rw-r--r--docutils/nodes.py83
-rw-r--r--docutils/parsers/__init__.py2
-rw-r--r--docutils/parsers/rst/directives/__init__.py2
-rw-r--r--docutils/parsers/rst/directives/admonitions.py2
-rw-r--r--docutils/parsers/rst/directives/body.py2
-rw-r--r--docutils/parsers/rst/directives/images.py4
-rw-r--r--docutils/parsers/rst/directives/misc.py24
-rw-r--r--docutils/parsers/rst/directives/parts.py4
-rw-r--r--docutils/parsers/rst/directives/tables.py24
-rw-r--r--docutils/parsers/rst/languages/__init__.py2
-rw-r--r--docutils/parsers/rst/languages/de.py2
-rw-r--r--docutils/parsers/rst/roles.py12
-rw-r--r--docutils/parsers/rst/states.py11
-rw-r--r--docutils/readers/__init__.py2
-rw-r--r--docutils/readers/python/__init__.py2
-rw-r--r--docutils/readers/python/moduleparser.py64
-rw-r--r--docutils/statemachine.py10
-rw-r--r--docutils/transforms/frontmatter.py2
-rw-r--r--docutils/transforms/parts.py4
-rw-r--r--docutils/transforms/references.py30
-rw-r--r--docutils/transforms/writer_aux.py2
-rw-r--r--docutils/utils.py8
-rw-r--r--docutils/writers/__init__.py2
-rw-r--r--docutils/writers/html4css1/__init__.py65
-rw-r--r--docutils/writers/html4css1/html4css1.css2
-rw-r--r--docutils/writers/latex2e/__init__.py247
-rw-r--r--docutils/writers/newlatex2e/__init__.py4
-rw-r--r--docutils/writers/newlatex2e/unicode_map.py2
-rw-r--r--docutils/writers/s5_html/__init__.py2
-rw-r--r--extras/optparse.py18
-rw-r--r--extras/roman.py2
-rwxr-xr-xsetup.py2
-rw-r--r--test/DocutilsTestSupport.py2
-rwxr-xr-xtest/coverage.sh12
-rw-r--r--test/docutils_difflib.py28
-rw-r--r--test/functional/expected/compact_lists.html2
-rw-r--r--test/functional/expected/dangerous.html2
-rw-r--r--test/functional/expected/field_name_limit.html2
-rw-r--r--test/functional/expected/latex_docinfo.tex7
-rw-r--r--test/functional/expected/misc_rst_html4css1.html2
-rw-r--r--test/functional/expected/pep_html.html20
-rw-r--r--test/functional/expected/standalone_rst_html4css1.html281
-rw-r--r--test/functional/expected/standalone_rst_latex.tex100
-rw-r--r--test/functional/expected/standalone_rst_pseudoxml.txt252
-rw-r--r--test/functional/expected/standalone_rst_s5_html_1.html10
-rw-r--r--test/functional/expected/standalone_rst_s5_html_2.html10
-rw-r--r--test/functional/input/data/standard.txt5
-rw-r--r--test/functional/tests/standalone_rst_html4css1.py2
-rw-r--r--test/functional/tests/standalone_rst_latex.py2
-rw-r--r--test/functional/tests/standalone_rst_pseudoxml.py2
-rwxr-xr-xtest/functional/tests/standalone_rst_s5_html_1.py2
-rwxr-xr-xtest/functional/tests/standalone_rst_s5_html_2.py2
-rwxr-xr-xtest/test_dependencies.py4
-rwxr-xr-xtest/test_functional.py13
-rwxr-xr-xtest/test_io.py2
-rwxr-xr-xtest/test_language.py8
-rwxr-xr-xtest/test_nodes.py18
-rw-r--r--test/test_parsers/test_parser.py31
-rwxr-xr-xtest/test_parsers/test_rst/test_citations.py45
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_block_quotes.py2
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_class.py2
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_images.py2
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_parsed_literals.py2
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_raw.py18
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_sectnum.py2
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_tables.py20
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_title.py2
-rwxr-xr-xtest/test_publisher.py2
-rwxr-xr-xtest/test_settings.py4
-rwxr-xr-xtest/test_transforms/test___init__.py2
-rwxr-xr-xtest/test_transforms/test_expose_internals.py2
-rwxr-xr-xtest/test_transforms/test_writer_aux.py2
-rwxr-xr-xtest/test_utils.py6
-rwxr-xr-xtest/test_writers/test_docutils_xml.py2
-rwxr-xr-xtest/test_writers/test_html4css1_misc.py2
-rwxr-xr-xtest/test_writers/test_html4css1_parts.py16
-rwxr-xr-xtest/test_writers/test_html4css1_template.py8
-rwxr-xr-xtest/test_writers/test_latex2e.py29
-rwxr-xr-xtest/test_writers/test_null.py2
-rwxr-xr-xtest/test_writers/test_pseudoxml.py2
-rwxr-xr-xtest/test_writers/test_s5.py4
-rwxr-xr-xtools/dev/create_unimap.py4
-rwxr-xr-xtools/dev/profile_docutils.py4
-rwxr-xr-xtools/dev/unicode2rstsubs.py4
-rw-r--r--tools/editors/emacs/README.txt5
-rw-r--r--tools/editors/emacs/rst.el1281
-rw-r--r--tools/editors/emacs/tests/Makefile11
-rwxr-xr-xtools/quicktest.py4
116 files changed, 2297 insertions, 1801 deletions
diff --git a/FAQ.txt b/FAQ.txt
index c6b2918e3..604eca018 100644
--- a/FAQ.txt
+++ b/FAQ.txt
@@ -203,6 +203,8 @@ be readable as plaintext, and most operating systems already associate
require that users alter their OS settings, which is something that
many users will not be willing or able to do.
+Also see `What's the official MIME type for reStructuredText data?`_
+
Are there any reStructuredText editor extensions?
-------------------------------------------------
@@ -915,6 +917,20 @@ list.
__ mailto:cben@users.sf.net
+What's the official MIME type for reStructuredText data?
+--------------------------------------------------------
+
+While there is no registered MIME type for reStructuredText, the
+"official unofficial" standard MIME type is "text/x-rst". This was
+invented for the build system for PEPs (Python Enhancement Proposals),
+and it's used by the python.org web site build system.
+
+(The "x-" prefix means it's an unregistered MIME type.)
+
+Also see `What's the standard filename extension for a
+reStructuredText file?`_
+
+
HTML Writer
===========
diff --git a/HISTORY.txt b/HISTORY.txt
index 4ef02f607..78a1a87aa 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -14,9 +14,26 @@
.. contents::
-Changes Since 0.4
+Changes Since 0.5
=================
+* General:
+
+ - Backwards-compatible changes to remove python2.6 -3 deprecation warnings
+ - Text nodes now subclass unicode rather than UserString
+ (which is gone in python 3.0)
+
+* docutils/nodes.py:
+
+ - Added ``Element.__contains__`` method, for the in-operator.
+
+* docutils/writers/latex2e/__init__.py:
+
+ - Change: has_key for dictionaries (not Nodes) to in-operator.
+
+Release 0.5 (2008-06-25)
+========================
+
* docutils/languages/he.py: Added to project: Hebrew mappings by
Meir Kriheli.
@@ -46,6 +63,7 @@ Changes Since 0.4
* docutils/parsers/rst/states.py:
+ - Allow ``+`` and ``:`` in reference names.
- Unquoted targets beginning with an underscore (``.. __target:
URI``) are no longer accepted.
- Added support for multiple attributions in a physical block quote
@@ -99,6 +117,8 @@ Changes Since 0.4
universally supported now).
- ``template.txt`` is now opened in text mode instead of binary mode
(to ensure Windows compatibility).
+ - ``a`` elements now have an "internal" or "external" class,
+ depending on reference type.
* docutils/writers/html4css1/template.txt: Added to project.
@@ -114,6 +134,25 @@ Changes Since 0.4
* docutils/writers/latex2e/__init__.py:
+ - Add ``--literal-block-env``
+ - Fix: escaping ``%`` in href urls.
+ - Move usepackage hyperref after stylesheet inclusion.
+ - Fix: scrartcl does not have chapter but scrreprt.
+ - Add newline after ``\end{verbatim}``.
+ - Merge smaller differences from latex2e_adaptive_preamble.
+ - Add ``use-part-section``.
+ - Put leavevmode before longtable to avoid having it moved before sub/pargraph.
+ - Using leavemode option_list no longer needs to check if parent
+ is a definition list.
+ - Append ``\leavemode`` to definition list terms.
+ - No longer write visit\_/depart_definition_list_item comments to
+ output.
+ - Table column width with 3 decimal places.
+ - Add table stubs support (boldfont).
+ - Add assemble_parts to writer.
+ - Add simply support for nested tables.
+ - Fix verbatim in tables if use-verbatim-when-possible.
+ - Use section commands down to subparagraph.
- Put ensuremath around some latin1 chars.
- Set ``usepackage[utf8x]{inputenc}`` for utf-8.
- New option ``--use-bibtex=style,db1,db2``.
@@ -693,7 +732,7 @@ Release 0.3.7 (2004-12-24)
- 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).
+ - Added ``compound`` directive (thanks to Lea Wiemann).
* docutils/parsers/rst/directives/misc.py:
@@ -849,7 +888,7 @@ General:
- Added ``THANKS.txt`` from "Acknowledgements" in ``HISTORY.txt``.
- Added "How To Report Bugs" to ``BUGS.txt``.
- Went through all the sources and docs (including under web/) and
- updated links. Mostly done by Felix Wiemann; thanks Felix!
+ updated links. Mostly done by Lea Wiemann; thanks Lea!
(Still need to update links in the sandboxes.)
Specific:
diff --git a/README.txt b/README.txt
index 53384ca25..feb4f3edb 100644
--- a/README.txt
+++ b/README.txt
@@ -149,8 +149,9 @@ Project Files & Directories
* docutils: The project source directory, installed as a Python
package.
-* extras: Directory for third-party modules that Docutils depends on.
- These are only installed if they're not already present.
+* extras: Directory for third-party modules that Docutils depends on
+ (roman.py, optparse.py, textwrap.py). These are only installed if
+ they're not already present.
* docs: The project documentation directory. Read ``docs/index.txt``
for an overview.
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index cfe2ce8f7..d0ecf8eae 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -2,8 +2,8 @@
Docutils Release Notes
========================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Date: $Date$
:Revision: $Revision$
:Web site: http://docutils.sourceforge.net/
@@ -18,9 +18,30 @@ more detailed list of changes, please see the `Docutils History`_.
.. contents::
-Changes Since 0.4
+Changes Since 0.5
=================
+
+Release 0.5 (2008-06-25)
+========================
+
+Components:
+
+* HTML writer.
+
+ - Dropped all ``name`` attributes of ``a`` elements (``id`` is
+ universally supported now).
+
+* LaTeX2e writer:
+
+ - Better bibTeX citation support.
+ - Add ``--literal-block-env``
+
+* PEP writer:
+
+ - Changed to support new python.org website structure and
+ pep2pyramid.py.
+
reStructuredText:
* Changed the directive API to a new object-oriented system.
@@ -30,6 +51,26 @@ reStructuredText:
__ docs/howto/rst-directives.html
+* Allow ``+`` and ``:`` in reference names requested for citations.
+
+Documentation:
+
+* Added `Deploying Docutils Securely`__
+
+ __ docs/howto/security.txt
+
+Internationalization:
+
+* Added hebrew mappings.
+
+General:
+
+* Configuration files are now assumed and required to be
+ UTF-8-encoded.
+
+* Added docutils/writers/html4css1/template.txt.
+
+* Enhance emacs support.
Release 0.4 (2006-01-09)
========================
diff --git a/THANKS.txt b/THANKS.txt
index ac66cdf61..41a772788 100644
--- a/THANKS.txt
+++ b/THANKS.txt
@@ -150,7 +150,7 @@ donations, tasty treats, and related projects:
* Barry Warsaw
* Wu Wei
* Edward Welbourne
-* Felix Wiemann
+* Lea Wiemann
* Anthony Williams
* Ka-Ping Yee
* Moshe Zadka
diff --git a/docs/api/cmdline-tool.txt b/docs/api/cmdline-tool.txt
index 200113f99..549ec38f8 100644
--- a/docs/api/cmdline-tool.txt
+++ b/docs/api/cmdline-tool.txt
@@ -55,7 +55,7 @@ We construct a description of the tool, for command-line help::
'reStructuredText sources. ' + default_description)
Now we call the Publisher convenience function, which takes over.
-Most of it's defaults are used ("standalone" Reader,
+Most of its 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::
diff --git a/docs/api/publisher.txt b/docs/api/publisher.txt
index 11f9aaaad..9717fcc34 100644
--- a/docs/api/publisher.txt
+++ b/docs/api/publisher.txt
@@ -11,13 +11,28 @@
.. contents::
+The ``docutils.core.Publisher`` class is the core of Docutils,
+managing all the processing and relationships between components. See
+`PEP 258`_ for an overview of Docutils components.
+
+The ``docutils.core.publish_*`` convenience functions are the normal
+entry points for using Docutils as a library.
+
+See `Inside A Docutils Command-Line Front-End Tool`_ for an overview
+of a typical Docutils front-end tool, including how the Publisher
+class is used.
+
+.. _PEP 258: ../peps/pep-0258.html
+.. _Inside A Docutils Command-Line Front-End Tool: ./cmdline-tool.html
+
+
Publisher Convenience Functions
===============================
Each of these functions set up a ``docutils.core.Publisher`` object,
then call its ``publish`` method. ``docutils.core.Publisher.publish``
-handles everything else. There are five convenience functions in the
-``docutils.core`` module:
+handles everything else. There are several convenience functions in
+the ``docutils.core`` module:
:_`publish_cmdline`: for command-line front-end tools, like
``rst2html.py``. There are several examples in the ``tools/``
@@ -45,8 +60,8 @@ handles everything else. There are five convenience functions in the
`publish_from_doctree`_.
:_`publish_from_doctree`: for programmatic use to render from an
- existing document tree data structure (doctree); returns a pair of
- encoded string output and document parts.
+ existing document tree data structure (doctree); returns the encoded
+ output as a string.
:_`publish_programmatically`: for custom programmatic use. This
function implements common code and is used by ``publish_file``,
@@ -99,8 +114,7 @@ dictionary of document parts. Dictionary keys are the names of parts,
and values are Unicode strings.
Each Writer component may publish a different set of document parts,
-described below. Currently only the HTML Writer implements more than
-the "whole" part.
+described below. Not all writers implement all parts.
Parts Provided By All Writers
@@ -254,3 +268,26 @@ Parts Provided by the S5/HTML Writer
````````````````````````````````````
The S5/HTML writer provides the same parts as the `HTML writer`_.
+
+Parts Provided by the LaTeX2e Writer
+````````````````````````````````````
+
+__`head_prefix`
+ ``parts['head_prefix']`` contains the LaTeX document class, package
+ and stylesheet inclusion.
+
+__`head`
+ ``parts['head']`` currently is empty.
+
+__`body_prefix`
+ ``parts['body_prefix']`` contains the LaTeX ``\begin{document}`` and
+ title page.
+
+__`body`
+ ``parts['body']`` contains the LaTeX document content, less
+ the ``\begin{document}`` and ``\end{document}`` tags themselves.
+
+__`body_suffix`
+ ``parts['body_suffix']`` contains the LaTeX ``\end{document}``.
+
+
diff --git a/docs/dev/distributing.txt b/docs/dev/distributing.txt
index c81807279..f50f6a7af 100644
--- a/docs/dev/distributing.txt
+++ b/docs/dev/distributing.txt
@@ -2,8 +2,8 @@
Docutils_ Distributor's Guide
===============================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Revision: $Revision$
:Date: $Date$
:Copyright: This document has been placed in the public domain.
diff --git a/docs/dev/hacking.txt b/docs/dev/hacking.txt
index d0ec9a3fb..243fd50b6 100644
--- a/docs/dev/hacking.txt
+++ b/docs/dev/hacking.txt
@@ -2,8 +2,8 @@
Docutils_ Hacker's Guide
==========================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Revision: $Revision$
:Date: $Date$
:Copyright: This document has been placed in the public domain.
diff --git a/docs/dev/release.txt b/docs/dev/release.txt
index 8bb159838..753091238 100644
--- a/docs/dev/release.txt
+++ b/docs/dev/release.txt
@@ -2,7 +2,7 @@
Docutils_ Release Procedure
=============================
-:Authors: David Goodger; Felix Wiemann; open to all Docutils developers
+:Authors: David Goodger; Lea Wiemann; open to all Docutils developers
:Contact: goodger@python.org
:Date: $Date$
:Revision: $Revision$
@@ -12,7 +12,7 @@
Steps in boldface text are *not* covered by the release script at
-sandbox/fwiemann/release.sh. "Not covered" means that you aren't even
+sandbox/infrastructure/release.sh. "Not covered" means that you aren't even
reminded of them.
.. Note:: This document does not cover branching and tagging, but the
@@ -147,6 +147,8 @@ reminded of them.
* Update the web page (web/index.txt).
* Run docutils-update on the server.
+
+* **Run alltests.py with svn version**
* **Send announcement email to:**
diff --git a/docs/dev/repository.txt b/docs/dev/repository.txt
index 0ec415a70..b6e3a606d 100644
--- a/docs/dev/repository.txt
+++ b/docs/dev/repository.txt
@@ -2,8 +2,8 @@
The Docutils_ Subversion Repository
=====================================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Revision: $Revision$
:Date: $Date$
:Copyright: This document has been placed in the public domain.
@@ -114,7 +114,7 @@ Information for Developers
If you would like to have write access to the repository, register
with SourceForge.net_ and BerliOS_, and send your SourceForge.net and
-BerliOS user names to `Felix Wiemann <Felix.Wiemann@ososo.de>`_.
+BerliOS user names to `Lea Wiemann <LeWiemann@gmail.com>`_.
(Note that there may be a delay of several hours until you can commit
changes to the repository.)
@@ -167,7 +167,7 @@ Migration from SourceForge.net
Developers who had write-access for Docutils' CVS repository on
SourceForge.net should `register with BerliOS`__ and send a message
-with their BerliOS user name to `Felix Wiemann`_.
+with their BerliOS user name to `Lea Wiemann`_.
__ https://developer.berlios.de/account/register.php
diff --git a/docs/dev/rst/alternatives.txt b/docs/dev/rst/alternatives.txt
index 443203fb7..ba5c7f448 100644
--- a/docs/dev/rst/alternatives.txt
+++ b/docs/dev/rst/alternatives.txt
@@ -1320,7 +1320,7 @@ Perhaps line block syntax like this would do::
| Ethan Hunt
| Jim Phelps
| Claire Phelps
- | CIA: Felix Leiter
+ | CIA: Lea Leiter
Note that the "nested" list does not have nested syntax (the "|" are
not further indented); the leading whitespace would still be
diff --git a/docs/dev/testing.txt b/docs/dev/testing.txt
index 0308803c5..36256be24 100644
--- a/docs/dev/testing.txt
+++ b/docs/dev/testing.txt
@@ -2,7 +2,7 @@
Docutils_ Testing
===================
-:Authors: Felix Wiemann <Felix.Wiemann@ososo.de>;
+:Authors: Lea Wiemann <LeWiemann@gmail.com>;
David Goodger <goodger@python.org>
:Revision: $Revision$
:Date: $Date$
diff --git a/docs/dev/todo.txt b/docs/dev/todo.txt
index 9142a18e7..8e8d74b0e 100644
--- a/docs/dev/todo.txt
+++ b/docs/dev/todo.txt
@@ -873,7 +873,7 @@ __ rst/alternatives.html#or-not-to-do
This may not be just a parser issue; it may need framework support.
Mailing list threads: `Images in both HTML and LaTeX`__ (especially
- `this summary of Felix's objections`__), `more-universal links?`__,
+ `this summary of Lea's objections`__), `more-universal links?`__,
`Output-format-sensitive link targets?`__
__ http://thread.gmane.org/gmane.text.docutils.user/1239
diff --git a/docs/dev/website.txt b/docs/dev/website.txt
index 4d7ba0398..3f39c584c 100644
--- a/docs/dev/website.txt
+++ b/docs/dev/website.txt
@@ -10,14 +10,46 @@
The Docutils web site, <http://docutils.sourceforge.net/>, is
maintained automatically by the ``docutils-update`` script, run as an
-hourly cron job on shell.berlios.de (by user "felixwiemann"). The
-script will process any .txt file which is newer than the
-corresponding .html file in the project's web directory on
-shell.berlios.de (``/home/groups/docutils/htdocs/aux/htdocs/``) and
-upload the changes to the web site at SourceForge. For a new .txt
-file, just SSH to ``<username>@shell.berlios.de`` and ::
+hourly cron job on shell.berlios.de (by user "wiemann"). The script
+will process any .txt file which is newer than the corresponding .html
+file in the project's web directory on shell.berlios.de
+(``/home/groups/docutils/htdocs/aux/htdocs/``) and upload the changes
+to the web site at SourceForge.
+
+Please **do not** add any generated .html files to the Docutils
+repository. They will be generated automatically after a one-time
+setup (`described below`__).
+
+__ `Adding .txt Files`_
+
+The docutils-update__ script is located at
+``sandbox/infrastructure/docutils-update``.
+
+__ http://docutils.sf.net/sandbox/infrastructure/docutils-update
+
+If you want to share files via the web, you can upload them using the
+uploaddocutils.sh__ script
+(``sandbox/infrastructure/uploaddocutils.sh``).
+
+__ http://docutils.sf.net/sandbox/infrastructure/uploaddocutils.sh
+
+
+Adding Directories
+==================
+
+After adding directories to SVN, allow the update script to run once
+to create the directories in the filesystem before preparing for HTML
+processing as described below.
+
+
+Adding .txt Files
+=================
+
+For a new .txt file, just SSH to ``<username>@shell.berlios.de`` and
+::
cd /home/groups/docutils/htdocs/aux/htdocs/
+ cd [path to your file's subdirectory]
touch filename.html
chmod g+w filename.html
sleep 1
@@ -27,19 +59,15 @@ The script will take care of the rest within an hour. Thereafter
whenever the .txt file is modified (checked in to SVN), the .html will
be regenerated automatically.
-After adding directories to SVN, allow the script to run once to
-create the directories in the filesystem before preparing for HTML
-processing as described above.
-The docutils-update__ script is located at
-``sandbox/infrastructure/docutils-update``.
-
-__ http://docutils.sf.net/sandbox/infrastructure/docutils-update
-
-If you want to share files via the web, you can upload them using the
-uploaddocutils.sh__ script (``sandbox/fwiemann/uploaddocutils.sh``).
+Renoving Files & Directories
+============================
-__ http://docutils.sf.net/sandbox/fwiemann/uploaddocutils.sh
+Removing files and directories from SVN will not trigger their removal
+from the web site. Files and directories must be manually removed
+from both berlios.de (under
+``/home/groups/docutils/htdocs/aux/htdocs/``) and from sourceforge.net
+(under ``/home/groups/d/do/docutils/htdocs/``).
..
diff --git a/docs/howto/html-stylesheets.txt b/docs/howto/html-stylesheets.txt
index 580045b88..8a8b0dfa9 100644
--- a/docs/howto/html-stylesheets.txt
+++ b/docs/howto/html-stylesheets.txt
@@ -2,8 +2,8 @@
Writing HTML (CSS) Stylesheets for Docutils_
==============================================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Date: $Date$
:Revision: $Revision$
:Copyright: This document has been placed in the public domain.
diff --git a/docs/howto/rst-directives.txt b/docs/howto/rst-directives.txt
index 4c4441155..72107d50d 100644
--- a/docs/howto/rst-directives.txt
+++ b/docs/howto/rst-directives.txt
@@ -2,9 +2,9 @@
Creating reStructuredText_ Directives
=======================================
-:Authors: Dethe Elza, David Goodger, Felix Wiemann
+:Authors: Dethe Elza, David Goodger, Lea Wiemann
:Contact: delza@enfoldingsystems.com, goodger@python.org,
- Felix.Wiemann@ososo.de
+ LeWiemann@gmail.com
:Date: $Date$
:Revision: $Revision$
:Copyright: This document has been placed in the public domain.
diff --git a/docs/ref/rst/restructuredtext.txt b/docs/ref/rst/restructuredtext.txt
index 09c48486b..f9dcdcd10 100644
--- a/docs/ref/rst/restructuredtext.txt
+++ b/docs/ref/rst/restructuredtext.txt
@@ -378,11 +378,11 @@ Reference Names
===============
Simple reference names are single words consisting of alphanumerics
-plus isolated (no two adjacent) internal hyphens, underscores, and
-periods; no whitespace or other characters are allowed. Footnote
-labels (Footnotes_ & `Footnote References`_), citation labels
-(Citations_ & `Citation References`_), `interpreted text`_ roles, and
-some `hyperlink references`_ use the simple reference name syntax.
+plus isolated (no two adjacent) internal hyphens, underscores,
+periods, colons and plus signs; no whitespace or other characters are
+allowed. Footnote labels (Footnotes_ & `Footnote References`_), citation
+labels (Citations_ & `Citation References`_), `interpreted text`_ roles,
+and some `hyperlink references`_ use the simple reference name syntax.
Reference names using punctuation or whose names are phrases (two or
more space-separated words) are called "phrase-references".
@@ -2222,13 +2222,17 @@ Replacement text
especially if it may need to change later. A short example is
unavoidably contrived::
- |RST| is a little annoying to type over and over, especially
+ |RST|_ is a little annoying to type over and over, especially
when writing about |RST| itself, and spelling out the
bicapitalized word |RST| every time isn't really necessary for
|RST| source readability.
- .. |RST| replace:: reStructuredText_
- .. _reStructuredText: http://docutils.sourceforge.net/rst.html
+ .. |RST| replace:: reStructuredText
+ .. _RST: http://docutils.sourceforge.net/rst.html
+
+ Note the trailing underscore in the first use of a substitution
+ reference. This indicates a reference to the corresponding
+ hyperlink target.
Substitution is also appropriate when the replacement text cannot
be represented using other inline constructs, or is obtrusively
diff --git a/docs/user/config.txt b/docs/user/config.txt
index 9361db1bb..ffca33d3d 100644
--- a/docs/user/config.txt
+++ b/docs/user/config.txt
@@ -404,18 +404,22 @@ _`strip_classes`
List of "classes" attribute values to remove from all elements in
the document tree.
+ .. WARNING:: Potentially dangerous; use with caution.
+
Default: disabled (None). Option: ``--strip-class``.
_`strip_comments`
Enable the removal of comment elements from the document tree.
- Default: disabled (None). Options: ``--strip-comment``,
+ Default: disabled (None). Options: ``--strip-comments``,
``--leave-comments``.
_`strip_elements_with_classes`
List of "classes" attribute values; matching elements to be
removed from the document tree.
+ .. WARNING:: Potentially dangerous; use with caution.
+
Default: disabled (None). Option: ``--strip-element-with-class``.
_`title`
diff --git a/docs/user/emacs.txt b/docs/user/emacs.txt
index e9e403c3f..c61d781c6 100644
--- a/docs/user/emacs.txt
+++ b/docs/user/emacs.txt
@@ -5,7 +5,7 @@
========================================
:Author: Martin Blais <blais@furius.ca>
-:Date: $Date$
+:Date: 2007-12-03
:Abstract:
High-level description of the existing emacs support for editing
@@ -15,30 +15,34 @@
.. contents::
..
1 Introduction
- 2 Basic Setup
- 3 Section Decoration Adjustment
- 3.1 Promoting and Demoting Many Sections
- 3.2 Redoing All the Decorations to Your Taste
- 3.3 Customizations
- 4 Viewing the Hierarchy of Section Decorations
- 5 Table of Contents
- 5.1 Inserting a Table of Contents
- 5.2 Maintaining the Table of Contents Up-to-date
- 6 Navigating Between the Section Titles
- 7 Shifting Bullet List Levels
- 8 Bulleting and Enumerating Lists
- 8.1 Straightening Existing Bullet List Hierarchies
- 9 Creating and Remove Line Blocks
- 10 Major Mode for Editing reStructuredText Documents
- 11 Converting Documents from Emacs
- 12 Other / External Useful Emacs Settings
- 12.1 Settings for Filling Lists
- 12.2 ``text-mode`` Settings
- 12.3 Editing Tables: Emacs table mode
- 12.4 Character Processing
- 13 Credits
- 14 Obsolete Files
- 15 Future Work
+ 2 Installation
+ 3 Section Decorations
+ 3.1 Adjusting a Section Title
+ 3.2 Promoting and Demoting Many Sections
+ 3.3 Redoing All the Decorations to Your Taste
+ 3.4 Customizations for Decorations
+ 3.5 Viewing the Hierarchy of Section Decorations
+ 4 Section Movement and Selection
+ 5 Operating on Blocks of Text
+ 5.1 Shifting Text Horizontally Intelligently
+ 5.2 Bulleting and Enumerating Lists
+ 5.2.1 Straightening Existing Bullet List Hierarchies
+ 5.3 Creating and Removing Line Blocks
+ 5.4 Commenting a Region of Text
+ 6 Converting Documents from Emacs
+ 7 Table-of-Contents Features
+ 7.1 Inserting a Table of Contents
+ 7.2 Maintaining the Table of Contents Up-to-date
+ 8 Syntax Highlighting via Font-Lock
+ 8.1 Face Customization
+ 8.1.1 Default Fonts
+ 9 Other Useful Settings
+ 9.1 ``text-mode`` Settings
+ 9.2 Editing Tables: Emacs table mode
+ 9.3 Character Processing
+ 10 Credits
+ 10.1 Obsolete Files
+ 11 Future Work
Introduction
@@ -46,49 +50,75 @@ Introduction
reStructuredText_ is a series of conventions that allows a
toolset--docutils--to extract generic document structure from simple
-text files. For people who use Emacs_, there is a package that adds
-some support for the conventions that reStructuredText_ specifies:
-``rst.el``.
+text files. For people who use Emacs_, there is a package that adds a
+major mode that supports editing in the conventions of
+reStructuredText_: ``rst.el``. This document describes the features it
+provides, and how to setup your emacs to use them and how to invoke
+them.
-This document describes the most important features that it provides,
-how to setup your emacs to use them and how to invoke them.
+Installation
+============
-Basic Setup
-===========
+The emacs support is implemented as an Emacs major mode (``rst-mode``)
+provided by the ``rst.el`` emacs package. In order to use
+``rst-mode``, you need to put the ``rst.el`` in a directory located in
+your emacs ``load-path``, and to load it with::
-The emacs support is completely provided by the ``rst.el`` emacs
-package. In order to use these features, you need to put the file in
-your emacs load-path, and to load it with::
+ (require 'rst)
- (require 'rst) ;; or (load "rst")
+To enable ``rst-mode``, simple type ``M-x rst-mode``. Alternatively,
+you can modify ``auto-mode-alist`` to automatically turn it on
+whenever you visit reStructuredText_ documents::
-Additional configuration variables can be customized and can be found
-by browsing the source code for ``rst.el``.
+ (setq auto-mode-alist
+ (append '(("\\.txt$" . rst-mode)
+ ("\\.rst$" . rst-mode)
+ ("\\.rest$" . rst-mode)) auto-mode-alist))
-Then you will want to bind keys to the most common commands it
-provides. A standard text-mode hook function is maintained and
-provided by the package for this use, set it up like this::
+If have local variables enabled (see ``enable-local-variables`` in the
+Emacs manual), you can also add the following at the top of your
+documents to trigger rst-mode::
- (add-hook 'text-mode-hook 'rst-text-mode-bindings)
+ .. -*- mode: rst -*-
-A prefix map is defined for all the ``rst.el`` commands. By default,
-it is bound to the mode-specific-map and ``p``, e.g. ``C-c p ...``.
+Or this at the end of your documents::
+ ..
+ Local Variables:
+ mode: rst
+ End:
+
+``rst-mode`` automatically binds several keys for invoking special
+handy functions for editing ReStructuredText. As is the custom for
+Emacs major modes, most keys are bound to ``C-c C-LETTER``.
+
+If you insert an inline table-of-contents at the top of the document,
+you may want to add a hook to automatically update it everytime you
+adjust a section title::
+
+ (add-hook 'rst-adjust-hook 'rst-toc-update)
+
+Additional configuration variables can be customized and can be found
+by browsing the source code for ``rst.el``.
-Section Decoration Adjustment
-=============================
+
+Section Decorations
+===================
The rst package does not completely parse all the reStructuredText_
constructs, but it contains the ability to recognize the section
-decorations and to build the hierarchy of the document. What we call
+decorations and to build the hierarchy of the document. What we call
section decorations or adornments are the underlines or under- and
overlines used to mark a section title.
+Adjusting a Section Title
+-------------------------
+
There is a function that helps a great deal to maintain these
-decorations: ``rst-adjust`` (bound on ``C-c p a``, ``C-c p =`` or
-``C-=`` by default). This function is a Swiss army knife that can be
-invoked repeatedly and whose behaviour depends on context:
+decorations: ``rst-adjust`` (bound to ``C-c C-a``, or ``C-=`` by
+default). This function is a Swiss army knife that can be invoked
+repeatedly and whose behaviour depends on context:
#. If there is an incomplete underline, e.g.::
@@ -114,7 +144,6 @@ use a regular prefix argument, e.g. ``C-u C-=``. See the
documentation of ``rst-adjust`` for more description of the prefix
arguments to alter the behaviour of the function.
-
Promoting and Demoting Many Sections
------------------------------------
@@ -124,150 +153,55 @@ key binding can be used to do that: if the region is active when the
binding is invoked, all the section titles that are within the region
are promoted accordingly (or demoted, with negative prefix arg).
-
Redoing All the Decorations to Your Taste
-----------------------------------------
If you open someone else's file and the decorations it contains are
unfamiliar, you may want to readjust them to fit your own preferred
-hierarchy of decorations. This can be difficult to perform by hand.
-However, you can do this easily by invokeing
-``rst-straighten-decorations`` (C-c p s), which operates on the entire
-buffer.
+hierarchy of decorations. This can be difficult to perform by hand.
+However, you can do this easily by invoking
+``rst-straighten-decorations`` (``C-c C-s``), which operates on the
+entire buffer.
-
-Customizations
---------------
+Customizations for Decorations
+------------------------------
You can set the variable ``rst-preferred-decorations`` to a list of
the decorations that you like to use for documents. Everyone has
their preference. ``rst-default-indent`` can be set to the number of
indent spaces preferred for the over-and-under decoration style.
-
Viewing the Hierarchy of Section Decorations
-============================================
+--------------------------------------------
You can visualize the hierarchy of the section decorations in the
current buffer by invoking ``rst-display-decorations-hierarchy``,
-bound on ``C-c p h``. A temporary buffer will appear with fake
+bound on ``C-c C-h``. A temporary buffer will appear with fake
section titles rendered in the style of the current document. This
can be useful when editing other people's documents to find out which
section decorations correspond to which levels.
-Table of Contents
-=================
+Section Movement and Selection
+==============================
-When you are editing long documents, it can be a bit difficult to
-orient yourself in the structure of your text. To that effect, a
-function is provided that quickly parses the document and presents a
-hierarchically indented table of contents of the document in a
-temporary buffer, in which you can navigate and press ``Return`` to go
-to a specific section.
+You can move the cursor between the different section titles by using
+the ``rst-backward-section`` and ``rst-forward-section`` functions, by
+default bound to the ``C-c C-p`` and ``C-c C-n`` keys.
-Invoke this function (``rst-toc``) with ``C-c p t``. It should
-present a temporary buffer that looks something like this::
-
- Table of Contents:
- Debugging Meta-Techniques
- Introduction
- Debugging Solution Patterns
- Recognize That a Bug Exists
- Subdivide and Isolate
- Identify and Verify Assumptions
- Use a Tool for Introspection
- Change one thing at a time
- Learn about the System
- Understanding a bug
- The Basic Steps in Debugging
- Attitude
- Bad Feelings
- Good Feelings
- References
-
-When you select a section title, the temporary buffer disappears and
-you are left with the cursor positioned at the chosen section.
+To mark the section that cursor lies in, use ``rst-mark-section``
+(``C-c C-m``).
-Inserting a Table of Contents
------------------------------
-
-Oftentimes in long text documents that are meant to be read directly,
-a Table of Contents is inserted at the beginning of the text. This is
-the case for most internet FAQs, for example. In reStructuredText_
-documents, since the table of contents is automatically generated by
-the parser with the ``.. contents::`` directive, people generally have
-not been adding a text table of contents to their source documents,
-and partly because it is too much trouble to edit and maintain.
-
-The emacs support for reStructuredText_ provides a function to insert
-such a table of contents in your document. Since it is not meant to
-be part of the document text, you should place such a table of
-contents within a comment, so that it is ignored by the parser. This
-is the favoured usage::
- .. contents::
- ..
- 1 Introduction
- 2 Debugging Solution Patterns
- 2.1 Recognize That a Bug Exists
- 2.2 Subdivide and Isolate
- 2.3 Identify and Verify Assumptions
- 2.4 Use a Tool for Introspection
- 2.5 Change one thing at a time
- 2.6 Learn about the System
- 3 Understanding a bug
- 4 The Basic Steps in Debugging
- 5 Attitude
- 5.1 Bad Feelings
- 5.2 Good Feelings
- 6 References
-
-Just place the cursor at the top-left corner where you want to insert
-the TOC and invoke the function with ``C-c p i``. The table of
-contents will display all the section titles that are under the
-location where the insertion occurs. This way you can insert local
-table of contents by placing them in the appropriate location.
-
-If you have deep nesting of sections, you can use a numeric prefix
-argument to limit the depth of rendering of the TOC.
-
-You can also customize the look of the TOC by setting the values of
-the following variables:: ``rst-toc-indent``,
-``rst-toc-insert-style``, ``rst-toc-insert-max-level``.
-
-
-Maintaining the Table of Contents Up-to-date
---------------------------------------------
-
-One issue is that you will probably want to maintain the inserted
-table of contents up-to-date. There is a function that will
-automatically look for the inserted TOC (``rst-toc-insert-update``)
-and it can be added to a hook on the section decoration adjustment
-function, so that every time you adjust a section title, the TOC is
-updated. Add this functionality with the following emacs
-configuration::
-
- (add-hook 'rst-adjust-hook 'rst-toc-insert-update)
-
-You can invoke the update on the current buffer with ``C-c p u``.
-
-
-Navigating Between the Section Titles
-=====================================
-
-You can move the cursor between the different sections by using the
-``rst-backward-section`` and ``rst-forward-section`` functions, by
-default bound to the ``C-c p p`` and ``C-c p n`` keys (also ``C-c
-C-p`` and ``C-c C-n``).
-
-
-Shifting Bullet List Levels
+Operating on Blocks of Text
===========================
-Due to the nature of reStructuredText_, bulleted lists are indented by
-two characters (unless they are part of a blockquote), e.g. ::
+Shifting Text Horizontally Intelligently
+----------------------------------------
+
+Due to the nature of reStructuredText_, lists are indented by two or
+three characters, e.g. bulleted lists use two chars::
- Fruits
@@ -280,7 +214,7 @@ two characters (unless they are part of a blockquote), e.g. ::
- Zucchini
- Chick Peas
-Enumerated lists, however, as indented by 3 or more characters ::
+while enumerated lists are indented by 3 or more characters ::
9. Apples
@@ -290,25 +224,24 @@ Enumerated lists, however, as indented by 3 or more characters ::
Oranges are zesty.
+To this effect, when shifting text, it can be useful to have functions
+which understand which indent to use by using the context around the
+region. Those functions are ``rst-shift-region-right`` and
+``rst-shift-region-left``.
-To this effect, when re-organizing bullet lists, it can be useful to
-have functions to shift regions of text by appropriate indents, which
-are figured out automatically by emacs.
-
-You can use ``C-c C-r`` and ``C-c C-l`` to shift the current region
-(``rst-shift-region-right`` and ``rst-shift-region-left``). These
-bindings are similar to the ones provided by python-mode for editing
-python code and behave similarly. They inspect the lines of text
-before the currently selected region to determine what the appropriate
-column positions are.
+You can use ``C-c C-r`` and ``C-c C-l`` to shift the active region.
+These bindings are similar to the ones provided by python-mode for
+editing python code and behave similarly. They automatically inspect
+the lines of text before the currently selected region to determine
+what the appropriate column positions are.
Bulleting and Enumerating Lists
-===============================
+-------------------------------
Sometimes it can be useful to insert bullet list markers enumeration
number before a number of lines or paragraphs. You can do this easily
-by invoking ``rst-enumerate-region`` (``C-c p e``), for example, the
+by invoking ``rst-enumerate-region`` (``C-c C-e``), for example, the
following::
Apples
@@ -325,7 +258,7 @@ becomes::
3. Bananas
-``rst-listify-region`` (``C-c p b``) does the same, but only adds
+``rst-listify-region`` (``C-c C-b``) does the same, but only adds
bullet list markers, e.g.::
Apples
@@ -337,9 +270,9 @@ bullet list markers, e.g.::
becomes::
- Apples
-
+
- Oranges
-
+
- Bananas
@@ -347,24 +280,24 @@ By default, each paragraph starting on the leftmost line in the
highlighted region will be taken to be a single list or enumeration
item, for example, enumerating the following::
- An apple a day
+ An apple a day
keeps the doctor away.
-
- But oranges
+
+ But oranges
are tastier than apples.
-
+
If you preferred bananas
you may be
a monkey.
Will result in::
- 1. An apple a day
+ 1. An apple a day
keeps the doctor away.
-
- 2. But oranges
+
+ 2. But oranges
are tastier than apples.
-
+
3. If you preferred bananas
you may be
a monkey.
@@ -382,12 +315,10 @@ becomes::
- Oranges
- Bananas
-
-
Straightening Existing Bullet List Hierarchies
-----------------------------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you invoke ``rst-straighten-bullets-region`` (C-c p w), the
+If you invoke ``rst-straighten-bullets-region`` (C-c C-w), the
existing bullets in the highlighted region will be replaced to reflect
their respective level. This does not make a difference in the
document structure that reStructuredText_ defines, but looks better in
@@ -395,11 +326,11 @@ the input file, for example, if all of the top-level bullet items use
the character ``-``, and all of the 2nd level items use ``*``, etc.
-Creating and Remove Line Blocks
-===============================
+Creating and Removing Line Blocks
+---------------------------------
To create line blocks, first select the region to convert and invoke
-``rst-toggle-line-block`` with ``C-c p B``, for example, the
+``rst-toggle-line-block`` with ``C-c C-d``, for example, the
following::
Apples
@@ -416,112 +347,227 @@ This works even if the region is indented. To remove line blocks,
select a region and invoke with a prefix argument.
-Major Mode for Editing reStructuredText Documents
-=================================================
-
-The great majority of the functionality for supporting
-reStructuredText_ can be invoked directly from Emacs' vanilla
-text-mode.
-
-However, there is also a major mode that adds syntax highlighting to
-reStructuredText_ constructs. This mode was written by Stefan Merten
-[#]_. It mostly provides lazy syntax coloring for many of the
-constructs that reStructuredText_ prescribes.
-
-To enable this mode, type ``M-x rst-mode`` or you can set up an
-``auto-mode-alist`` to automatically turn it on whenever you visit
-reStructuredText_ documents::
+Commenting a Region of Text
+---------------------------
- (add-to-list 'auto-mode-alist '("\\.rst$" . rst-mode) )
+If you use the Emacs ``comment-region`` function (bound to ``C-c
+C-c``), the appropriate comment syntax will be added to the active
+block of text::
-If have local variables enabled (see ``enable-local-variables`` in the
-Emacs manual), you can also add the following at the top of your
-documents to trigger rst-mode::
-
- .. -*- mode: rst -*-
-
-Or add this at the end of your documents::
+ Apples
+ Oranges
+ Bananas
- ..
- Local Variables:
- mode: rst
- End:
+becomes::
-By default, the font-lock colouring is performed lazily. If you don't
-like this, you can turn this off by setting the value of
-``rst-mode-lazy``. You can also change the various colours (see the
-source file for the whole list of customizable faces).
+ .. Apples
+ .. Oranges
+ .. Bananas
-.. [#] This mode used to be provided by the file ``rst-mode.el`` and
- has now been integrated with the rest of the emacs code.
Converting Documents from Emacs
===============================
-We provide a function (``rst-compile``) for invoking the document
-converters from within emacs. It is bound on ``C-c p c``.
+The major mode provides a number of functions for running documents
+being edited through the docutils tools.
-This function basically creates a compilation command with the correct
+The main generic function is ``rst-compile`` (``C-c 1``). This
+function basically creates a compilation command with the correct
output name for the current buffer and then invokes Emacs' compile
function. It also looks for the presence of a ``docutils.conf``
configuration file in the parent directories and adds it to the
-cmdline options. You can customize which tool is used to perform the
-conversion and some standard options to always be added as well.
+cmdline options. There is also an alternative function in case you
+often need run your document in a second toolset (``C-c 2``).
+
+You can customize the commands being used by setting
+``rst-compile-primary-toolset`` and ``rst-compile-secondary-toolset``.
-Invocation uses the toolset indicated by
-``rst-compile-primary-toolset`` (default is ``'html``). Invocation
-with a prefix argument uses ``rst-compile-secondary-toolset`` (default
-is ``'latex``).
+Other commands are available for other formats:
+
+- ``rst-compile-pseudo-region`` (``C-c 3``): When crafting documents,
+ it is often convenient to view which data structures docutils will
+ parse them into. You can use to run the active region through
+ ``rst2pseudoxml.py`` and have the output automatically be displayed
+ in a new buffer.
+
+- ``rst-compile-pdf-preview`` (``C-c 4``): Convert the current
+ document to PDF and launch a viewer on the results.
+
+- ``rst-compile-slides-preview`` (``C-c 5``): Convert the current
+ document to S5 slides and view in a web browser.
+
+
+Table-of-Contents Features
+==========================
+
+When you are editing long documents, it can be a bit difficult to
+orient yourself in the structure of your text. To that effect, a
+function is provided that quickly parses the document and presents a
+hierarchically indented table of contents of the document in a
+temporary buffer, in which you can navigate and press ``Return`` to go
+to a specific section.
+
+Invoke this function (``rst-toc``) with ``C-c C-t``. It should
+present a temporary buffer that looks something like this::
+
+ Table of Contents:
+ Debugging Meta-Techniques
+ Introduction
+ Debugging Solution Patterns
+ Recognize That a Bug Exists
+ Subdivide and Isolate
+ Identify and Verify Assumptions
+ Use a Tool for Introspection
+ Change one thing at a time
+ Learn about the System
+ Understanding a bug
+ The Basic Steps in Debugging
+ Attitude
+ Bad Feelings
+ Good Feelings
+ References
+
+When you select a section title (press ``RET``), the temporary buffer
+disappears and you are left with the cursor positioned at the chosen
+section.
+
+
+Inserting a Table of Contents
+-----------------------------
+
+Oftentimes in long text documents that are meant to be read directly,
+a Table of Contents is inserted at the beginning of the text. This is
+the case for most internet FAQs, for example. In reStructuredText_
+documents, since the table of contents is automatically generated by
+the parser with the ``.. contents::`` directive, people generally have
+not been adding a text table of contents to their source documents,
+and partly because it is too much trouble to edit and maintain.
+
+The emacs support for reStructuredText_ provides a function to insert
+such a table of contents in your document. Since it is not meant to
+be part of the document text, you should place such a table of
+contents within a comment, so that it is ignored by the parser. This
+is the favoured usage::
+
+ .. contents::
+ ..
+ 1 Introduction
+ 2 Debugging Solution Patterns
+ 2.1 Recognize That a Bug Exists
+ 2.2 Subdivide and Isolate
+ 2.3 Identify and Verify Assumptions
+ 2.4 Use a Tool for Introspection
+ 2.5 Change one thing at a time
+ 2.6 Learn about the System
+ 3 Understanding a bug
+ 4 The Basic Steps in Debugging
+ 5 Attitude
+ 5.1 Bad Feelings
+ 5.2 Good Feelings
+ 6 References
+
+Just place the cursor at the top-left corner where you want to insert
+the TOC and invoke the function with ``C-c C-i``. The table of
+contents will display all the section titles that are under the
+location where the insertion occurs. This way you can insert local
+table of contents by placing them in the appropriate location.
+
+If you have deep nesting of sections, you can use a numeric prefix
+argument to limit the depth of rendering of the TOC.
+
+You can also customize the look of the TOC by setting the values of
+the following variables:: ``rst-toc-indent``,
+``rst-toc-insert-style``, ``rst-toc-insert-max-level``.
.. note::
- In general it is preferred to use a Makefile to automate the
- conversion of many documents or a hierarchy of documents. The
- functionality presented above is meant to be convenient for use on
- single files.
+ The table-of-contents inserted by ``rst-mode`` has text properties
+ added to it so that if you type ``C-c C-f`` while the cursor is on
+ one of its entries, the cursor will jump to the corresponding
+ section in the document.
+
+
+Maintaining the Table of Contents Up-to-date
+--------------------------------------------
+
+One issue is that you will probably want to maintain the inserted
+table of contents up-to-date. There is a function that will
+automatically look for the inserted TOC (``rst-toc-update``)
+and it can be added to a hook on the section decoration adjustment
+function, so that every time you adjust a section title, the TOC is
+updated. Add this functionality with the following emacs
+configuration::
+ (add-hook 'rst-adjust-hook 'rst-toc-update)
-Other / External Useful Emacs Settings
-======================================
+You can invoke the update on the current buffer with ``C-c C-u``.
-This section covers general emacs text-mode settings that are useful
-in the context of reStructuredText_ conventions. These are not
-provided by ``rst.el`` but you may find them useful specifically for
-reStructuredText_ documents.
+
+Syntax Highlighting via Font-Lock
+=================================
+
+``rst-mode`` also provides syntax highlighting to reStructuredText_
+constructs. (This mode was written by Stefan Merten.)
+
+Lazy syntax coloring is implemented for many of the constructs that
+reStructuredText_ prescribes. By default, the font-lock colouring is
+performed lazily. If you don't like this, you can turn this off by
+setting the value of ``rst-mode-lazy``. You can also change the
+various colours (see the source file for the whole list of
+customizable faces).
+
+``font-lock`` syntax highlighting is enabled by default. If you prefer
+to turn off syntax highlighting (on some machines it can slow down
+editing a little bit), you can use the following in your Emacs
+configuration::
+
+ (setq font-lock-global-modes '(not rst-mode))
-Settings for Filling Lists
---------------------------
+Face Customization
+------------------
-One problem with the default text-mode settings is that *filling* long
-lines in bullet and enumerated lists that do not have an empty line
-between them merges them together, e.g.::
+The ``rst-faces`` group contains all necessary for customizing
+fonts. The default settings use standard ``font-lock-*-face`` so if
+you set these to your liking they are probably good in rst-mode also.
- - Bananas;
- - One Apple a day keeps the doctor away, and eating more keeps the pirates at bay;
- - Oranges;
+The group is contained in the faces group as well as in the rst group.
-Becomes::
- - Bananas; One Apple a day keeps the doctor away, and eating more
- - keeps the pirates at bay; Oranges;
+Default Fonts
+~~~~~~~~~~~~~
-This is usually not what you want. What you want is this::
+The ``rst-faces-defaults`` group contains all necessary for
+customizing the default fonts used for section title faces.
- - Bananas;
- - One Apple a day keeps the doctor away, and eating more keeps
- the pirates at bay;
- - Oranges;
+The general idea for section title faces is to have a non-default
+background but do not change the background. The section level is
+shown by the lightness of the background color. If you like this
+general idea of generating faces for section titles but do not like
+the details this group is the point where you can customize the
+details. If you do not like the general idea, however, you should
+customize the faces used in ``rst-adornment-faces-alist``.
-The problem is that emacs does not recognize the various consecutive
-items as forming paragraph boundaries. You can fix this easily by
-changing the global value of the parapraph boundary detection to
-recognize such lists, using the ``rst-set-paragraph-separation``
-function::
+Note: If you are using a dark background please make sure the variable
+``frame-background-mode`` is set to the symbol dark. This triggers
+some default values which are probably right for you.
- (add-hook 'text-mode-hook 'rst-set-paragraph-separation)
+The group is contained in the ``rst-faces`` group.
+All customizable features have a comment explaining their
+meaning. Refer to the customization of your Emacs (try ``M-x
+customize``).
+
+
+
+Other Useful Settings
+=====================
+
+This section covers general emacs text-mode settings that are useful
+in the context of reStructuredText_ conventions. These are not
+provided by ``rst.el`` but you may find them useful specifically for
+reStructuredText_ documents.
``text-mode`` Settings
----------------------
@@ -536,7 +582,6 @@ functions and modes that pertain somewhat to text-mode:
- auto-mode-alist
- fill-region
-
Editing Tables: Emacs table mode
--------------------------------
@@ -609,45 +654,25 @@ and ".,:;"), and free.
__ http://www.tobias-jung.de/seekingprofont/
+
Credits
=======
- The automatic section adjustment and table of contents features were
written by Martin Blais;
-- ``rst-mode`` and its syntax highlighting was implemented by Stefan
- Merten;
+- Syntax highlighting was implemented by Stefan Merten;
- Various other functions were implemented by David Goodger.
-
Obsolete Files
-==============
-
-On 2005-10-30, ``restructuredtext.el``, ``rst-html.el`` and
-``rst-mode.el`` were merged to form the new ``rst.el``. You can
-consider the old files obsolete and remove them.
-
-
-Future Work
-===========
-
-Here are some features and ideas that will be worked on in the future,
-in those frenzied mornings of excitement over the virtues of the
-one-true-way kitchen sink of editors:
+--------------
-- It would be nice to differentiate between text files using
- reStructuredText_ and other general text files. If we had a
- function to automatically guess whether a .txt file is following the
- reStructuredText_ conventions, we could trigger rst-mode without
- having to hard-code this in every text file, nor forcing the user to
- add a local mode variable at the top of the file.
+On 2005-10-30, ``rst.el`` integrated and replaced the contents of the
+following files:
- We could perform this guessing by searching for a valid decoration
- at the top of the document or searching for reStructuredText_
- directives further on.
+- ``restructuredtext.el``
+- ``rst-html.el``
+- ``rst-mode.el``
-- The suggested decorations when adjusting should not have to cycle
- below one below the last section decoration level preceding the
- cursor. We need to fix that.
.. _Emacs: http://www.gnu.org/software/emacs/emacs.html
@@ -656,7 +681,7 @@ one-true-way kitchen sink of editors:
..
Local Variables:
- mode: indented-text
+ mode: rst
indent-tabs-mode: nil
sentence-end-double-space: t
fill-column: 70
diff --git a/docs/user/latex.txt b/docs/user/latex.txt
index 8aa361faa..3b49f233a 100644
--- a/docs/user/latex.txt
+++ b/docs/user/latex.txt
@@ -128,7 +128,7 @@ line spacing Is done with package *setspace*, which gives
for bigger linespacing.
--------------------- ------------------------------------------------
use verbatim when When possibile, use verbatim for literal-blocks.
-possible Default is to always use the mbox environment.
+possible Compatibility alias for "--literal-env=verbatim".
A literal-block element, when processed by a
docutils-writer might have it's origin in a
@@ -204,18 +204,33 @@ Unicode
The generated LaTeX documents are in the input encoding per default.
-If the source document is in utf-8 encoding (or
-``--output-encoding=utf-8`` is set), LaTeX needs unicode support
-(the ``ucs`` package). If this is not available, specify
-a different output-encoding, e.g. ``latin1``.
+* If the source document is in utf-8 encoding (or
+ ``--output-encoding=utf-8`` is set), LaTeX needs unicode support
+ (the ``ucs`` package). If this is not available, specify
+ a different output-encoding, e.g. ``latin1``.
-If LaTeX issues a Warning about unloaded/known characters adding ::
+* If LaTeX issues a Warning about unloaded/known characters adding ::
\PreloadUnicodePage{n}
-where *n* is the unicode pagenumber, might help.
+ where *n* is the unicode pagenumber, might help.
-.. _LaTeX unicode: http://www.unruh.de/DniQ/latex/unicode/
+ .. _LaTeX unicode: http://www.unruh.de/DniQ/latex/unicode/
+
+* Unicode box drawing characters
+
+ - generate LaTeX code with ``--output-encoding=utf-8:strict``.
+
+ - In the latex file, edit the preamble to load "ucs" with "postscript"
+ option and also load the pstricks package::
+
+ \usepackage{shortvrb}
+ - \usepackage{ucs}
+ + \usepackage[postscript]{ucs}
+ + \usepackage{pstricks}
+ \usepackage[utf8x]{inputenc}
+
+ - Convert to PDF with ``latex``, ``dvips``, and ``ps2pdf``.
Table of figures
----------------
@@ -284,6 +299,7 @@ image formats depend on the used driver (dvi, dvips, pdftex, ...).
If pdf-image inclusion in pdf files fails, specify
``--graphicx-option=pdftex`` or ``--graphicx-option=auto``.
+Wrapping text around images requires the wrapfig package.
Commands directly to LaTeX
==========================
@@ -348,6 +364,13 @@ Problems
Open to be fixed or open to discussion.
+Lists
+-----
+
+Definitions in definition lists start on the same line as the term. Putting
+``\leavevmode`` after the term results in a new newline if the definition
+starts with a item list or similar.
+
footnotes and citations
-----------------------
@@ -401,6 +424,9 @@ Tables
uses raggedright.
- Ragged right fails on followup paragraphs as the vertical space would be
missing.
+* Use tabularx column type ``X`` and let latex decide width.
+* csv-tables do not have a colwidth.
+
Notes
~~~~~
@@ -423,8 +449,6 @@ Miscellaneous
* recognize LaTeX and replace by ``\LaTeX``.
* Support embed-stylesheet.
* Sidebar handling.
-* Maybe add end of line after term in definition list. see
- http://roundup.sf.net/doc-0.5/features.pdf
* Pdfbookmark level 4 (and greater) does not work (might be settable but OTOH).
* center subsection{Abstract} gives a LaTeX error here.
``! LaTeX Error: Something's wrong--perhaps a missing \item.``
diff --git a/docs/user/links.txt b/docs/user/links.txt
index a254feacd..d86d1e5ef 100644
--- a/docs/user/links.txt
+++ b/docs/user/links.txt
@@ -2,8 +2,8 @@
Docutils_ Link List
=====================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Revision: $Revision$
:Date: $Date$
:Copyright: This document has been placed in the public domain.
@@ -29,31 +29,83 @@ Docutils. All projects listed here are usable by end users in some
way, however please do not expect all of them to run straight out of
the box.
-* For Wikis, please see the `FAQ entry about Wikis`_.
+Editors
+~~~~~~~
-* For Blogs (Weblogs), please see the `FAQ entry about Blogs`_.
+Editors with reStructuredText support and docutils GUIs:
-* Pandoc_ is a document converter; it can read Markdown and (subsets
- of) reStructuredText, HTML, and LaTeX, and it can write Markdown,
- reStructuredText, HTML, LaTeX, RTF, DocBook XML, and S5.
+* Emacs `rst mode <http://docutils.sf.net/docutils/tools/editors/emacs>`__.
-* restxsl_, by Michael Alyn Miller, lets you transform
- reStructuredText documents into XML/XHTML files using XSLT
- stylesheets.
+* `reStructuredText syntax highlighting mode
+ <http://www.vim.org/scripts/script.php?script_id=973>`__ for vim.
-* rest2web_, by Michael Foord, is a tool for creating web sites with
- reStructuredText.
+* `VST <http://skawina.eu.org/mikolaj/vst.html>`__ (Vim reStructured Text)
+ is a plugin for Vim7 with folding.
+
+* `rst mode <http://jedmodes.sf.net/mode/rst/>`__ for the
+ `JED <http://www.jedsoft.org/jed/>`__ programmers editor
+
+* Gunnar Schwant's DocFactory_ is a wxPython GUI application for
+ Docutils.
-* Ladislav Lhotka has written an `XSLT script`_ that enables
- reStructuredText annotations to be included in RELAG NG XML schemas.
-
* ReSTedit_ by Bill Bumgarner is a Docutils GUI for Mac OS X.
-* There is an `ASCII art to SVG converter`_ (aafigure), developed by
- Chris Liechti.
-* Jens J. Mortensen developed `LaTeX math for reST`_, which writes to
- LaTeX or to MathML.
+Export
+~~~~~~
+
+Convert reStructuredText to other formats:
+
+* `rst2pdf.py <http://docutils.sf.net/sandbox/rst2pdf>`_
+ is a front end for the generation of PDF documents from a
+ reStructuredText source in one step cleaning up intermediate files.
+
+* **py.rest** from the Codespeak `py Lib scripts`_ converts
+ reStructuredText files to HTML and PDF (cleaning up the intermediate
+ latex files). Similar to ``buildhtml.py``, it looks recursively for
+ .txt files in the given PATHS.
+
+* odtwriter_ the Open Document Format writer developed by Dave Kuhlman
+ produces files that can be processed with OpenOffice and Abiword.
+
+* restxsl_ by Michael Alyn Miller, lets you transform reStructuredText
+ documents into XML/XHTML files using XSLT stylesheets.
+
+* rst2ht_ by Oliver Rutherfurd, converts reStructuredText to an .ht
+ template, for use with ht2html_.
+
+* htmlnav_ by Gunnar Schwant, is an HTML writer which supports navigation
+ bars.
+
+* rst2chm_ by Oliver Rutherfurd, generates Microsoft HTML Help files from
+ reStructuredText files.
+
+* `html4strict <http://docutils.sf.net/sandbox/html4strict/>`__
+ produces XHTML that strictly conforms to the XHTML 1.0 specification.
+
+* `html4trans <http://docutils.sf.net/sandbox/html4trans/>`__
+ produces XHTML conforming to the version 1.0 Transitional DTD that
+ contains enough formatting information to be viewed by a lightweight HTML
+ browser without CSS support.
+
+* A `simple HTML writer`_ by Bill Bumgarner that doesn't rely on CSS
+ (stylesheets).
+
+* An `XSLT script`_ by Ladislav Lhotka enables reStructuredText annotations
+ to be included in RELAG NG XML schemas.
+
+* The Docutils interface to PythonPoint_
+ by Richard Jones produces PDF presentations using ReportLabs.
+
+* `ManPage Writer`_ by Engelbert Gruber.
+
+* `DocBook Writer`_ by Oliver Rutherfurd.
+
+
+Import
+~~~~~~
+
+Convert other formats to reStructuredText:
* sxw2rest_, by Trent W. Buck, converts StarOffice XML Writer (SXW)
files to reStructuredText.
@@ -65,42 +117,50 @@ the box.
* xhtml2rest_, written by Antonios Christofides, is a simple utility
to convert XHTML to reStructuredText.
-* rst2ht_, by Oliver Rutherfurd, converts reStructuredText to an .ht
- template, for use with ht2html_.
+Extensions
+~~~~~~~~~~
-* htmlnav_, by Gunnar Schwant, is an HTML writer which supports
- navigation bars.
+Extend the reStructuredText syntax or the features of docutils.
+More extensions are in the `Docutils Sandbox`_.
-* rst2chm_, written by Oliver Rutherfurd, generates Microsoft HTML
- Help files from reStructuredText files.
+* Jens J. Mortensen developed `LaTeX math for reST`_, which writes to
+ LaTeX or to MathML.
-* ZReST_, by Richard Jones, is a "ReStructuredText Document for Zope"
- application that is complete and ready to install.
+* Beni Cherniavsky has written a generic `preprocessing module`_ for
+ roles and/or directives and built preprocessors for TeX math for
+ both LaTeX and HTML output on top of it.
-* The Docutils interface to PythonPoint_, also by Richard Jones,
- produces PDF presentations using ReportLabs.
-* Engelbert Gruber has begun a `ManPage Writer`_.
+Related Applications
+~~~~~~~~~~~~~~~~~~~~
-* Oliver Rutherfurd has begun a `DocBook Writer`_.
+Applications using docutils/reStructuredText, helper applications:
-* Gunnar Schwant's DocFactory_ is a wxPython GUI application for
- Docutils.
+* For Wikis, please see the `FAQ entry about Wikis`_.
-* odtwriter_ Open Document Format writer is being developed by Dave
- Kuhlman.
+* For Blogs (Weblogs), please see the `FAQ entry about Blogs`_.
-* Bill Bumgarner has written a `simple HTML writer`_ that doesn't rely
- on CSS (stylesheets).
+* PyLit_ provides a bidirectional text <--> code converter for *literate
+ programming with reStructuredText*.
-* Beni Cherniavsky has written a generic `preprocessing module`_ for
- roles and/or directives and built preprocessors for TeX math for
- both LaTeX and HTML output on top of it.
+* Pandoc_ is a document converter; it can read Markdown and (subsets
+ of) reStructuredText, HTML, and LaTeX, and it can write Markdown,
+ reStructuredText, HTML, LaTeX, RTF, DocBook XML, and S5.
+
+* rest2web_, by Michael Foord, is a tool for creating web sites with
+ reStructuredText.
+
+* There is an `ASCII art to SVG converter`_ (aafigure), developed by
+ Chris Liechti.
+
+* ZReST_, by Richard Jones, is a "ReStructuredText Document for Zope"
+ application that is complete and ready to install.
* Beni Cherniavsky maintains a Makefile_ for driving Docutils, hoping
to handle everything one might do with Docutils.
+
API Developers
--------------
@@ -131,6 +191,8 @@ code base.
.. _Docutils: http://docutils.sourceforge.net/
.. _FAQ entry about Wikis: http://docutils.sf.net/FAQ.html#are-there-any-wikis-that-use-restructuredtext-syntax
.. _FAQ entry about Blogs: http://docutils.sf.net/FAQ.html#are-there-any-weblog-blog-projects-that-use-restructuredtext-syntax
+.. _py Lib scripts: http://codespeak.net/py/dist/bin.html
+.. _PyLit: http://pylit.berlios.de
.. _Pandoc: http://sophos.berkeley.edu/macfarlane/pandoc/
.. _restxsl: http://www.strangeGizmo.com/products/restxsl/
.. _XSLT script: http://www.cesnet.cz/doc/techzpravy/2006/rngrest/
@@ -143,7 +205,7 @@ code base.
.. _rst2ht: http://www.rutherfurd.net/articles/rst-ht2html.html
.. _ht2html: http://ht2html.sourceforge.net/
.. _htmlnav: http://docutils.sf.net/sandbox/gschwant/htmlnav/
-.. _xhtml2rest: http://docutils.sf.net/sandbox/fwiemann/xhtml2rest/
+.. _xhtml2rest: http://docutils.sf.net/sandbox/wiemann/xhtml2rest/
.. _rst2chm: http://www.rutherfurd.net/software/rst2chm/
.. _rest2web: http://www.voidspace.org.uk/python/rest2web/
.. _Docutils Sandbox: http://docutils.sf.net/sandbox/README.html
diff --git a/docs/user/mailing-lists.txt b/docs/user/mailing-lists.txt
index 0d92fa0a6..4eb5b4c18 100644
--- a/docs/user/mailing-lists.txt
+++ b/docs/user/mailing-lists.txt
@@ -2,8 +2,8 @@
Docutils_ Mailing Lists
=========================
-:Author: Felix Wiemann
-:Contact: Felix.Wiemann@ososo.de
+:Author: Lea Wiemann
+:Contact: LeWiemann@gmail.com
:Revision: $Revision$
:Date: $Date$
:Copyright: This document has been placed in the public domain.
diff --git a/docutils/__init__.py b/docutils/__init__.py
index 6991f3643..eca962fca 100644
--- a/docutils/__init__.py
+++ b/docutils/__init__.py
@@ -49,7 +49,7 @@ Subpackages:
__docformat__ = 'reStructuredText'
-__version__ = '0.5'
+__version__ = '0.6'
"""``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
diff --git a/docutils/core.py b/docutils/core.py
index f68f74cea..bf3b2a4f1 100644
--- a/docutils/core.py
+++ b/docutils/core.py
@@ -53,9 +53,11 @@ class Publisher:
"""A `docutils.writers.Writer` instance."""
for component in 'reader', 'parser', 'writer':
- assert not isinstance(getattr(self, component), StringType), \
- ('passed string as "%s" parameter; use "%s_name" instead'
- % (getattr(self, component), component, component))
+ assert not isinstance(getattr(self, component), StringType), (
+ 'passed string "%s" as "%s" parameter; pass an instance, '
+ 'or use the "%s_name" parameter instead (in '
+ 'docutils.core.publish_* convenience functions).'
+ % (getattr(self, component), component, component))
self.source = source
"""The source of input data, a `docutils.io.Input` instance."""
diff --git a/docutils/frontend.py b/docutils/frontend.py
index 034e30769..c21bd2c2d 100644
--- a/docutils/frontend.py
+++ b/docutils/frontend.py
@@ -193,7 +193,7 @@ def make_paths_absolute(pathdict, keys, base_path=None):
if base_path is None:
base_path = os.getcwd()
for key in keys:
- if pathdict.has_key(key):
+ if key in pathdict:
value = pathdict[key]
if isinstance(value, types.ListType):
value = [make_one_path_absolute(base_path, path)
@@ -225,7 +225,7 @@ class Values(optparse.Values):
other_dict = other_dict.__dict__
other_dict = other_dict.copy()
for setting in option_parser.lists.keys():
- if (hasattr(self, setting) and other_dict.has_key(setting)):
+ if (hasattr(self, setting) and setting in other_dict):
value = getattr(self, setting)
if value:
value += other_dict[setting]
@@ -359,12 +359,14 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec):
['--leave-comments'],
{'action': 'store_false', 'dest': 'strip_comments'}),
('Remove all elements with classes="<class>" from the document tree. '
+ 'Warning: potentially dangerous; use with caution. '
'(Multiple-use option.)',
['--strip-elements-with-class'],
{'action': 'append', 'dest': 'strip_elements_with_classes',
'metavar': '<class>', 'validator': validate_strip_class}),
('Remove all classes="<class>" attributes from elements in the '
- 'document tree. (Multiple-use option.)',
+ 'document tree. Warning: potentially dangerous; use with caution. '
+ '(Multiple-use option.)',
['--strip-class'],
{'action': 'append', 'dest': 'strip_classes',
'metavar': '<class>', 'validator': validate_strip_class}),
@@ -476,8 +478,9 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec):
config_section = 'general'
- version_template = ('%%prog (Docutils %s [%s])'
- % (docutils.__version__, docutils.__version_details__))
+ version_template = ('%%prog (Docutils %s [%s], Python %s, on %s)'
+ % (docutils.__version__, docutils.__version_details__,
+ sys.version.split()[0], sys.platform))
"""Default version message."""
def __init__(self, components=(), defaults=None, read_config_files=None,
@@ -582,7 +585,7 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec):
continue
for section in (tuple(component.config_section_dependencies or ())
+ (component.config_section,)):
- if applied.has_key(section):
+ if section in applied:
continue
applied[section] = 1
settings.update(parser.get_section(section), self)
@@ -696,7 +699,7 @@ Skipping "%s" configuration file.
if not self.has_section('general'):
self.add_section('general')
for key, value in options.items():
- if self.old_settings.has_key(key):
+ if key in self.old_settings:
section, setting = self.old_settings[key]
if not self.has_section(section):
self.add_section(section)
diff --git a/docutils/languages/__init__.py b/docutils/languages/__init__.py
index c721c0210..7d6521fc1 100644
--- a/docutils/languages/__init__.py
+++ b/docutils/languages/__init__.py
@@ -14,7 +14,7 @@ __docformat__ = 'reStructuredText'
_languages = {}
def get_language(language_code):
- if _languages.has_key(language_code):
+ if language_code in _languages:
return _languages[language_code]
module = __import__(language_code, globals(), locals())
_languages[language_code] = module
diff --git a/docutils/languages/pt_br.py b/docutils/languages/pt_br.py
index 92db002aa..f4adfbbf6 100644
--- a/docutils/languages/pt_br.py
+++ b/docutils/languages/pt_br.py
@@ -27,7 +27,7 @@ labels = {
'copyright': u'Copyright',
'dedication': u'Dedicat\u00F3ria',
'abstract': u'Resumo',
- 'attention': u'Atten\u00E7\u00E3o!',
+ 'attention': u'Aten\u00E7\u00E3o!',
'caution': u'Cuidado!',
'danger': u'PERIGO!',
'error': u'Erro',
diff --git a/docutils/nodes.py b/docutils/nodes.py
index ffb679b17..816befd4d 100644
--- a/docutils/nodes.py
+++ b/docutils/nodes.py
@@ -27,7 +27,6 @@ import re
import warnings
from types import IntType, SliceType, StringType, UnicodeType, \
TupleType, ListType, ClassType, TypeType
-from UserString import UserString
# ==============================
@@ -62,11 +61,7 @@ class Node:
return 1
def __str__(self):
- return self.__unicode__().encode('raw_unicode_escape')
-
- def __unicode__(self):
- # Override in subclass.
- raise NotImplementedError
+ return unicode(self).encode('raw_unicode_escape')
def asdom(self, dom=None):
"""Return a DOM **fragment** representation of this Node."""
@@ -273,7 +268,15 @@ class Node:
except IndexError:
return None
-class Text(Node, UserString):
+class reprunicode(unicode):
+ """
+ A class that removes the initial u from unicode's repr.
+ """
+
+ def __repr__(self):
+ return unicode.__repr__(self)[1:]
+
+class Text(Node, reprunicode):
"""
Instances are terminal nodes (leaves) containing text only; no child
@@ -286,38 +289,44 @@ class Text(Node, UserString):
children = ()
"""Text nodes have no children, and cannot have children."""
+ def __new__(cls, data, rawsource=None):
+ """Prevent the rawsource argument from propagating to str."""
+ return reprunicode.__new__(cls, data)
+
def __init__(self, data, rawsource=''):
- UserString.__init__(self, data)
self.rawsource = rawsource
"""The raw text from which this element was constructed."""
def __repr__(self):
- data = repr(self.data)
+ data = reprunicode.__repr__(self)
if len(data) > 70:
- data = repr(self.data[:64] + ' ...')
+ data = reprunicode.__repr__(self[:64] + ' ...')
return '<%s: %s>' % (self.tagname, data)
- def __len__(self):
- return len(self.data)
-
def shortrepr(self):
- data = repr(self.data)
+ data = reprunicode.__repr__(self)
if len(data) > 20:
- data = repr(self.data[:16] + ' ...')
+ data = reprunicode.__repr__(self[:16] + ' ...')
return '<%s: %s>' % (self.tagname, data)
def _dom_node(self, domroot):
- return domroot.createTextNode(self.data)
+ return domroot.createTextNode(unicode(self))
def astext(self):
- return self.data
+ return reprunicode(self)
- def __unicode__(self):
- return self.data
+ # Note about __unicode__: The implementation of __unicode__ here,
+ # and the one raising NotImplemented in the superclass Node had
+ # to be removed when changing Text to a subclass of unicode instead
+ # of UserString, since there is no way to delegate the __unicode__
+ # call to the superclass unicode:
+ # unicode itself does not have __unicode__ method to delegate to
+ # and calling unicode(self) or unicode.__new__ directly creates
+ # an infinite loop
def copy(self):
- return self.__class__(self.data)
+ return self.__class__(reprunicode(self), rawsource=self.rawsource)
def deepcopy(self):
return self.copy()
@@ -325,10 +334,19 @@ class Text(Node, UserString):
def pformat(self, indent=' ', level=0):
result = []
indent = indent * level
- for line in self.data.splitlines():
+ for line in self.splitlines():
result.append(indent + line + '\n')
return ''.join(result)
+ # rstrip and lstrip are used by substitution definitions where
+ # they are expected to return a Text instance, this was formerly
+ # taken care of by UserString. Note that then and now the
+ # rawsource member is lost.
+
+ def rstrip(self, chars=None):
+ return self.__class__(reprunicode.rstrip(self, chars))
+ def lstrip(self, chars=None):
+ return self.__class__(reprunicode.lstrip(self, chars))
class Element(Node):
@@ -539,10 +557,10 @@ class Element(Node):
return self.attributes.get(key, failobj)
def hasattr(self, attr):
- return self.attributes.has_key(attr)
+ return attr in self.attributes
def delattr(self, attr):
- if self.attributes.has_key(attr):
+ if attr in self.attributes:
del self.attributes[attr]
def setdefault(self, key, failobj=None):
@@ -550,6 +568,9 @@ class Element(Node):
has_key = hasattr
+ # support operator in
+ __contains__ = hasattr
+
def append(self, item):
self.setup_child(item)
self.children.append(item)
@@ -930,18 +951,18 @@ class document(Root, Structural, Element):
def set_id(self, node, msgnode=None):
for id in node['ids']:
- if self.ids.has_key(id) and self.ids[id] is not node:
+ if id in self.ids and self.ids[id] is not node:
msg = self.reporter.severe('Duplicate ID: "%s".' % id)
if msgnode != None:
msgnode += msg
if not node['ids']:
for name in node['names']:
id = self.settings.id_prefix + make_id(name)
- if id and not self.ids.has_key(id):
+ if id and id not in self.ids:
break
else:
id = ''
- while not id or self.ids.has_key(id):
+ while not id or id in self.ids:
id = (self.settings.id_prefix +
self.settings.auto_id_prefix + str(self.id_start))
self.id_start += 1
@@ -982,7 +1003,7 @@ class document(Root, Structural, Element):
The new target is invalidated regardless.
"""
for name in node['names']:
- if self.nameids.has_key(name):
+ if name in self.nameids:
self.set_duplicate_name_id(node, id, name, msgnode, explicit)
else:
self.nameids[name] = id
@@ -997,10 +1018,10 @@ class document(Root, Structural, Element):
level = 2
if old_id is not None:
old_node = self.ids[old_id]
- if node.has_key('refuri'):
+ if 'refuri' in node:
refuri = node['refuri']
if old_node['names'] \
- and old_node.has_key('refuri') \
+ and 'refuri' in old_node \
and old_node['refuri'] == refuri:
level = 1 # just inform if refuri's identical
if level > 1:
@@ -1031,7 +1052,7 @@ class document(Root, Structural, Element):
msgnode += msg
def has_name(self, name):
- return self.nameids.has_key(name)
+ return name in self.nameids
# "note" here is an imperative verb: "take note of".
def note_implicit_target(self, target, msgnode=None):
@@ -1091,7 +1112,7 @@ class document(Root, Structural, Element):
def note_substitution_def(self, subdef, def_name, msgnode=None):
name = whitespace_normalize_name(def_name)
- if self.substitution_defs.has_key(name):
+ if name in self.substitution_defs:
msg = self.reporter.error(
'Duplicate substitution definition name: "%s".' % name,
base_node=subdef)
diff --git a/docutils/parsers/__init__.py b/docutils/parsers/__init__.py
index 125ab7674..2683376f9 100644
--- a/docutils/parsers/__init__.py
+++ b/docutils/parsers/__init__.py
@@ -41,7 +41,7 @@ _parser_aliases = {
def get_parser_class(parser_name):
"""Return the Parser class from the `parser_name` module."""
parser_name = parser_name.lower()
- if _parser_aliases.has_key(parser_name):
+ if parser_name in _parser_aliases:
parser_name = _parser_aliases[parser_name]
module = __import__(parser_name, globals(), locals())
return module.Parser
diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py
index 14ac03a99..30da65ecd 100644
--- a/docutils/parsers/rst/directives/__init__.py
+++ b/docutils/parsers/rst/directives/__init__.py
@@ -76,7 +76,7 @@ def directive(directive_name, language_module, document):
normname = directive_name.lower()
messages = []
msg_text = []
- if _directives.has_key(normname):
+ if normname in _directives:
return _directives[normname], messages
canonicalname = None
try:
diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py
index bed3381b8..870b6659e 100644
--- a/docutils/parsers/rst/directives/admonitions.py
+++ b/docutils/parsers/rst/directives/admonitions.py
@@ -35,7 +35,7 @@ class BaseAdmonition(Directive):
self.lineno)
admonition_node += nodes.title(title_text, '', *textnodes)
admonition_node += messages
- if self.options.has_key('class'):
+ if 'class' in self.options:
classes = self.options['class']
else:
classes = ['admonition-' + nodes.make_id(title_text)]
diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py
index 03c9c3fa6..0cc695726 100644
--- a/docutils/parsers/rst/directives/body.py
+++ b/docutils/parsers/rst/directives/body.py
@@ -39,7 +39,7 @@ class BasePseudoSection(Directive):
textnodes, messages = self.state.inline_text(title_text, self.lineno)
titles = [nodes.title(title_text, '', *textnodes)]
# Sidebar uses this code.
- if self.options.has_key('subtitle'):
+ if 'subtitle' in self.options:
textnodes, more_messages = self.state.inline_text(
self.options['subtitle'], self.lineno)
titles.append(nodes.subtitle(self.options['subtitle'], '',
diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py
index 96bdb3353..59323bba0 100644
--- a/docutils/parsers/rst/directives/images.py
+++ b/docutils/parsers/rst/directives/images.py
@@ -46,7 +46,7 @@ class Image(Directive):
'class': directives.class_option}
def run(self):
- if self.options.has_key('align'):
+ if 'align' in self.options:
if isinstance(self.state, states.SubstitutionDef):
# Check for align_v_values.
if self.options['align'] not in self.align_v_values:
@@ -66,7 +66,7 @@ class Image(Directive):
reference = directives.uri(self.arguments[0])
self.options['uri'] = reference
reference_node = None
- if self.options.has_key('target'):
+ if 'target' in self.options:
block = states.escape2null(
self.options['target']).splitlines()
block = [line for line in block]
diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py
index 5d5d34729..89c8364c7 100644
--- a/docutils/parsers/rst/directives/misc.py
+++ b/docutils/parsers/rst/directives/misc.py
@@ -86,7 +86,7 @@ class Include(Directive):
raise self.severe('Problem with "end-before" option of "%s" '
'directive:\nText not found.' % self.name)
include_text = include_text[:before_index]
- if self.options.has_key('literal'):
+ if 'literal' in self.options:
literal_block = nodes.literal_block(include_text, include_text,
source=path)
literal_block.line = 1
@@ -120,20 +120,20 @@ class Raw(Directive):
def run(self):
if (not self.state.document.settings.raw_enabled
or (not self.state.document.settings.file_insertion_enabled
- and (self.options.has_key('file')
- or self.options.has_key('url')))):
+ and ('file' in self.options
+ or 'url' in self.options))):
raise self.warning('"%s" directive disabled.' % self.name)
attributes = {'format': ' '.join(self.arguments[0].lower().split())}
encoding = self.options.get(
'encoding', self.state.document.settings.input_encoding)
if self.content:
- if self.options.has_key('file') or self.options.has_key('url'):
+ if 'file' in self.options or 'url' in self.options:
raise self.error(
'"%s" directive may not both specify an external file '
'and have content.' % self.name)
text = '\n'.join(self.content)
- elif self.options.has_key('file'):
- if self.options.has_key('url'):
+ elif 'file' in self.options:
+ if 'url' in self.options:
raise self.error(
'The "file" and "url" options may not be simultaneously '
'specified for the "%s" directive.' % self.name)
@@ -159,7 +159,7 @@ class Raw(Directive):
'Problem with "%s" directive:\n%s: %s'
% (self.name, error.__class__.__name__, error))
attributes['source'] = path
- elif self.options.has_key('url'):
+ elif 'url' in self.options:
source = self.options['url']
# Do not import urllib2 at the top of the module because
# it may fail due to broken SSL dependencies, and it takes
@@ -244,12 +244,12 @@ class Unicode(Directive):
'Invalid context: the "%s" directive can only be used within '
'a substitution definition.' % self.name)
substitution_definition = self.state_machine.node
- if self.options.has_key('trim'):
+ if 'trim' in self.options:
substitution_definition.attributes['ltrim'] = 1
substitution_definition.attributes['rtrim'] = 1
- if self.options.has_key('ltrim'):
+ if 'ltrim' in self.options:
substitution_definition.attributes['ltrim'] = 1
- if self.options.has_key('rtrim'):
+ if 'rtrim' in self.options:
substitution_definition.attributes['rtrim'] = 1
codes = self.comment_pattern.split(self.arguments[0])[0].split()
element = nodes.Element()
@@ -349,7 +349,7 @@ class Role(Directive):
nodes.literal_block(self.block_text, self.block_text),
line=self.lineno)
return messages + [error]
- if not options.has_key('class'):
+ if 'class' not in options:
try:
options['class'] = directives.class_option(new_role_name)
except ValueError, detail:
@@ -373,7 +373,7 @@ class DefaultRole(Directive):
def run(self):
if not self.arguments:
- if roles._roles.has_key(''):
+ if '' in roles._roles:
# restore the "default" default role
del roles._roles['']
return []
diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py
index da1586275..6ef8c905c 100644
--- a/docutils/parsers/rst/directives/parts.py
+++ b/docutils/parsers/rst/directives/parts.py
@@ -57,13 +57,13 @@ class Contents(Directive):
title = nodes.title(title_text, '', *text_nodes)
else:
messages = []
- if self.options.has_key('local'):
+ if 'local' in self.options:
title = None
else:
title = nodes.title('', language.labels['contents'])
topic = nodes.topic(classes=['contents'])
topic['classes'] += self.options.get('class', [])
- if self.options.has_key('local'):
+ if 'local' in self.options:
topic['classes'].append('local')
if title:
name = title.astext()
diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py
index 639ce8d1f..5527c9f0b 100644
--- a/docutils/parsers/rst/directives/tables.py
+++ b/docutils/parsers/rst/directives/tables.py
@@ -49,7 +49,7 @@ class Table(Directive):
source = self.state_machine.get_source(self.lineno - 1)
table_head = []
max_header_cols = 0
- if self.options.has_key('header'): # separate table header in option
+ if 'header' in self.options: # separate table header in option
rows, max_header_cols = self.parse_csv_data_into_rows(
self.options['header'].split('\n'), self.HeaderDialect(),
source)
@@ -88,7 +88,7 @@ class Table(Directive):
raise SystemMessagePropagation(error)
def get_column_widths(self, max_cols):
- if self.options.has_key('widths'):
+ if 'widths' in self.options:
col_widths = self.options['widths']
if len(col_widths) != max_cols:
error = self.state_machine.reporter.error(
@@ -170,13 +170,13 @@ class CSVTable(Table):
quoting = csv.QUOTE_MINIMAL
def __init__(self, options):
- if options.has_key('delim'):
+ if 'delim' in options:
self.delimiter = str(options['delim'])
- if options.has_key('keepspace'):
+ if 'keepspace' in options:
self.skipinitialspace = False
- if options.has_key('quote'):
+ if 'quote' in options:
self.quotechar = str(options['quote'])
- if options.has_key('escape'):
+ if 'escape' in options:
self.doublequote = False
self.escapechar = str(options['escape'])
csv.Dialect.__init__(self)
@@ -206,8 +206,8 @@ class CSVTable(Table):
def run(self):
try:
if (not self.state.document.settings.file_insertion_enabled
- and (self.options.has_key('file')
- or self.options.has_key('url'))):
+ and ('file' in self.options
+ or 'url' in self.options)):
warning = self.state_machine.reporter.warning(
'File and URL access deactivated; ignoring "%s" '
'directive.' % self.name, nodes.literal_block(
@@ -253,7 +253,7 @@ class CSVTable(Table):
'encoding', self.state.document.settings.input_encoding)
if self.content:
# CSV data is from directive content.
- if self.options.has_key('file') or self.options.has_key('url'):
+ if 'file' in self.options or 'url' in self.options:
error = self.state_machine.reporter.error(
'"%s" directive may not both specify an external file and'
' have content.' % self.name, nodes.literal_block(
@@ -261,9 +261,9 @@ class CSVTable(Table):
raise SystemMessagePropagation(error)
source = self.content.source(0)
csv_data = self.content
- elif self.options.has_key('file'):
+ elif 'file' in self.options:
# CSV data is from an external file.
- if self.options.has_key('url'):
+ if 'url' in self.options:
error = self.state_machine.reporter.error(
'The "file" and "url" options may not be simultaneously'
' specified for the "%s" directive.' % self.name,
@@ -289,7 +289,7 @@ class CSVTable(Table):
% (self.name, error), nodes.literal_block(
self.block_text, self.block_text), line=self.lineno)
raise SystemMessagePropagation(severe)
- elif self.options.has_key('url'):
+ elif 'url' in self.options:
# CSV data is from a URL.
# Do not import urllib2 at the top of the module because
# it may fail due to broken SSL dependencies, and it takes
diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py
index 18c884748..962802245 100644
--- a/docutils/parsers/rst/languages/__init__.py
+++ b/docutils/parsers/rst/languages/__init__.py
@@ -15,7 +15,7 @@ __docformat__ = 'reStructuredText'
_languages = {}
def get_language(language_code):
- if _languages.has_key(language_code):
+ if language_code in _languages:
return _languages[language_code]
try:
module = __import__(language_code, globals(), locals())
diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py
index ecdde3837..300a8a30f 100644
--- a/docutils/parsers/rst/languages/de.py
+++ b/docutils/parsers/rst/languages/de.py
@@ -1,6 +1,6 @@
# $Id$
# Authors: Engelbert Gruber <grubert@users.sourceforge.net>;
-# Felix Wiemann <Felix.Wiemann@ososo.de>
+# Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py
index 1da1395e9..062d53e50 100644
--- a/docutils/parsers/rst/roles.py
+++ b/docutils/parsers/rst/roles.py
@@ -101,7 +101,7 @@ def role(role_name, language_module, lineno, reporter):
messages = []
msg_text = []
- if _roles.has_key(normname):
+ if normname in _roles:
return _roles[normname], messages
if role_name:
@@ -135,7 +135,7 @@ def role(role_name, language_module, lineno, reporter):
messages.append(message)
# Look the role up in the registry, and return it.
- if _role_registry.has_key(canonicalname):
+ if canonicalname in _role_registry:
role_fn = _role_registry[canonicalname]
register_local_role(normname, role_fn)
return role_fn, messages
@@ -171,7 +171,7 @@ def set_implicit_options(role_fn):
"""
if not hasattr(role_fn, 'options') or role_fn.options is None:
role_fn.options = {'class': directives.class_option}
- elif not role_fn.options.has_key('class'):
+ elif 'class' not in role_fn.options:
role_fn.options['class'] = directives.class_option
def register_generic_role(canonical_name, node_class):
@@ -294,7 +294,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner,
register_canonical_role('rfc-reference', rfc_reference_role)
def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
- if not options.has_key('format'):
+ if 'format' not in options:
msg = inliner.reporter.error(
'No format (Writer name) is associated with this role: "%s".\n'
'The "raw" role cannot be used directly.\n'
@@ -340,7 +340,7 @@ def set_classes(options):
Auxiliary function to set options['classes'] and delete
options['class'].
"""
- if options.has_key('class'):
- assert not options.has_key('classes')
+ if 'class' in options:
+ assert 'classes' not in options
options['classes'] = options['class']
del options['class']
diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py
index 50f5dd082..d5efb20e5 100644
--- a/docutils/parsers/rst/states.py
+++ b/docutils/parsers/rst/states.py
@@ -512,8 +512,8 @@ class Inliner:
non_whitespace_before = r'(?<![ \n])'
non_whitespace_escape_before = r'(?<![ \n\x00])'
non_whitespace_after = r'(?![ \n])'
- # Alphanumerics with isolated internal [-._] chars (i.e. not 2 together):
- simplename = r'(?:(?!_)\w)+(?:[-._](?:(?!_)\w)+)*'
+ # Alphanumerics with isolated internal [-._+:] chars (i.e. not 2 together):
+ simplename = r'(?:(?!_)\w)+(?:[-._+:](?:(?!_)\w)+)*'
# Valid URI characters (see RFC 2396 & RFC 2732);
# final \x00 allows backslash escapes in URIs:
uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9\x00]"""
@@ -901,8 +901,8 @@ class Inliner:
return self.reference(match, lineno, anonymous=1)
def standalone_uri(self, match, lineno):
- if not match.group('scheme') or urischemes.schemes.has_key(
- match.group('scheme').lower()):
+ if (not match.group('scheme')
+ or match.group('scheme').lower() in urischemes.schemes):
if match.group('email'):
addscheme = 'mailto:'
else:
@@ -2249,7 +2249,8 @@ class Body(RSTState):
if expmatch:
try:
return method(self, expmatch)
- except MarkupError, (message, lineno): # never reached?
+ except MarkupError, error: # never reached?
+ message, lineno = error.args
errors.append(self.reporter.warning(message, line=lineno))
break
nodelist, blank_finish = self.comment(match)
diff --git a/docutils/readers/__init__.py b/docutils/readers/__init__.py
index 74db893f9..a28248f70 100644
--- a/docutils/readers/__init__.py
+++ b/docutils/readers/__init__.py
@@ -101,7 +101,7 @@ _reader_aliases = {}
def get_reader_class(reader_name):
"""Return the Reader class from the `reader_name` module."""
reader_name = reader_name.lower()
- if _reader_aliases.has_key(reader_name):
+ if reader_name in _reader_aliases:
reader_name = _reader_aliases[reader_name]
module = __import__(reader_name, globals(), locals())
return module.Reader
diff --git a/docutils/readers/python/__init__.py b/docutils/readers/python/__init__.py
index da8fb22d2..eac284a7e 100644
--- a/docutils/readers/python/__init__.py
+++ b/docutils/readers/python/__init__.py
@@ -94,7 +94,7 @@ class DocstringFormattingVisitor(nodes.SparseNodeVisitor):
visitation, so parser instances are cached.
"""
parser_name = parsers._parser_aliases.get(parser_name, parser_name)
- if not self.parsers.has_key(parser_name):
+ if parser_name not in self.parsers:
cls = parsers.get_parser_class(parser_name)
self.parsers[parser_name] = cls()
return self.parsers[parser_name]
diff --git a/docutils/readers/python/moduleparser.py b/docutils/readers/python/moduleparser.py
index 5e63c9876..fadb3586b 100644
--- a/docutils/readers/python/moduleparser.py
+++ b/docutils/readers/python/moduleparser.py
@@ -53,78 +53,78 @@ The module parser will produce this module documentation tree::
<docstring lineno="5">
Additional docstring
<attribute lineno="7">
- <object_name>
- __docformat__
+ <object_name>
+ __docformat__
<expression_value lineno="7">
'reStructuredText'
<attribute lineno="9">
- <object_name>
- a
+ <object_name>
+ a
<expression_value lineno="9">
1
<docstring lineno="10">
Attribute docstring
<class_section lineno="12">
- <object_name>
- C
+ <object_name>
+ C
<class_base>
- Super
+ Super
<docstring lineno="12">
C's docstring
<attribute lineno="16">
- <object_name>
- class_attribute
+ <object_name>
+ class_attribute
<expression_value lineno="16">
1
<docstring lineno="17">
class_attribute's docstring
<method_section lineno="19">
- <object_name>
- __init__
+ <object_name>
+ __init__
<docstring lineno="19">
__init__'s docstring
<parameter_list lineno="19">
<parameter lineno="19">
- <object_name>
- self
+ <object_name>
+ self
<parameter lineno="19">
- <object_name>
- text
+ <object_name>
+ text
<parameter_default lineno="19">
None
<attribute lineno="22">
- <object_name>
- self.instance_attribute
+ <object_name>
+ self.instance_attribute
<expression_value lineno="22">
(text * 7 + ' whaddyaknow')
<docstring lineno="24">
instance_attribute's docstring
<function_section lineno="27">
- <object_name>
- f
+ <object_name>
+ f
<docstring lineno="27">
f's docstring
<parameter_list lineno="27">
<parameter lineno="27">
- <object_name>
- x
+ <object_name>
+ x
<comment>
# parameter x
<parameter lineno="27">
- <object_name>
- y
+ <object_name>
+ y
<parameter_default lineno="27">
a * 5
<comment>
# parameter y
<parameter excess_positional="1" lineno="27">
- <object_name>
- args
+ <object_name>
+ args
<comment>
# parameter args
<attribute lineno="33">
- <object_name>
- f.function_attribute
+ <object_name>
+ f.function_attribute
<expression_value lineno="33">
1
<docstring lineno="34">
@@ -525,14 +525,14 @@ class TokenParser:
def note_token(self):
if self.type == tokenize.NL:
return
- del_ws = self.del_ws_prefix.has_key(self.string)
- append_ws = not self.no_ws_suffix.has_key(self.string)
- if self.openers.has_key(self.string):
+ del_ws = self.string in self.del_ws_prefix
+ append_ws = self.string not in self.no_ws_suffix
+ if self.string in self.openers:
self.stack.append(self.string)
if (self._type == token.NAME
- or self.closers.has_key(self._string)):
+ or self._string in self.closers):
del_ws = 1
- elif self.closers.has_key(self.string):
+ elif self.string in self.closers:
assert self.stack[-1] == self.closers[self.string]
self.stack.pop()
elif self.string == '`':
diff --git a/docutils/statemachine.py b/docutils/statemachine.py
index 514e5dbd1..c29f128a7 100644
--- a/docutils/statemachine.py
+++ b/docutils/statemachine.py
@@ -377,7 +377,7 @@ class StateMachine:
self.next_line(len(block) - 1)
return block
except UnexpectedIndentationError, error:
- block, source, lineno = error
+ block, source, lineno = error.args
self.next_line(len(block) - 1) # advance to last line of block
raise
@@ -441,7 +441,7 @@ class StateMachine:
added.
"""
statename = state_class.__name__
- if self.states.has_key(statename):
+ if statename in self.states:
raise DuplicateStateError(statename)
self.states[statename] = state_class(self, self.debug)
@@ -629,9 +629,9 @@ class State:
Exceptions: `DuplicateTransitionError`, `UnknownTransitionError`.
"""
for name in names:
- if self.transitions.has_key(name):
+ if name in self.transitions:
raise DuplicateTransitionError(name)
- if not transitions.has_key(name):
+ if name not in transitions:
raise UnknownTransitionError(name)
self.transition_order[:0] = names
self.transitions.update(transitions)
@@ -644,7 +644,7 @@ class State:
Exception: `DuplicateTransitionError`.
"""
- if self.transitions.has_key(name):
+ if name in self.transitions:
raise DuplicateTransitionError(name)
self.transition_order[:0] = [name]
self.transitions[name] = transition
diff --git a/docutils/transforms/frontmatter.py b/docutils/transforms/frontmatter.py
index eae149a44..cd537f910 100644
--- a/docutils/transforms/frontmatter.py
+++ b/docutils/transforms/frontmatter.py
@@ -388,7 +388,7 @@ class DocInfo(Transform):
try:
name = field[0][0].astext()
normedname = nodes.fully_normalize_name(name)
- if not (len(field) == 2 and bibliofields.has_key(normedname)
+ if not (len(field) == 2 and normedname in bibliofields
and self.check_empty_biblio_field(field, name)):
raise TransformError
canonical = bibliofields[normedname]
diff --git a/docutils/transforms/parts.py b/docutils/transforms/parts.py
index 39cb74f75..26fcdb684 100644
--- a/docutils/transforms/parts.py
+++ b/docutils/transforms/parts.py
@@ -80,7 +80,7 @@ class Contents(Transform):
def apply(self):
details = self.startnode.details
- if details.has_key('local'):
+ if 'local' in details:
startnode = self.startnode.parent.parent
while not (isinstance(startnode, nodes.section)
or isinstance(startnode, nodes.document)):
@@ -89,7 +89,7 @@ class Contents(Transform):
else:
startnode = self.document
self.toc_id = self.startnode.parent['ids'][0]
- if details.has_key('backlinks'):
+ if 'backlinks' in details:
self.backlinks = details['backlinks']
else:
self.backlinks = self.document.settings.toc_backlinks
diff --git a/docutils/transforms/references.py b/docutils/transforms/references.py
index 097877ee9..c45fdb0da 100644
--- a/docutils/transforms/references.py
+++ b/docutils/transforms/references.py
@@ -240,7 +240,7 @@ class IndirectHyperlinks(Transform):
del target.multiply_indirect
if reftarget.hasattr('refuri'):
target['refuri'] = reftarget['refuri']
- if target.has_key('refid'):
+ if 'refid' in target:
del target['refid']
elif reftarget.hasattr('refid'):
target['refid'] = reftarget['refid']
@@ -257,7 +257,7 @@ class IndirectHyperlinks(Transform):
target.resolved = 1
def nonexistent_indirect_target(self, target):
- if self.document.nameids.has_key(target['refname']):
+ if target['refname'] in self.document.nameids:
self.indirect_target_error(target, 'which is a duplicate, and '
'cannot be used as a unique reference')
else:
@@ -505,7 +505,7 @@ class Footnotes(Transform):
while 1:
label = str(startnum)
startnum += 1
- if not self.document.nameids.has_key(label):
+ if label not in self.document.nameids:
break
footnote.insert(0, nodes.label('', label))
for name in footnote['names']:
@@ -600,12 +600,12 @@ class Footnotes(Transform):
"""
for footnote in self.document.footnotes:
for label in footnote['names']:
- if self.document.footnote_refs.has_key(label):
+ if label in self.document.footnote_refs:
reflist = self.document.footnote_refs[label]
self.resolve_references(footnote, reflist)
for citation in self.document.citations:
for label in citation['names']:
- if self.document.citation_refs.has_key(label):
+ if label in self.document.citation_refs:
reflist = self.document.citation_refs[label]
self.resolve_references(citation, reflist)
@@ -666,11 +666,11 @@ class Substitutions(Transform):
for ref in subreflist:
refname = ref['refname']
key = None
- if defs.has_key(refname):
+ if refname in defs:
key = refname
else:
normed_name = refname.lower()
- if normed.has_key(normed_name):
+ if normed_name in normed:
key = normed[normed_name]
if key is None:
msg = self.document.reporter.error(
@@ -686,14 +686,14 @@ class Substitutions(Transform):
subdef = defs[key]
parent = ref.parent
index = parent.index(ref)
- if (subdef.attributes.has_key('ltrim')
- or subdef.attributes.has_key('trim')):
+ if ('ltrim' in subdef.attributes
+ or 'trim' in subdef.attributes):
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 ('rtrim' in subdef.attributes
+ or 'trim' in subdef.attributes):
if (len(parent) > index + 1
and isinstance(parent[index + 1], nodes.Text)):
parent.replace(parent[index + 1],
@@ -764,7 +764,7 @@ class TargetNotes(Transform):
continue
footnote = self.make_target_footnote(target['refuri'], refs,
notes)
- if not notes.has_key(target['refuri']):
+ if target['refuri'] not in notes:
notes[target['refuri']] = footnote
nodelist.append(footnote)
# Take care of anonymous references.
@@ -774,13 +774,13 @@ class TargetNotes(Transform):
if ref.hasattr('refuri'):
footnote = self.make_target_footnote(ref['refuri'], [ref],
notes)
- if not notes.has_key(ref['refuri']):
+ if ref['refuri'] not in notes:
notes[ref['refuri']] = footnote
nodelist.append(footnote)
self.startnode.replace_self(nodelist)
def make_target_footnote(self, refuri, refs, notes):
- if notes.has_key(refuri): # duplicate?
+ if refuri in notes: # duplicate?
footnote = notes[refuri]
assert len(footnote['names']) == 1
footnote_name = footnote['names'][0]
@@ -873,7 +873,7 @@ class DanglingReferencesVisitor(nodes.SparseNodeVisitor):
if resolver_function(node):
break
else:
- if self.document.nameids.has_key(refname):
+ if refname in self.document.nameids:
msg = self.document.reporter.error(
'Duplicate target name, cannot be used as a unique '
'reference: "%s".' % (node['refname']), base_node=node)
diff --git a/docutils/transforms/writer_aux.py b/docutils/transforms/writer_aux.py
index 6be338338..0db085fb0 100644
--- a/docutils/transforms/writer_aux.py
+++ b/docutils/transforms/writer_aux.py
@@ -1,5 +1,5 @@
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/docutils/utils.py b/docutils/utils.py
index 456f3eed9..b88ffbbc1 100644
--- a/docutils/utils.py
+++ b/docutils/utils.py
@@ -161,7 +161,7 @@ class Reporter:
Raise an exception or generate a warning if appropriate.
"""
attributes = kwargs.copy()
- if kwargs.has_key('base_node'):
+ if 'base_node' in kwargs:
source, line = get_source_line(kwargs['base_node'])
del attributes['base_node']
if source is not None:
@@ -308,7 +308,7 @@ def assemble_option_dict(option_list, options_spec):
convertor = options_spec[name] # raises KeyError if unknown
if convertor is None:
raise KeyError(name) # or if explicitly disabled
- if options.has_key(name):
+ if name in options:
raise DuplicateOptionError('duplicate option "%s"' % name)
try:
options[name] = convertor(value)
@@ -404,9 +404,9 @@ def clean_rcs_keywords(paragraph, keyword_substitutions):
if len(paragraph) == 1 and isinstance(paragraph[0], nodes.Text):
textnode = paragraph[0]
for pattern, substitution in keyword_substitutions:
- match = pattern.search(textnode.data)
+ match = pattern.search(textnode)
if match:
- textnode.data = pattern.sub(substitution, textnode.data)
+ paragraph[0] = nodes.Text(pattern.sub(substitution, textnode))
return
def relative_path(source, target):
diff --git a/docutils/writers/__init__.py b/docutils/writers/__init__.py
index 39e1ecd5b..8e3bd1aaa 100644
--- a/docutils/writers/__init__.py
+++ b/docutils/writers/__init__.py
@@ -127,7 +127,7 @@ _writer_aliases = {
def get_writer_class(writer_name):
"""Return the Writer class from the `writer_name` module."""
writer_name = writer_name.lower()
- if _writer_aliases.has_key(writer_name):
+ if writer_name in _writer_aliases:
writer_name = _writer_aliases[writer_name]
module = __import__(writer_name, globals(), locals())
return module.Writer
diff --git a/docutils/writers/html4css1/__init__.py b/docutils/writers/html4css1/__init__.py
index 693672b76..57d2c6ef0 100644
--- a/docutils/writers/html4css1/__init__.py
+++ b/docutils/writers/html4css1/__init__.py
@@ -353,13 +353,13 @@ class HTMLTranslator(nodes.NodeVisitor):
for (name, value) in attributes.items():
atts[name.lower()] = value
classes = node.get('classes', [])
- if atts.has_key('class'):
+ if 'class' in atts:
classes.append(atts['class'])
if classes:
atts['class'] = ' '.join(classes)
- assert not atts.has_key('id')
+ assert 'id' not in atts
ids.extend(node.get('ids', []))
- if atts.has_key('ids'):
+ if 'ids' in atts:
ids.extend(atts['ids'])
del atts['ids']
if ids:
@@ -712,7 +712,7 @@ class HTMLTranslator(nodes.NodeVisitor):
assert not self.context, 'len(context) = %s' % len(self.context)
def visit_emphasis(self, node):
- self.body.append('<em>')
+ self.body.append(self.starttag(node, 'em', ''))
def depart_emphasis(self, node):
self.body.append('</em>')
@@ -731,9 +731,9 @@ class HTMLTranslator(nodes.NodeVisitor):
tagname = 'td'
del atts['class']
node.parent.column += 1
- if node.has_key('morerows'):
+ if 'morerows' in node:
atts['rowspan'] = node['morerows'] + 1
- if node.has_key('morecols'):
+ if 'morecols' in node:
atts['colspan'] = node['morecols'] + 1
node.parent.column += node['morecols']
self.body.append(self.starttag(node, tagname, '', **atts))
@@ -752,9 +752,9 @@ class HTMLTranslator(nodes.NodeVisitor):
usable.
"""
atts = {}
- if node.has_key('start'):
+ if 'start' in node:
atts['start'] = node['start']
- if node.has_key('enumtype'):
+ if 'enumtype' in node:
atts['class'] = node['enumtype']
# @@@ To do: prefix, suffix. How? Change prefix/suffix to a
# single "format" attribute? Use CSS2?
@@ -941,26 +941,26 @@ class HTMLTranslator(nodes.NodeVisitor):
def visit_image(self, node):
atts = {}
atts['src'] = node['uri']
- if node.has_key('width'):
+ if 'width' in node:
atts['width'] = node['width']
- if node.has_key('height'):
+ if 'height' in node:
atts['height'] = node['height']
- if node.has_key('scale'):
- if Image and not (node.has_key('width')
- and node.has_key('height')):
+ if 'scale' in node:
+ if Image and not ('width' in node
+ and 'height' in node):
try:
im = Image.open(str(atts['src']))
except (IOError, # Source image can't be found or opened
UnicodeError): # PIL doesn't like Unicode paths.
pass
else:
- if not atts.has_key('width'):
+ if 'width' not in atts:
atts['width'] = str(im.size[0])
- if not atts.has_key('height'):
+ if 'height' not in atts:
atts['height'] = str(im.size[1])
del im
for att_name in 'width', 'height':
- if atts.has_key(att_name):
+ if att_name in atts:
match = re.match(r'([0-9.]+)(\S*)$', atts[att_name])
assert match
atts[att_name] = '%s%s' % (
@@ -968,7 +968,7 @@ class HTMLTranslator(nodes.NodeVisitor):
match.group(2))
style = []
for att_name in 'width', 'height':
- if atts.has_key(att_name):
+ if att_name in atts:
if re.match(r'^[0-9.]+$', atts[att_name]):
# Interpret unitless values as pixels.
atts[att_name] += 'px'
@@ -984,7 +984,7 @@ class HTMLTranslator(nodes.NodeVisitor):
suffix = ''
else:
suffix = '\n'
- if node.has_key('align'):
+ if 'align' in node:
if node['align'] == 'center':
# "align" attribute is set in surrounding "div" element.
self.body.append('<div align="center" class="align-center">')
@@ -1167,12 +1167,11 @@ class HTMLTranslator(nodes.NodeVisitor):
if child is node:
break
return 0
+ parent_length = len([n for n in node.parent if not isinstance(
+ n, (nodes.Invisible, nodes.label))])
if ( self.compact_simple
or self.compact_field_list
- or (self.compact_p
- and (len(node.parent) == 1
- or len(node.parent) == 2
- and isinstance(node.parent[0], nodes.label)))):
+ or self.compact_p and parent_length == 1):
return 1
return 0
@@ -1210,17 +1209,19 @@ class HTMLTranslator(nodes.NodeVisitor):
raise nodes.SkipNode
def visit_reference(self, node):
- if node.has_key('refuri'):
- href = node['refuri']
+ atts = {'class': 'reference'}
+ if 'refuri' in node:
+ atts['href'] = node['refuri']
if ( self.settings.cloak_email_addresses
- and href.startswith('mailto:')):
- href = self.cloak_mailto(href)
+ and atts['href'].startswith('mailto:')):
+ atts['href'] = self.cloak_mailto(atts['href'])
self.in_mailto = 1
+ atts['class'] += ' external'
else:
- assert node.has_key('refid'), \
+ assert 'refid' in node, \
'References must have "refuri" or "refid" attribute.'
- href = '#' + node['refid']
- atts = {'href': href, 'class': 'reference'}
+ atts['href'] = '#' + node['refid']
+ atts['class'] += ' internal'
if not isinstance(node.parent, nodes.TextElement):
assert len(node) == 1 and isinstance(node[0], nodes.image)
atts['class'] += ' image-reference'
@@ -1277,7 +1278,7 @@ class HTMLTranslator(nodes.NodeVisitor):
self.depart_docinfo_item()
def visit_strong(self, node):
- self.body.append('<strong>')
+ self.body.append(self.starttag(node, 'strong', ''))
def depart_strong(self, node):
self.body.append('</strong>')
@@ -1363,8 +1364,8 @@ class HTMLTranslator(nodes.NodeVisitor):
self.body.append('</table>\n')
def visit_target(self, node):
- if not (node.has_key('refuri') or node.has_key('refid')
- or node.has_key('refname')):
+ if not ('refuri' in node or 'refid' in node
+ or 'refname' in node):
self.body.append(self.starttag(node, 'span', '', CLASS='target'))
self.context.append('</span>')
else:
diff --git a/docutils/writers/html4css1/html4css1.css b/docutils/writers/html4css1/html4css1.css
index 331a2979a..345f1cc85 100644
--- a/docutils/writers/html4css1/html4css1.css
+++ b/docutils/writers/html4css1/html4css1.css
@@ -106,7 +106,7 @@ div.line-block div.line-block {
margin-left: 1.5em }
div.sidebar {
- margin-left: 1em ;
+ margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index 0c459147e..4db7b67bf 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -21,6 +21,8 @@ from types import ListType
from docutils import frontend, nodes, languages, writers, utils
from docutils.writers.newlatex2e import unicode_map
+from docutils.transforms.references import DanglingReferencesVisitor
+
class Writer(writers.Writer):
supported = ('latex','latex2e')
@@ -74,6 +76,10 @@ class Writer(writers.Writer):
['--use-latex-toc'],
{'default': 0, 'action': 'store_true',
'validator': frontend.validate_boolean}),
+ ('Add parts on top of the section hierarchy.',
+ ['--use-part-section'],
+ {'default': 0, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
('Let LaTeX print author and date, do not show it in docutils '
'document info.',
['--use-latex-docinfo'],
@@ -110,8 +116,12 @@ class Writer(writers.Writer):
'for compound enumerated lists. Default is "-".',
['--section-enumerator-separator'],
{'default': '-', 'metavar': '<char>'}),
+ ('When possibile, use the specified environment for literal-blocks. '
+ 'Default is quoting of whitespace and special chars.',
+ ['--literal-block-env'],
+ {'default': '', }),
('When possibile, use verbatim for literal-blocks. '
- 'Default is to always use the mbox environment.',
+ 'Compatibility alias for "--literal-block-env=verbatim".',
['--use-verbatim-when-possible'],
{'default': 0, 'action': 'store_true',
'validator': frontend.validate_boolean}),
@@ -153,6 +163,9 @@ class Writer(writers.Writer):
config_section = 'latex2e writer'
config_section_dependencies = ('writers',)
+ visitor_attributes = ("head_prefix", "head",
+ "body_prefix", "body", "body_suffix")
+
output = None
"""Final translated form of `document`."""
@@ -164,11 +177,15 @@ class Writer(writers.Writer):
visitor = self.translator_class(self.document)
self.document.walkabout(visitor)
self.output = visitor.astext()
- self.head_prefix = visitor.head_prefix
- self.head = visitor.head
- self.body_prefix = visitor.body_prefix
- self.body = visitor.body
- self.body_suffix = visitor.body_suffix
+ # copy parts
+ for attr in self.visitor_attributes:
+ setattr(self, attr, getattr(visitor, attr))
+
+ def assemble_parts(self):
+ writers.Writer.assemble_parts(self)
+ for part in self.visitor_attributes:
+ self.parts[part] = ''.join(getattr(self, part))
+
"""
Notes on LaTeX
@@ -177,6 +194,9 @@ Notes on LaTeX
* LaTeX does not support multiple tocs in one document.
(might be no limitation except for docutils documentation)
+ The "minitoc" latex package can produce per-chapter tocs in
+ book and report document classes.
+
* width
* linewidth - width of a line in the local environment
@@ -276,13 +296,13 @@ class Babel:
return text.replace('"', self.double_quote_replacment)
def get_language(self):
- if self._ISO639_TO_BABEL.has_key(self.language):
+ if self.language in self._ISO639_TO_BABEL:
return self._ISO639_TO_BABEL[self.language]
else:
# support dialects.
- l = self.language.split("_")[0]
- if self._ISO639_TO_BABEL.has_key(l):
- return self._ISO639_TO_BABEL[l]
+ lang = self.language.split("_")[0]
+ if lang in self._ISO639_TO_BABEL:
+ return self._ISO639_TO_BABEL[lang]
return None
@@ -336,22 +356,9 @@ latex_headings = {
class DocumentClass:
"""Details of a LaTeX document class."""
- # BUG: LaTeX has no deeper sections (actually paragrah is no
- # section either).
- # BUG: No support for unknown document classes. Make 'article'
- # default?
- _class_sections = {
- 'book': ( 'chapter', 'section', 'subsection', 'subsubsection' ),
- 'scrbook': ( 'chapter', 'section', 'subsection', 'subsubsection' ),
- 'report': ( 'chapter', 'section', 'subsection', 'subsubsection' ),
- 'scrreprt': ( 'chapter', 'section', 'subsection', 'subsubsection' ),
- 'article': ( 'section', 'subsection', 'subsubsection' ),
- 'scrartcl': ( 'section', 'subsection', 'subsubsection' ),
- }
- _deepest_section = 'subsubsection'
-
- def __init__(self, document_class):
+ def __init__(self, document_class, with_part=False):
self.document_class = document_class
+ self._with_part = with_part
def section(self, level):
""" Return the section name at the given level for the specific
@@ -359,11 +366,16 @@ class DocumentClass:
Level is 1,2,3..., as level 0 is the title."""
- sections = self._class_sections[self.document_class]
+ sections = [ 'section', 'subsection', 'subsubsection',
+ 'paragraph', 'subparagraph' ]
+ if self.document_class in ('book', 'report', 'scrreprt', 'scrbook'):
+ sections.insert(0, 'chapter')
+ if self._with_part:
+ sections.insert(0, 'part')
if level <= len(sections):
return sections[level-1]
else:
- return self._deepest_section
+ return sections[-1]
class Table:
""" Manage a table while traversing.
@@ -384,6 +396,7 @@ class Table:
self._attrs = {}
self._col_width = []
self._rowspan = []
+ self.stubs = []
def open(self):
self._open = 1
@@ -396,8 +409,10 @@ class Table:
self._col_specs = None
self.caption = None
self._attrs = {}
+ self.stubs = []
def is_open(self):
return self._open
+
def set_table_style(self, table_style):
if not table_style in ('standard','booktabs','borderless','nolines'):
return
@@ -413,7 +428,7 @@ class Table:
def set(self,attr,value):
self._attrs[attr] = value
def get(self,attr):
- if self._attrs.has_key(attr):
+ if attr in self._attrs:
return self._attrs[attr]
return None
def get_vertical_bar(self):
@@ -422,7 +437,12 @@ class Table:
return ''
# horizontal lines are drawn below a row, because we.
def get_opening(self):
- return '\\begin{%s}[c]' % self._latex_type
+ if self._latex_type == 'longtable':
+ # otherwise longtable might move before paragraph and subparagraph
+ prefix = '\\leavevmode\n'
+ else:
+ prefix = ''
+ return '%s\\begin{%s}[c]' % (prefix, self._latex_type)
def get_closing(self):
line = ""
if self._table_style == 'booktabs':
@@ -431,8 +451,10 @@ class Table:
lines = '\\hline\n'
return '%s\\end{%s}' % (line,self._latex_type)
- def visit_colspec(self,node):
+ def visit_colspec(self, node):
self._col_specs.append(node)
+ # "stubs" list is an attribute of the tgroup element:
+ self.stubs.append(node.attributes.get('stub'))
def get_colspecs(self):
"""
@@ -466,7 +488,7 @@ class Table:
colwidth = factor * float(node['colwidth']+1) / width
self._col_width.append(colwidth+0.005)
self._rowspan.append(0)
- latex_table_spec += "%sp{%.2f\\locallinewidth}" % (bar,colwidth+0.005)
+ latex_table_spec += "%sp{%.3f\\locallinewidth}" % (bar,colwidth+0.005)
return latex_table_spec+bar
def get_column_width(self):
@@ -487,7 +509,8 @@ class Table:
# a.append('\\hline\n')
if self._table_style == 'booktabs':
a.append('\\midrule\n')
- a.append('\\endhead\n')
+ if self._latex_type == 'longtable':
+ a.append('\\endhead\n')
# for longtable one could add firsthead, foot and lastfoot
self._in_thead = 0
return a
@@ -534,6 +557,10 @@ class Table:
return self._cell_in_row
def visit_entry(self):
self._cell_in_row += 1
+ def is_stub_column(self):
+ if len(self.stubs) >= self._cell_in_row:
+ return self.stubs[self._cell_in_row-1]
+ return False
class LaTeXTranslator(nodes.NodeVisitor):
@@ -541,12 +568,19 @@ class LaTeXTranslator(nodes.NodeVisitor):
# When options are given to the documentclass, latex will pass them
# to other packages, as done with babel.
# Dummy settings might be taken from document settings
-
+
+ # Templates
+ # ---------
+
latex_head = '\\documentclass[%s]{%s}\n'
- linking = '\\usepackage[colorlinks=%s,linkcolor=%s,urlcolor=%s]{hyperref}\n'
+ linking = "\\ifthenelse{\\isundefined{\\hypersetup}}{\n" \
+ +"\\usepackage[colorlinks=%s,linkcolor=%s,urlcolor=%s]{hyperref}\n" \
+ +"}{}\n"
stylesheet = '\\input{%s}\n'
# add a generated on day , machine by user using docutils version.
- generator = '%% generator Docutils: http://docutils.sourceforge.net/\n'
+ generator = '% generated by Docutils <http://docutils.sourceforge.net/>\n'
+ # Config setting defaults
+ # -----------------------
# use latex tableofcontents or let docutils do it.
use_latex_toc = 0
@@ -592,6 +626,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self.settings.use_bibtex:
self.bibtex = self.settings.use_bibtex.split(",",1)
+ # TODO avoid errors on not declared citations.
else:
self.bibtex = None
# language: labels, bibliographic_fields, and author_separators.
@@ -601,11 +636,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.author_separator = self.language.author_separators[0]
self.d_options = self.settings.documentoptions
if self.babel.get_language():
- self.d_options += ',%s' % \
- self.babel.get_language()
+ self.d_options += ',%s' % self.babel.get_language()
- self.d_class = DocumentClass(settings.documentclass)
+ self.d_class = DocumentClass(settings.documentclass,
+ settings.use_part_section)
# object for a table while proccessing.
+ self.table_stack = []
self.active_table = Table('longtable',settings.table_style)
# HACK. Should have more sophisticated typearea handling.
@@ -663,7 +699,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
'\\usepackage{color}\n',
'\\usepackage{multirow}\n',
'\\usepackage{ifthen}\n', # before hyperref!
- self.linking % (self.colorlinks, self.hyperlink_color, self.hyperlink_color),
self.typearea,
self.generator,
# latex lengths
@@ -687,17 +722,25 @@ class LaTeXTranslator(nodes.NodeVisitor):
if stylesheet:
settings.record_dependencies.add(stylesheet)
self.head_prefix.append(self.stylesheet % (stylesheet))
-
+ # hyperref after stylesheet
+ # TODO conditionally if no hyperref is used dont include
+ self.head_prefix.append( self.linking % (
+ self.colorlinks, self.hyperlink_color, self.hyperlink_color))
+
+ #
+ if self.settings.literal_block_env != '':
+ self.settings.use_verbatim_when_possible = True
if self.linking: # and maybe check for pdf
self.pdfinfo = [ ]
self.pdfauthor = None
- # pdftitle, pdfsubject, pdfauthor, pdfkeywords, pdfcreator, pdfproducer
+ # pdftitle, pdfsubject, pdfauthor, pdfkeywords,
+ # pdfcreator, pdfproducer
else:
self.pdfinfo = None
# NOTE: Latex wants a date and an author, rst puts this into
- # docinfo, so normally we donot want latex author/date handling.
+ # docinfo, so normally we do not want latex author/date handling.
# latex article has its own handling of date and author, deactivate.
- # So we always emit \title{...} \author{...} \date{...}, even if the
+ # self.astext() adds \title{...} \author{...} \date{...}, even if the
# "..." are empty strings.
self.head = [ ]
# separate title, so we can appen subtitle.
@@ -788,7 +831,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
#"iso-8859-8": "" # hebrew
#"iso-8859-10": "" # latin6, more complete iso-8859-4
}
- if tr.has_key(docutils_encoding.lower()):
+ if docutils_encoding.lower() in tr:
return tr[docutils_encoding.lower()]
# convert: latin-1 and utf-8 and similar things
return docutils_encoding.replace("_", "").replace("-", "").lower()
@@ -824,7 +867,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
return text
def ensure_math(self, text):
- if not self.__dict__.has_key('ensure_math_re'):
+ if not 'ensure_math_re' in self.__dict__:
chars = {
# lnot,pm,twosuperior,threesuperior,mu,onesuperior,times,div
'latin1' : '\xac\xb1\xb2\xb3\xb5\xb9\xd7\xf7' ,
@@ -848,10 +891,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
# compile the regexps once. do it here so one can see them.
#
# first the braces.
- if not self.__dict__.has_key('encode_re_braces'):
+ if not 'encode_re_braces' in self.__dict__:
self.encode_re_braces = re.compile(r'([{}])')
text = self.encode_re_braces.sub(r'{\\\1}',text)
- if not self.__dict__.has_key('encode_re_bslash'):
+ if not 'encode_re_bslash' in self.__dict__:
# find backslash: except in the form '{\{}' or '{\}}'.
self.encode_re_bslash = re.compile(r'(?<!{)(\\)(?![{}]})')
# then the backslash: except in the form from line above:
@@ -909,6 +952,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
# ! LaTeX Error: There's no line here to end.
text = text.replace("\n", '~\\\\\n')
elif self.mbox_newline:
+ # TODO dead code: remove after 0.5 release
if self.literal_block:
closings = "}" * len(self.literal_block_stack)
openings = "".join(self.literal_block_stack)
@@ -924,15 +968,26 @@ class LaTeXTranslator(nodes.NodeVisitor):
text = self.ensure_math(text)
return text
+ def literal_block_env(self, begin_or_end):
+ env = 'verbatim'
+ opt = ''
+ if self.settings.literal_block_env != '':
+ (none, env, opt, none) = re.split("(\w+)(.*)",
+ self.settings.literal_block_env)
+ if begin_or_end == 'begin':
+ return '\\begin{%s}%s\n' % (env, opt)
+ return '\n\\end{%s}\n' % (env, )
+
+
+
def attval(self, text,
whitespace=re.compile('[\n\r\t\v\f]')):
"""Cleanse, encode, and return attribute value text."""
return self.encode(whitespace.sub(' ', text))
def astext(self):
- if self.pdfinfo is not None:
- if self.pdfauthor:
- self.pdfinfo.append('pdfauthor={%s}' % self.pdfauthor)
+ if self.pdfinfo is not None and self.pdfauthor:
+ self.pdfinfo.append('pdfauthor={%s}' % self.pdfauthor)
if self.pdfinfo:
pdfinfo = '\\hypersetup{\n' + ',\n'.join(self.pdfinfo) + '\n}\n'
else:
@@ -1070,9 +1125,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.inside_citation_reference_label = 1
else:
href = ''
- if node.has_key('refid'):
+ if 'refid' in node:
href = node['refid']
- elif node.has_key('refname'):
+ elif 'refname' in node:
href = self.document.nameids[node['refname']]
self.body.append('[\\hyperlink{%s}{' % href)
@@ -1169,10 +1224,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append( '\\end{description}\n' )
def visit_definition_list_item(self, node):
- self.body.append('%[visit_definition_list_item]\n')
+ pass
def depart_definition_list_item(self, node):
- self.body.append('%[depart_definition_list_item]\n')
+ pass
def visit_description(self, node):
self.body.append( ' ' )
@@ -1250,9 +1305,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body_prefix.append('\\begin{document}\n')
# titled document?
if self.use_latex_docinfo or len(node) and isinstance(node[0], nodes.title):
- self.body_prefix.append('\\maketitle\n\n')
+ self.body_prefix.append('\\maketitle\n')
# alternative use titlepage environment.
# \begin{titlepage}
+ # ...
self.body.append('\n\\setlength{\\locallinewidth}{\\linewidth}\n')
def depart_document(self, node):
@@ -1302,17 +1358,17 @@ class LaTeXTranslator(nodes.NodeVisitor):
# IN WORK BUG TODO HACK continues here
# multirow in LaTeX simply will enlarge the cell over several rows
# (the following n if n is positive, the former if negative).
- if node.has_key('morerows') and node.has_key('morecols'):
+ if 'morerows' in node and 'morecols' in node:
raise NotImplementedError('Cells that '
'span multiple rows *and* columns are not supported, sorry.')
- if node.has_key('morerows'):
+ if 'morerows' in node:
count = node['morerows'] + 1
self.active_table.set_rowspan(self.active_table.get_entry_number()-1,count)
self.body.append('\\multirow{%d}{%s}{' % \
(count,self.active_table.get_column_width()))
self.context.append('}')
# BUG following rows must have empty cells.
- elif node.has_key('morecols'):
+ elif 'morecols' in node:
# the vertical bar before column is missing if it is the first column.
# the one after always.
if self.active_table.get_entry_number() == 1:
@@ -1330,6 +1386,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
if isinstance(node.parent.parent, nodes.thead):
self.body.append('\\textbf{')
self.context.append('}')
+ elif self.active_table.is_stub_column():
+ self.body.append('\\textbf{')
+ self.context.append('}')
else:
self.context.append('')
@@ -1357,10 +1416,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
'lowerroman':'roman',
'upperroman':'Roman' }
enum_suffix = ""
- if node.has_key('suffix'):
+ if 'suffix' in node:
enum_suffix = node['suffix']
enum_prefix = ""
- if node.has_key('prefix'):
+ if 'prefix' in node:
enum_prefix = node['prefix']
if self.compound_enumerators:
pref = ""
@@ -1372,9 +1431,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
for ctype, cname in self._enumeration_counters:
enum_prefix += '\\%s{%s}.' % (ctype, cname)
enum_type = "arabic"
- if node.has_key('enumtype'):
+ if 'enumtype' in node:
enum_type = node['enumtype']
- if enum_style.has_key(enum_type):
+ if enum_type in enum_style:
enum_type = enum_style[enum_type]
counter_name = "listcnt%d" % len(self._enumeration_counters)
@@ -1392,7 +1451,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('{\n')
self.body.append('\\usecounter{%s}\n' % counter_name)
# set start after usecounter, because it initializes to zero.
- if node.has_key('start'):
+ if 'start' in node:
self.body.append('\\addtocounter{%s}{%d}\n' \
% (counter_name,node['start']-1))
## set rightmargin equal to leftmargin
@@ -1456,7 +1515,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(':]')
def visit_figure(self, node):
- if (not node.attributes.has_key('align') or
+ if ('align' not in node.attributes or
node.attributes['align'] == 'center'):
# centering does not add vertical space like center.
align = '\n\\centering'
@@ -1503,9 +1562,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append("\\footnotemark["+self.encode(node.astext())+"]")
raise nodes.SkipNode
href = ''
- if node.has_key('refid'):
+ if 'refid' in node:
href = node['refid']
- elif node.has_key('refname'):
+ elif 'refname' in node:
href = self.document.nameids[node['refname']]
format = self.settings.footnote_references
if format == 'brackets':
@@ -1589,18 +1648,18 @@ class LaTeXTranslator(nodes.NodeVisitor):
post = []
include_graphics_options = []
inline = isinstance(node.parent, nodes.TextElement)
- if attrs.has_key('scale'):
+ if 'scale' in attrs:
# Could also be done with ``scale`` option to
# ``\includegraphics``; doing it this way for consistency.
pre.append('\\scalebox{%f}{' % (attrs['scale'] / 100.0,))
post.append('}')
- if attrs.has_key('width'):
+ if 'width' in attrs:
include_graphics_options.append('width=%s' % (
self.latex_image_length(attrs['width']), ))
- if attrs.has_key('height'):
+ if 'height' in attrs:
include_graphics_options.append('height=%s' % (
self.latex_image_length(attrs['height']), ))
- if attrs.has_key('align'):
+ if 'align' in attrs:
align_prepost = {
# By default latex aligns the top of an image.
(1, 'top'): ('', ''),
@@ -1707,13 +1766,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
# table border and literal block.
# BUG: fails if normal text preceeds the literal block.
self.body.append('\\begin{quote}')
+ self.context.append('\\end{quote}\n')
else:
self.body.append('\n')
+ self.context.append('\n')
if (self.settings.use_verbatim_when_possible and (len(node) == 1)
# in case of a parsed-literal containing just a "**bold**" word:
and isinstance(node[0], nodes.Text)):
self.verbatim = 1
- self.body.append('\\begin{verbatim}\n')
+ self.body.append(self.literal_block_env('begin'))
else:
self.literal_block = 1
self.insert_none_breaking_blanks = 1
@@ -1723,17 +1784,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
def depart_literal_block(self, node):
if self.verbatim:
- self.body.append('\n\\end{verbatim}\\end{quote}\n')
+ self.body.append(self.literal_block_env('end'))
self.verbatim = 0
else:
- if self.active_table.is_open():
- self.body.append('\n}\n')
- else:
- self.body.append('\n')
- self.body.append('}\\end{quote}\n')
+ self.body.append('\n}')
self.insert_none_breaking_blanks = 0
self.literal_block = 0
# obey end: self.body.append('}\n')
+ self.body.append(self.context.pop())
def visit_meta(self, node):
self.body.append('[visit_meta]\n')
@@ -1775,9 +1833,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('] ')
def visit_option_list(self, node):
- # force new line after definition
- if isinstance(node.parent, nodes.definition):
- self.body.append('~\n')
self.body.append('\\begin{optionlist}{3cm}\n')
def depart_option_list(self, node):
@@ -1830,16 +1885,16 @@ class LaTeXTranslator(nodes.NodeVisitor):
# BUG: hash_char "#" is trouble some in LaTeX.
# mbox and other environment do not like the '#'.
hash_char = '\\#'
- if node.has_key('refuri'):
+ if 'refuri' in node:
href = node['refuri'].replace('#',hash_char)
- elif node.has_key('refid'):
+ elif 'refid' in node:
href = hash_char + node['refid']
- elif node.has_key('refname'):
+ elif 'refname' in node:
href = hash_char + self.document.nameids[node['refname']]
else:
raise AssertionError('Unknown reference.')
- self.body.append('\\href{%s}{' % href)
- if self._reference_label and not node.has_key('refuri'):
+ self.body.append('\\href{%s}{' % href.replace("%", "\\%"))
+ if self._reference_label and 'refuri' not in node:
self.body.append('\\%s{%s}}' % (self._reference_label,
href.replace(hash_char, '')))
raise nodes.SkipNode
@@ -1935,8 +1990,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_table(self, node):
if self.active_table.is_open():
- print 'nested tables are not supported'
- raise AssertionError
+ self.table_stack.append(self.active_table)
+ # nesting longtable does not work (e.g. 2007-04-18)
+ self.active_table = Table('tabular',self.settings.table_style)
self.active_table.open()
for cl in node['classes']:
self.active_table.set_table_style(cl)
@@ -1945,12 +2001,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
def depart_table(self, node):
self.body.append(self.active_table.get_closing() + '\n')
self.active_table.close()
- self.active_table.set_table_style(self.settings.table_style)
+ if len(self.table_stack)>0:
+ self.active_table = self.table_stack.pop()
+ else:
+ self.active_table.set_table_style(self.settings.table_style)
def visit_target(self, node):
# BUG: why not (refuri or refid or refname) means not footnote ?
- if not (node.has_key('refuri') or node.has_key('refid')
- or node.has_key('refname')):
+ if not ('refuri' in node or 'refid' in node
+ or 'refname' in node):
for id in node['ids']:
self.body.append('\\hypertarget{%s}{' % id)
self.context.append('}' * len(node['ids']))
@@ -1978,7 +2037,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def depart_term(self, node):
# definition list term.
- self.body.append('}] ')
+ # \leavevmode results in a line break if the term is followed by a item list.
+ self.body.append('}] \leavevmode ')
def visit_tgroup(self, node):
#self.body.append(self.starttag(node, 'colgroup'))
@@ -2038,7 +2098,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
(l, text, id))
def visit_title(self, node):
- """Only 3 section levels are supported by LaTeX article (AFAIR)."""
+ """Section and other titles."""
if isinstance(node.parent, nodes.topic):
# the table of contents.
@@ -2085,7 +2145,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
section_name = self.d_class.section(self.section_level)
self.body.append('\\%s%s{' % (section_name, section_star))
-
+ # MAYBE postfix paragraph and subparagraph with \leavemode to
+ # ensure floatables stay in the section and text starts on a new line.
self.context.append('}\n')
def depart_title(self, node):
diff --git a/docutils/writers/newlatex2e/__init__.py b/docutils/writers/newlatex2e/__init__.py
index 08058cb2d..2830fd556 100644
--- a/docutils/writers/newlatex2e/__init__.py
+++ b/docutils/writers/newlatex2e/__init__.py
@@ -1,5 +1,5 @@
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
@@ -676,7 +676,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
# Move IDs into TextElements. This won't work for images.
# Need to review this.
for node in document.traverse(nodes.Element):
- if node.has_key('ids') and not isinstance(node,
+ if 'ids' in node and not isinstance(node,
nodes.TextElement):
next_text_element = node.next_node(nodes.TextElement)
if next_text_element:
diff --git a/docutils/writers/newlatex2e/unicode_map.py b/docutils/writers/newlatex2e/unicode_map.py
index f5b019dcc..c0d63b6fe 100644
--- a/docutils/writers/newlatex2e/unicode_map.py
+++ b/docutils/writers/newlatex2e/unicode_map.py
@@ -1,5 +1,5 @@
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This file has been placed in the public domain.
# This is a mapping of Unicode characters to LaTeX equivalents.
diff --git a/docutils/writers/s5_html/__init__.py b/docutils/writers/s5_html/__init__.py
index 486c03f4a..73a1ec66f 100644
--- a/docutils/writers/s5_html/__init__.py
+++ b/docutils/writers/s5_html/__init__.py
@@ -251,7 +251,7 @@ class S5HTMLTranslator(html4css1.HTMLTranslator):
"""
source = os.path.join(source_dir, name)
dest = os.path.join(dest_dir, name)
- if self.theme_files_copied.has_key(dest):
+ if dest in self.theme_files_copied:
return 1
else:
self.theme_files_copied[dest] = 1
diff --git a/extras/optparse.py b/extras/optparse.py
index c21663c55..dcc36fd84 100644
--- a/extras/optparse.py
+++ b/extras/optparse.py
@@ -472,7 +472,7 @@ class Option:
def _set_attrs (self, attrs):
for attr in self.ATTRS:
- if attrs.has_key(attr):
+ if attr in attrs:
setattr(self, attr, attrs[attr])
del attrs[attr]
else:
@@ -676,7 +676,7 @@ class Values:
are silently ignored.
"""
for attr in dir(self):
- if dict.has_key(attr):
+ if attr in dict:
dval = dict[attr]
if dval is not None:
setattr(self, attr, dval)
@@ -704,7 +704,7 @@ class Values:
def read_file (self, filename, mode="careful"):
vars = {}
- execfile(filename, vars)
+ exec(open(filename).read(), vars)
self._update(vars, mode)
def ensure_value (self, attr, value):
@@ -786,10 +786,10 @@ class OptionContainer:
def _check_conflict (self, option):
conflict_opts = []
for opt in option._short_opts:
- if self._short_opt.has_key(opt):
+ if opt in self._short_opt:
conflict_opts.append((opt, self._short_opt[opt]))
for opt in option._long_opts:
- if self._long_opt.has_key(opt):
+ if opt in self._long_opt:
conflict_opts.append((opt, self._long_opt[opt]))
if conflict_opts:
@@ -837,7 +837,7 @@ class OptionContainer:
if option.dest is not None: # option has a dest, we need a default
if option.default is not NO_DEFAULT:
self.defaults[option.dest] = option.default
- elif not self.defaults.has_key(option.dest):
+ elif option.dest not in self.defaults:
self.defaults[option.dest] = None
return option
@@ -853,8 +853,8 @@ class OptionContainer:
self._long_opt.get(opt_str))
def has_option (self, opt_str):
- return (self._short_opt.has_key(opt_str) or
- self._long_opt.has_key(opt_str))
+ return (opt_str in self._short_opt or
+ opt_str in self._long_opt)
def remove_option (self, opt_str):
option = self._short_opt.get(opt_str)
@@ -1393,7 +1393,7 @@ def _match_abbrev (s, wordmap):
'words', raise BadOptionError.
"""
# Is there an exact match?
- if wordmap.has_key(s):
+ if s in wordmap:
return s
else:
# Isolate all words with s as a prefix.
diff --git a/extras/roman.py b/extras/roman.py
index ebe088308..0335f29f8 100644
--- a/extras/roman.py
+++ b/extras/roman.py
@@ -41,7 +41,7 @@ def toRoman(n):
"""convert integer to Roman numeral"""
if not (0 < n < 5000):
raise OutOfRangeError, "number out of range (must be 1..4999)"
- if int(n) <> n:
+ if int(n) != n:
raise NotIntegerError, "decimals can not be converted"
result = ""
diff --git a/setup.py b/setup.py
index ab4b23d5b..4373789c9 100755
--- a/setup.py
+++ b/setup.py
@@ -72,7 +72,7 @@ into useful formats, such as HTML, XML, and LaTeX. For
input Docutils supports reStructuredText, an easy-to-read,
what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
'url': 'http://docutils.sourceforge.net/',
- 'version': '0.5',
+ 'version': '0.6',
'author': 'David Goodger',
'author_email': 'goodger@python.org',
'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
index 24858c624..ce67ab262 100644
--- a/test/DocutilsTestSupport.py
+++ b/test/DocutilsTestSupport.py
@@ -668,7 +668,7 @@ class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec):
writer_name = '' # set in subclasses or constructor
def __init__(self, *args, **kwargs):
- if kwargs.has_key('writer_name'):
+ if 'writer_name' in kwargs:
self.writer_name = kwargs['writer_name']
del kwargs['writer_name']
CustomTestCase.__init__(self, *args, **kwargs)
diff --git a/test/coverage.sh b/test/coverage.sh
index 23e0adfdf..1717cb535 100755
--- a/test/coverage.sh
+++ b/test/coverage.sh
@@ -1,9 +1,11 @@
#!/bin/bash
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This script has been placed in the public domain.
+# Usage: ./coverage.sh [project, [module]]
+
set -e
# Resolve all symlinks in current path.
cd -P .
@@ -15,7 +17,9 @@ fi
if test "$1"; then
proj="$1"
fi
-echo "Performing code coverage test for project \"$proj\"..."
+module="${2:-alltests.py}"
+module="${module#test/}"
+echo "Performing code coverage test for project \"$proj\", test module \"$module\"..."
echo
echo "Please be patient; coverage tracking slows test execution down by more"
echo "than factor 10."
@@ -23,7 +27,7 @@ echo
cd test
rm -rf cover
mkdir -p cover
-python -u -m trace --count --coverdir=cover --missing alltests.py
+python -u -m trace --count --coverdir=cover --missing "$module"
cd ..
echo
echo
@@ -31,7 +35,7 @@ echo Uncovered lines
echo ===============
echo
(
- find "$proj" -name \*.py | while read i; do
+ find "$proj/" -name \*.py | while read i; do
i="${i%.py}"
test -f test/cover/"${i//\//.}".cover -o "${i##*/}" == Template || echo "${i//\//.}" "`cat "$i.py" | wc -l`"
done
diff --git a/test/docutils_difflib.py b/test/docutils_difflib.py
index a41d4d5ba..cc84c485a 100644
--- a/test/docutils_difflib.py
+++ b/test/docutils_difflib.py
@@ -163,8 +163,6 @@ class SequenceMatcher:
# b2j
# for x in b, b2j[x] is a list of the indices (into b)
# at which x appears; junk elements do not appear
- # b2jhas
- # b2j.has_key
# fullbcount
# for x in b, fullbcount[x] == the number of times x
# appears in b; only materialized if really needed (used
@@ -188,7 +186,7 @@ class SequenceMatcher:
# DON'T USE! Only __chain_b uses this. Use isbjunk.
# isbjunk
# for x in b, isbjunk(x) == isjunk(x) but much faster;
- # it's really the has_key method of a hidden dict.
+ # it's really the in operator of a hidden dict.
# DOES NOT WORK for x in a!
self.isjunk = isjunk
@@ -285,10 +283,9 @@ class SequenceMatcher:
# from the start.
b = self.b
self.b2j = b2j = {}
- self.b2jhas = b2jhas = b2j.has_key
for i in xrange(len(b)):
elt = b[i]
- if b2jhas(elt):
+ if elt in b2j:
b2j[elt].append(i)
else:
b2j[elt] = [i]
@@ -304,12 +301,12 @@ class SequenceMatcher:
junkdict[elt] = 1 # value irrelevant; it's a set
del b2j[elt]
- # Now for x in b, isjunk(x) == junkdict.has_key(x), but the
+ # Now for x in b, isjunk(x) == x in junkdict, but the
# latter is much faster. Note too that while there may be a
# lot of junk in the sequence, the number of *unique* junk
# elements is probably small. So the memory burden of keeping
# this dict alive is likely trivial compared to the size of b2j.
- self.isbjunk = junkdict.has_key
+ self.isbjunk = lambda elt: elt in junkdict
def find_longest_match(self, alo, ahi, blo, bhi):
"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
@@ -528,8 +525,9 @@ class SequenceMatcher:
1.0
"""
- matches = reduce(lambda sum, triple: sum + triple[-1],
- self.get_matching_blocks(), 0)
+ matches = 0
+ for triple in self.get_matching_blocks():
+ matches += triple[-1]
return 2.0 * matches / (len(self.a) + len(self.b))
def quick_ratio(self):
@@ -550,9 +548,9 @@ class SequenceMatcher:
# avail[x] is the number of times x appears in 'b' less the
# number of times we've seen it in 'a' so far ... kinda
avail = {}
- availhas, matches = avail.has_key, 0
+ matches = 0
for elt in self.a:
- if availhas(elt):
+ if elt in avail:
numb = avail[elt]
else:
numb = fullbcount.get(elt, 0)
@@ -603,9 +601,9 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
"""
if not n > 0:
- raise ValueError("n must be > 0: " + `n`)
+ raise ValueError("n must be > 0: " + repr(n))
if not 0.0 <= cutoff <= 1.0:
- raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`)
+ raise ValueError("cutoff must be in [0.0, 1.0]: " + repr(cutoff))
result = []
s = SequenceMatcher()
s.set_seq2(word)
@@ -791,7 +789,7 @@ class Differ:
elif tag == 'equal':
self._dump(' ', a, alo, ahi)
else:
- raise ValueError, 'unknown tag ' + `tag`
+ raise ValueError, 'unknown tag ' + repr(tag)
results = self.results
self.results = []
return results
@@ -907,7 +905,7 @@ class Differ:
atags += ' ' * la
btags += ' ' * lb
else:
- raise ValueError, 'unknown tag ' + `tag`
+ raise ValueError, 'unknown tag ' + repr(tag)
self._qformat(aelt, belt, atags, btags)
else:
# the synch pair is identical
diff --git a/test/functional/expected/compact_lists.html b/test/functional/expected/compact_lists.html
index 60f1e059e..f3a3c1f3e 100644
--- a/test/functional/expected/compact_lists.html
+++ b/test/functional/expected/compact_lists.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title></title>
<link rel="stylesheet" href="../../../docutils/writers/html4css1/html4css1.css" type="text/css" />
</head>
diff --git a/test/functional/expected/dangerous.html b/test/functional/expected/dangerous.html
index a44ae2b71..d0661d72d 100644
--- a/test/functional/expected/dangerous.html
+++ b/test/functional/expected/dangerous.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title></title>
<link rel="stylesheet" href="../../../docutils/writers/html4css1/html4css1.css" type="text/css" />
</head>
diff --git a/test/functional/expected/field_name_limit.html b/test/functional/expected/field_name_limit.html
index acc2eec9c..87d25ce24 100644
--- a/test/functional/expected/field_name_limit.html
+++ b/test/functional/expected/field_name_limit.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title></title>
<link rel="stylesheet" href="../../../docutils/writers/html4css1/html4css1.css" type="text/css" />
</head>
diff --git a/test/functional/expected/latex_docinfo.tex b/test/functional/expected/latex_docinfo.tex
index 04d9438f7..a093c7965 100644
--- a/test/functional/expected/latex_docinfo.tex
+++ b/test/functional/expected/latex_docinfo.tex
@@ -12,9 +12,8 @@
\usepackage{color}
\usepackage{multirow}
\usepackage{ifthen}
-\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage[DIV12]{typearea}
-%% generator Docutils: http://docutils.sourceforge.net/
+% generated by Docutils <http://docutils.sourceforge.net/>
\newlength{\admonitionwidth}
\setlength{\admonitionwidth}{0.9\textwidth}
\newlength{\docinfowidth}
@@ -55,6 +54,9 @@
\newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}}
\newcommand{\titlereference}[1]{\textsl{#1}}
% end of "some commands"
+\ifthenelse{\isundefined{\hypersetup}}{
+\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+}{}
\title{}
\author{Foo Fred~\\
Food Foomatics {\&} Friends~\\
@@ -73,7 +75,6 @@ pdfauthor={Foo Fred;Bar Barney}
\raggedbottom
\begin{document}
\maketitle
-
%___________________________________________________________________________
\begin{center}
\begin{tabularx}{\docinfowidth}{lX}
diff --git a/test/functional/expected/misc_rst_html4css1.html b/test/functional/expected/misc_rst_html4css1.html
index 6b55bbd1b..754f4c3e3 100644
--- a/test/functional/expected/misc_rst_html4css1.html
+++ b/test/functional/expected/misc_rst_html4css1.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title></title>
<link rel="stylesheet" href="foo&amp;bar.css" type="text/css" />
</head>
diff --git a/test/functional/expected/pep_html.html b/test/functional/expected/pep_html.html
index 408903cc4..eb1f6b37b 100644
--- a/test/functional/expected/pep_html.html
+++ b/test/functional/expected/pep_html.html
@@ -8,7 +8,7 @@ to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+ <meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title>PEP 100 -- Test PEP</title>
<link rel="stylesheet" href="../../../docutils/writers/pep_html/pep.css" type="text/css" />
</head>
@@ -35,17 +35,17 @@ to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!
</tr>
<tr class="field"><th class="field-name">Version:</th><td class="field-body">42</td>
</tr>
-<tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference" href="http://svn.python.org/view/*checkout*/peps/trunk/pep-0100.txt">A long time ago.</a></td>
+<tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference external" href="http://svn.python.org/view/*checkout*/peps/trunk/pep-0100.txt">A long time ago.</a></td>
</tr>
<tr class="field"><th class="field-name">Author:</th><td class="field-body">John Doe &lt;john&#32;&#97;t&#32;example.org&gt;</td>
</tr>
-<tr class="field"><th class="field-name">Discussions-To:</th><td class="field-body">&lt;<a class="reference" href="mailto:devnull&#37;&#52;&#48;example&#46;org?subject=PEP%20100">devnull&#32;&#97;t&#32;example.org</a>&gt;</td>
+<tr class="field"><th class="field-name">Discussions-To:</th><td class="field-body">&lt;<a class="reference external" href="mailto:devnull&#37;&#52;&#48;example&#46;org?subject=PEP%20100">devnull&#32;&#97;t&#32;example.org</a>&gt;</td>
</tr>
<tr class="field"><th class="field-name">Status:</th><td class="field-body">Draft</td>
</tr>
<tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards Track</td>
</tr>
-<tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference" href="http://www.python.org/dev/peps/pep-0012">text/x-rst</a></td>
+<tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference external" href="http://www.python.org/dev/peps/pep-0012">text/x-rst</a></td>
</tr>
<tr class="field"><th class="field-name">Created:</th><td class="field-body">01-Jun-2001</td>
</tr>
@@ -57,14 +57,14 @@ to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
-<li><a class="reference" href="#abstract" id="id5">Abstract</a></li>
-<li><a class="reference" href="#copyright" id="id6">Copyright</a></li>
-<li><a class="reference" href="#references-and-footnotes" id="id7">References and Footnotes</a></li>
+<li><a class="reference internal" href="#abstract" id="id5">Abstract</a></li>
+<li><a class="reference internal" href="#copyright" id="id6">Copyright</a></li>
+<li><a class="reference internal" href="#references-and-footnotes" id="id7">References and Footnotes</a></li>
</ul>
</div>
<div class="section" id="abstract">
<h1><a class="toc-backref" href="#id5">Abstract</a></h1>
-<p>This is just a test <a class="footnote-reference" href="#id2" id="id1">[1]</a>. See the <a class="reference" href="http://www.python.org/peps/">PEP repository</a> <a class="footnote-reference" href="#id3" id="id4">[2]</a> for the real
+<p>This is just a test <a class="footnote-reference" href="#id2" id="id1">[1]</a>. See the <a class="reference external" href="http://www.python.org/peps/">PEP repository</a> <a class="footnote-reference" href="#id3" id="id4">[2]</a> for the real
thing.</p>
</div>
<div class="section" id="copyright">
@@ -76,13 +76,13 @@ thing.</p>
<table class="docutils footnote" frame="void" id="id2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>PEP editors: <a class="reference" href="mailto:peps&#37;&#52;&#48;python&#46;org">peps<span>&#64;</span>python<span>&#46;</span>org</a></td></tr>
+<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>PEP editors: <a class="reference external" href="mailto:peps&#37;&#52;&#48;python&#46;org">peps<span>&#64;</span>python<span>&#46;</span>org</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id3" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label"><a class="fn-backref" href="#id4">[2]</a></td><td><a class="reference" href="http://www.python.org/peps/">http://www.python.org/peps/</a></td></tr>
+<tr><td class="label"><a class="fn-backref" href="#id4">[2]</a></td><td><a class="reference external" href="http://www.python.org/peps/">http://www.python.org/peps/</a></td></tr>
</tbody>
</table>
</div>
diff --git a/test/functional/expected/standalone_rst_html4css1.html b/test/functional/expected/standalone_rst_html4css1.html
index dc0dc6f3f..f98d31e5a 100644
--- a/test/functional/expected/standalone_rst_html4css1.html
+++ b/test/functional/expected/standalone_rst_html4css1.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title>reStructuredText Test Document</title>
<meta name="author" content="David Goodger" />
<meta name="authors" content="Me Myself I" />
@@ -37,7 +37,7 @@ A1B 2C3
</pre>
</td></tr>
<tr><th class="docinfo-name">Contact:</th>
-<td><a class="first last reference" href="mailto:goodger&#64;python.org">goodger&#64;python.org</a></td></tr>
+<td><a class="first last reference external" href="mailto:goodger&#64;python.org">goodger&#64;python.org</a></td></tr>
<tr><th class="docinfo-name">Authors:</th>
<td>Me
<br />Myself
@@ -85,70 +85,70 @@ They are transformed from section titles after parsing. -->
<div class="contents topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="auto-toc simple">
-<li><a class="reference" href="#structural-elements" id="id32">1&nbsp;&nbsp;&nbsp;Structural Elements</a><ul class="auto-toc">
-<li><a class="reference" href="#section-title" id="id33">1.1&nbsp;&nbsp;&nbsp;Section Title</a></li>
-<li><a class="reference" href="#empty-section" id="id34">1.2&nbsp;&nbsp;&nbsp;Empty Section</a></li>
-<li><a class="reference" href="#transitions" id="id35">1.3&nbsp;&nbsp;&nbsp;Transitions</a></li>
+<li><a class="reference internal" href="#structural-elements" id="id33">1&nbsp;&nbsp;&nbsp;Structural Elements</a><ul class="auto-toc">
+<li><a class="reference internal" href="#section-title" id="id34">1.1&nbsp;&nbsp;&nbsp;Section Title</a></li>
+<li><a class="reference internal" href="#empty-section" id="id35">1.2&nbsp;&nbsp;&nbsp;Empty Section</a></li>
+<li><a class="reference internal" href="#transitions" id="id36">1.3&nbsp;&nbsp;&nbsp;Transitions</a></li>
</ul>
</li>
-<li><a class="reference" href="#body-elements" id="id36">2&nbsp;&nbsp;&nbsp;Body Elements</a><ul class="auto-toc">
-<li><a class="reference" href="#paragraphs" id="id37">2.1&nbsp;&nbsp;&nbsp;Paragraphs</a><ul class="auto-toc">
-<li><a class="reference" href="#inline-markup" id="id38">2.1.1&nbsp;&nbsp;&nbsp;Inline Markup</a></li>
+<li><a class="reference internal" href="#body-elements" id="id37">2&nbsp;&nbsp;&nbsp;Body Elements</a><ul class="auto-toc">
+<li><a class="reference internal" href="#paragraphs" id="id38">2.1&nbsp;&nbsp;&nbsp;Paragraphs</a><ul class="auto-toc">
+<li><a class="reference internal" href="#inline-markup" id="id39">2.1.1&nbsp;&nbsp;&nbsp;Inline Markup</a></li>
</ul>
</li>
-<li><a class="reference" href="#bullet-lists" id="id39">2.2&nbsp;&nbsp;&nbsp;Bullet Lists</a></li>
-<li><a class="reference" href="#enumerated-lists" id="id40">2.3&nbsp;&nbsp;&nbsp;Enumerated Lists</a></li>
-<li><a class="reference" href="#definition-lists" id="id41">2.4&nbsp;&nbsp;&nbsp;Definition Lists</a></li>
-<li><a class="reference" href="#field-lists" id="id42">2.5&nbsp;&nbsp;&nbsp;Field Lists</a></li>
-<li><a class="reference" href="#option-lists" id="id43">2.6&nbsp;&nbsp;&nbsp;Option Lists</a></li>
-<li><a class="reference" href="#literal-blocks" id="id44">2.7&nbsp;&nbsp;&nbsp;Literal Blocks</a></li>
-<li><a class="reference" href="#line-blocks" id="id45">2.8&nbsp;&nbsp;&nbsp;Line Blocks</a></li>
-<li><a class="reference" href="#block-quotes" id="id46">2.9&nbsp;&nbsp;&nbsp;Block Quotes</a></li>
-<li><a class="reference" href="#doctest-blocks" id="id47">2.10&nbsp;&nbsp;&nbsp;Doctest Blocks</a></li>
-<li><a class="reference" href="#footnotes" id="id48">2.11&nbsp;&nbsp;&nbsp;Footnotes</a></li>
-<li><a class="reference" href="#citations" id="id49">2.12&nbsp;&nbsp;&nbsp;Citations</a></li>
-<li><a class="reference" href="#targets" id="id50">2.13&nbsp;&nbsp;&nbsp;Targets</a><ul class="auto-toc">
-<li><a class="reference" href="#duplicate-target-names" id="id51">2.13.1&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></li>
-<li><a class="reference" href="#id20" id="id52">2.13.2&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></li>
+<li><a class="reference internal" href="#bullet-lists" id="id40">2.2&nbsp;&nbsp;&nbsp;Bullet Lists</a></li>
+<li><a class="reference internal" href="#enumerated-lists" id="id41">2.3&nbsp;&nbsp;&nbsp;Enumerated Lists</a></li>
+<li><a class="reference internal" href="#definition-lists" id="id42">2.4&nbsp;&nbsp;&nbsp;Definition Lists</a></li>
+<li><a class="reference internal" href="#field-lists" id="id43">2.5&nbsp;&nbsp;&nbsp;Field Lists</a></li>
+<li><a class="reference internal" href="#option-lists" id="id44">2.6&nbsp;&nbsp;&nbsp;Option Lists</a></li>
+<li><a class="reference internal" href="#literal-blocks" id="id45">2.7&nbsp;&nbsp;&nbsp;Literal Blocks</a></li>
+<li><a class="reference internal" href="#line-blocks" id="id46">2.8&nbsp;&nbsp;&nbsp;Line Blocks</a></li>
+<li><a class="reference internal" href="#block-quotes" id="id47">2.9&nbsp;&nbsp;&nbsp;Block Quotes</a></li>
+<li><a class="reference internal" href="#doctest-blocks" id="id48">2.10&nbsp;&nbsp;&nbsp;Doctest Blocks</a></li>
+<li><a class="reference internal" href="#footnotes" id="id49">2.11&nbsp;&nbsp;&nbsp;Footnotes</a></li>
+<li><a class="reference internal" href="#citations" id="id50">2.12&nbsp;&nbsp;&nbsp;Citations</a></li>
+<li><a class="reference internal" href="#targets" id="id51">2.13&nbsp;&nbsp;&nbsp;Targets</a><ul class="auto-toc">
+<li><a class="reference internal" href="#duplicate-target-names" id="id52">2.13.1&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></li>
+<li><a class="reference internal" href="#id21" id="id53">2.13.2&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></li>
</ul>
</li>
-<li><a class="reference" href="#directives" id="id53">2.14&nbsp;&nbsp;&nbsp;Directives</a><ul class="auto-toc">
-<li><a class="reference" href="#document-parts" id="id54">2.14.1&nbsp;&nbsp;&nbsp;Document Parts</a></li>
-<li><a class="reference" href="#images" id="id55">2.14.2&nbsp;&nbsp;&nbsp;Images</a></li>
-<li><a class="reference" href="#admonitions" id="id56">2.14.3&nbsp;&nbsp;&nbsp;Admonitions</a></li>
-<li><a class="reference" href="#topics-sidebars-and-rubrics" id="id57">2.14.4&nbsp;&nbsp;&nbsp;Topics, Sidebars, and Rubrics</a></li>
-<li><a class="reference" href="#target-footnotes" id="id58">2.14.5&nbsp;&nbsp;&nbsp;Target Footnotes</a></li>
-<li><a class="reference" href="#replacement-text" id="id59">2.14.6&nbsp;&nbsp;&nbsp;Replacement Text</a></li>
-<li><a class="reference" href="#compound-paragraph" id="id60">2.14.7&nbsp;&nbsp;&nbsp;Compound Paragraph</a></li>
-<li><a class="reference" href="#parsed-literal-blocks" id="id61">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></li>
+<li><a class="reference internal" href="#directives" id="id54">2.14&nbsp;&nbsp;&nbsp;Directives</a><ul class="auto-toc">
+<li><a class="reference internal" href="#document-parts" id="id55">2.14.1&nbsp;&nbsp;&nbsp;Document Parts</a></li>
+<li><a class="reference internal" href="#images" id="id56">2.14.2&nbsp;&nbsp;&nbsp;Images</a></li>
+<li><a class="reference internal" href="#admonitions" id="id57">2.14.3&nbsp;&nbsp;&nbsp;Admonitions</a></li>
+<li><a class="reference internal" href="#topics-sidebars-and-rubrics" id="id58">2.14.4&nbsp;&nbsp;&nbsp;Topics, Sidebars, and Rubrics</a></li>
+<li><a class="reference internal" href="#target-footnotes" id="id59">2.14.5&nbsp;&nbsp;&nbsp;Target Footnotes</a></li>
+<li><a class="reference internal" href="#replacement-text" id="id60">2.14.6&nbsp;&nbsp;&nbsp;Replacement Text</a></li>
+<li><a class="reference internal" href="#compound-paragraph" id="id61">2.14.7&nbsp;&nbsp;&nbsp;Compound Paragraph</a></li>
+<li><a class="reference internal" href="#parsed-literal-blocks" id="id62">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></li>
</ul>
</li>
-<li><a class="reference" href="#substitution-definitions" id="id62">2.15&nbsp;&nbsp;&nbsp;Substitution Definitions</a></li>
-<li><a class="reference" href="#comments" id="id63">2.16&nbsp;&nbsp;&nbsp;Comments</a></li>
-<li><a class="reference" href="#raw-text" id="id64">2.17&nbsp;&nbsp;&nbsp;Raw text</a></li>
-<li><a class="reference" href="#container" id="id65">2.18&nbsp;&nbsp;&nbsp;Container</a></li>
-<li><a class="reference" href="#colspanning-tables" id="id66">2.19&nbsp;&nbsp;&nbsp;Colspanning tables</a></li>
-<li><a class="reference" href="#rowspanning-tables" id="id67">2.20&nbsp;&nbsp;&nbsp;Rowspanning tables</a></li>
-<li><a class="reference" href="#complex-tables" id="id68">2.21&nbsp;&nbsp;&nbsp;Complex tables</a></li>
-<li><a class="reference" href="#list-tables" id="id69">2.22&nbsp;&nbsp;&nbsp;List Tables</a></li>
-<li><a class="reference" href="#custom-roles" id="id70">2.23&nbsp;&nbsp;&nbsp;Custom Roles</a></li>
+<li><a class="reference internal" href="#substitution-definitions" id="id63">2.15&nbsp;&nbsp;&nbsp;Substitution Definitions</a></li>
+<li><a class="reference internal" href="#comments" id="id64">2.16&nbsp;&nbsp;&nbsp;Comments</a></li>
+<li><a class="reference internal" href="#raw-text" id="id65">2.17&nbsp;&nbsp;&nbsp;Raw text</a></li>
+<li><a class="reference internal" href="#container" id="id66">2.18&nbsp;&nbsp;&nbsp;Container</a></li>
+<li><a class="reference internal" href="#colspanning-tables" id="id67">2.19&nbsp;&nbsp;&nbsp;Colspanning tables</a></li>
+<li><a class="reference internal" href="#rowspanning-tables" id="id68">2.20&nbsp;&nbsp;&nbsp;Rowspanning tables</a></li>
+<li><a class="reference internal" href="#complex-tables" id="id69">2.21&nbsp;&nbsp;&nbsp;Complex tables</a></li>
+<li><a class="reference internal" href="#list-tables" id="id70">2.22&nbsp;&nbsp;&nbsp;List Tables</a></li>
+<li><a class="reference internal" href="#custom-roles" id="id71">2.23&nbsp;&nbsp;&nbsp;Custom Roles</a></li>
</ul>
</li>
-<li><a class="reference" href="#error-handling" id="id71">3&nbsp;&nbsp;&nbsp;Error Handling</a></li>
+<li><a class="reference internal" href="#error-handling" id="id72">3&nbsp;&nbsp;&nbsp;Error Handling</a></li>
</ul>
</div>
<div class="section" id="structural-elements">
-<h1><a class="toc-backref" href="#id32">1&nbsp;&nbsp;&nbsp;Structural Elements</a></h1>
+<h1><a class="toc-backref" href="#id33">1&nbsp;&nbsp;&nbsp;Structural Elements</a></h1>
<div class="section" id="section-title">
-<h2 class="with-subtitle"><a class="toc-backref" href="#id33">1.1&nbsp;&nbsp;&nbsp;Section Title</a></h2>
+<h2 class="with-subtitle"><a class="toc-backref" href="#id34">1.1&nbsp;&nbsp;&nbsp;Section Title</a></h2>
<h2 class="section-subtitle" id="section-subtitle"><span class="section-subtitle">Section Subtitle</span></h2>
<p>That's it, the text just above this line.</p>
</div>
<div class="section" id="empty-section">
-<h2><a class="toc-backref" href="#id34">1.2&nbsp;&nbsp;&nbsp;Empty Section</a></h2>
+<h2><a class="toc-backref" href="#id35">1.2&nbsp;&nbsp;&nbsp;Empty Section</a></h2>
</div>
<div class="section" id="transitions">
-<h2><a class="toc-backref" href="#id35">1.3&nbsp;&nbsp;&nbsp;Transitions</a></h2>
+<h2><a class="toc-backref" href="#id36">1.3&nbsp;&nbsp;&nbsp;Transitions</a></h2>
<p>Here's a transition:</p>
<hr class="docutils" />
<p>It divides the section. Transitions may also occur between sections:</p>
@@ -156,28 +156,28 @@ They are transformed from section titles after parsing. -->
</div>
<hr class="docutils" />
<div class="section" id="body-elements">
-<h1><a class="toc-backref" href="#id36">2&nbsp;&nbsp;&nbsp;Body Elements</a></h1>
+<h1><a class="toc-backref" href="#id37">2&nbsp;&nbsp;&nbsp;Body Elements</a></h1>
<div class="section" id="paragraphs">
-<h2><a class="toc-backref" href="#id37">2.1&nbsp;&nbsp;&nbsp;Paragraphs</a></h2>
+<h2><a class="toc-backref" href="#id38">2.1&nbsp;&nbsp;&nbsp;Paragraphs</a></h2>
<p>A paragraph.</p>
<div class="section" id="inline-markup">
-<h3><a class="toc-backref" href="#id38">2.1.1&nbsp;&nbsp;&nbsp;Inline Markup</a></h3>
+<h3><a class="toc-backref" href="#id39">2.1.1&nbsp;&nbsp;&nbsp;Inline Markup</a></h3>
<p>Paragraphs contain text and may contain inline markup: <em>emphasis</em>,
<strong>strong emphasis</strong>, <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literals</span></tt>, standalone hyperlinks
-(<a class="reference" href="http://www.python.org">http://www.python.org</a>), external hyperlinks (<a class="reference" href="http://www.python.org/">Python</a> <a class="footnote-reference" href="#id25" id="id26">[5]</a>), internal
-cross-references (<a class="reference" href="#example">example</a>), external hyperlinks with embedded URIs
-(<a class="reference" href="http://www.python.org">Python web site</a>), <a class="reference" href="http://www.python.org/">anonymous hyperlink
-references</a> <a class="footnote-reference" href="#id25" id="id29">[5]</a> (<a class="reference" href="http://docutils.sourceforge.net/">a second reference</a> <a class="footnote-reference" href="#id30" id="id31">[6]</a>), footnote references (manually
-numbered <a class="footnote-reference" href="#id8" id="id1">[1]</a>, anonymous auto-numbered <a class="footnote-reference" href="#id11" id="id2">[3]</a>, labeled auto-numbered
-<a class="footnote-reference" href="#label" id="id3">[2]</a>, or symbolic <a class="footnote-reference" href="#id12" id="id4">[*]</a>), citation references (<a class="citation-reference" href="#cit2002" id="id5">[CIT2002]</a>),
+(<a class="reference external" href="http://www.python.org">http://www.python.org</a>), external hyperlinks (<a class="reference external" href="http://www.python.org/">Python</a> <a class="footnote-reference" href="#id26" id="id27">[5]</a>), internal
+cross-references (<a class="reference internal" href="#example">example</a>), external hyperlinks with embedded URIs
+(<a class="reference external" href="http://www.python.org">Python web site</a>), <a class="reference external" href="http://www.python.org/">anonymous hyperlink
+references</a> <a class="footnote-reference" href="#id26" id="id30">[5]</a> (<a class="reference external" href="http://docutils.sourceforge.net/">a second reference</a> <a class="footnote-reference" href="#id31" id="id32">[6]</a>), footnote references (manually
+numbered <a class="footnote-reference" href="#id8" id="id1">[1]</a>, anonymous auto-numbered <a class="footnote-reference" href="#id12" id="id2">[3]</a>, labeled auto-numbered
+<a class="footnote-reference" href="#label" id="id3">[2]</a>, or symbolic <a class="footnote-reference" href="#id13" id="id4">[*]</a>), citation references (<a class="citation-reference" href="#cit2002" id="id5">[CIT2002]</a>),
substitution references (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" />), and <span class="target" id="inline-hyperlink-targets">inline hyperlink targets</span>
-(see <a class="reference" href="#id22">Targets</a> below for a reference back to here). Character-level
-inline markup is also possible (although exceedingly ugly!) in <em>re</em><tt class="docutils literal"><span class="pre">Structured</span></tt><em>Text</em>. Problems are indicated by <a href="#id23"><span class="problematic" id="id24">|problematic|</span></a> text
+(see <a class="reference internal" href="#id23">Targets</a> below for a reference back to here). Character-level
+inline markup is also possible (although exceedingly ugly!) in <em>re</em><tt class="docutils literal"><span class="pre">Structured</span></tt><em>Text</em>. Problems are indicated by <a href="#id24"><span class="problematic" id="id25">|problematic|</span></a> text
(generated by processing errors; this one is intentional). Here is a
-reference to the <a class="reference" href="#doctitle">doctitle</a> and the <a class="reference" href="#subtitle">subtitle</a>.</p>
+reference to the <a class="reference internal" href="#doctitle">doctitle</a> and the <a class="reference internal" href="#subtitle">subtitle</a>.</p>
<p>The default role for interpreted text is <cite>Title Reference</cite>. Here are
-some explicit interpreted text roles: a PEP reference (<a class="reference" href="http://www.python.org/dev/peps/pep-0287">PEP 287</a>); an
-RFC reference (<a class="reference" href="http://www.faqs.org/rfcs/rfc2822.html">RFC 2822</a>); a <sub>subscript</sub>; a <sup>superscript</sup>;
+some explicit interpreted text roles: a PEP reference (<a class="reference external" href="http://www.python.org/dev/peps/pep-0287">PEP 287</a>); an
+RFC reference (<a class="reference external" href="http://www.faqs.org/rfcs/rfc2822.html">RFC 2822</a>); a <sub>subscript</sub>; a <sup>superscript</sup>;
and explicit roles for <em>standard</em> <strong>inline</strong>
<tt class="docutils literal"><span class="pre">markup</span></tt>.</p>
<!-- DO NOT RE-WRAP THE FOLLOWING PARAGRAPH! -->
@@ -192,7 +192,7 @@ live link to PEP 258 here.</p>
</div>
</div>
<div class="section" id="bullet-lists">
-<h2><a class="toc-backref" href="#id39">2.2&nbsp;&nbsp;&nbsp;Bullet Lists</a></h2>
+<h2><a class="toc-backref" href="#id40">2.2&nbsp;&nbsp;&nbsp;Bullet Lists</a></h2>
<ul>
<li><p class="first">A bullet list</p>
<ul class="simple">
@@ -217,7 +217,7 @@ live link to PEP 258 here.</p>
</ul>
</div>
<div class="section" id="enumerated-lists">
-<h2><a class="toc-backref" href="#id40">2.3&nbsp;&nbsp;&nbsp;Enumerated Lists</a></h2>
+<h2><a class="toc-backref" href="#id41">2.3&nbsp;&nbsp;&nbsp;Enumerated Lists</a></h2>
<ol class="arabic">
<li><p class="first">Arabic numerals.</p>
<ol class="loweralpha simple">
@@ -250,7 +250,7 @@ live link to PEP 258 here.</p>
</ol>
</div>
<div class="section" id="definition-lists">
-<h2><a class="toc-backref" href="#id41">2.4&nbsp;&nbsp;&nbsp;Definition Lists</a></h2>
+<h2><a class="toc-backref" href="#id42">2.4&nbsp;&nbsp;&nbsp;Definition Lists</a></h2>
<dl class="docutils">
<dt>Term</dt>
<dd>Definition</dd>
@@ -265,7 +265,7 @@ live link to PEP 258 here.</p>
</dl>
</div>
<div class="section" id="field-lists">
-<h2><a class="toc-backref" href="#id42">2.5&nbsp;&nbsp;&nbsp;Field Lists</a></h2>
+<h2><a class="toc-backref" href="#id43">2.5&nbsp;&nbsp;&nbsp;Field Lists</a></h2>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@@ -289,7 +289,7 @@ doesn't get stripped away.)</p>
</table>
</div>
<div class="section" id="option-lists">
-<h2><a class="toc-backref" href="#id43">2.6&nbsp;&nbsp;&nbsp;Option Lists</a></h2>
+<h2><a class="toc-backref" href="#id44">2.6&nbsp;&nbsp;&nbsp;Option Lists</a></h2>
<p>For listing command-line options:</p>
<table class="docutils option-list" frame="void" rules="none">
<col class="option" />
@@ -335,7 +335,7 @@ regardless of where it starts.</p>
description.</p>
</div>
<div class="section" id="literal-blocks">
-<h2><a class="toc-backref" href="#id44">2.7&nbsp;&nbsp;&nbsp;Literal Blocks</a></h2>
+<h2><a class="toc-backref" href="#id45">2.7&nbsp;&nbsp;&nbsp;Literal Blocks</a></h2>
<p>Literal blocks are indicated with a double-colon (&quot;::&quot;) at the end of
the preceding paragraph (over there <tt class="docutils literal"><span class="pre">--&gt;</span></tt>). They can be indented:</p>
<pre class="literal-block">
@@ -352,7 +352,7 @@ if literal_block:
</pre>
</div>
<div class="section" id="line-blocks">
-<h2><a class="toc-backref" href="#id45">2.8&nbsp;&nbsp;&nbsp;Line Blocks</a></h2>
+<h2><a class="toc-backref" href="#id46">2.8&nbsp;&nbsp;&nbsp;Line Blocks</a></h2>
<p>This section tests line blocks. Line blocks are body elements which
consist of lines and other line blocks. Nested line blocks cause
indentation.</p>
@@ -411,7 +411,7 @@ the left edge of the text above it.</div>
</blockquote>
</div>
<div class="section" id="block-quotes">
-<h2><a class="toc-backref" href="#id46">2.9&nbsp;&nbsp;&nbsp;Block Quotes</a></h2>
+<h2><a class="toc-backref" href="#id47">2.9&nbsp;&nbsp;&nbsp;Block Quotes</a></h2>
<p>Block quotes consist of indented body elements:</p>
<blockquote>
<p>My theory by A. Elk. Brackets Miss, brackets. This theory goes
@@ -423,7 +423,7 @@ own it, and what it is too.</p>
</blockquote>
</div>
<div class="section" id="doctest-blocks">
-<h2><a class="toc-backref" href="#id47">2.10&nbsp;&nbsp;&nbsp;Doctest Blocks</a></h2>
+<h2><a class="toc-backref" href="#id48">2.10&nbsp;&nbsp;&nbsp;Doctest Blocks</a></h2>
<pre class="doctest-block">
&gt;&gt;&gt; print 'Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;'
Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;
@@ -432,11 +432,11 @@ Python-specific usage examples; begun with &quot;&gt;&gt;&gt;&quot;
</pre>
</div>
<div class="section" id="footnotes">
-<h2><a class="toc-backref" href="#id48">2.11&nbsp;&nbsp;&nbsp;Footnotes</a></h2>
+<h2><a class="toc-backref" href="#id49">2.11&nbsp;&nbsp;&nbsp;Footnotes</a></h2>
<table class="docutils footnote" frame="void" id="id8" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label">[1]</td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id9">2</a>, <a class="fn-backref" href="#id21">3</a>)</em> <p>A footnote contains body elements, consistently indented by at
+<tr><td class="label">[1]</td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id9">2</a>, <a class="fn-backref" href="#id22">3</a>)</em> <p>A footnote contains body elements, consistently indented by at
least 3 spaces.</p>
<p class="last">This is the footnote's second paragraph.</p>
</td></tr>
@@ -448,11 +448,10 @@ least 3 spaces.</p>
<tr><td class="label">[2]</td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id10">2</a>)</em> Footnotes may be numbered, either manually (as in <a class="footnote-reference" href="#id8" id="id9">[1]</a>) or
automatically using a &quot;#&quot;-prefixed label. This footnote has a
label so it can be referred to from multiple places, both as a
-footnote reference (<a class="footnote-reference" href="#label" id="id10">[2]</a>) and as a hyperlink reference
-(<a class="reference" href="#label">label</a>).</td></tr>
+footnote reference (<a class="footnote-reference" href="#label" id="id10">[2]</a>) and as a <a class="reference internal" href="#label">hyperlink reference</a>.</td></tr>
</tbody>
</table>
-<table class="docutils footnote" frame="void" id="id11" rules="none">
+<table class="docutils footnote" frame="void" id="id12" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[3]</a></td><td><p class="first">This footnote is numbered automatically and anonymously using a
@@ -462,92 +461,92 @@ label of &quot;#&quot; only.</p>
</td></tr>
</tbody>
</table>
-<table class="docutils footnote" frame="void" id="id12" rules="none">
+<table class="docutils footnote" frame="void" id="id13" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id4">[*]</a></td><td>Footnotes may also use symbols, specified with a &quot;*&quot; label.
-Here's a reference to the next footnote: <a class="footnote-reference" href="#id14" id="id13">[†]</a>.</td></tr>
+Here's a reference to the next footnote: <a class="footnote-reference" href="#id15" id="id14">[†]</a>.</td></tr>
</tbody>
</table>
-<table class="docutils footnote" frame="void" id="id14" rules="none">
+<table class="docutils footnote" frame="void" id="id15" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label"><a class="fn-backref" href="#id13">[†]</a></td><td>This footnote shows the next symbol in the sequence.</td></tr>
+<tr><td class="label"><a class="fn-backref" href="#id14">[†]</a></td><td>This footnote shows the next symbol in the sequence.</td></tr>
</tbody>
</table>
-<table class="docutils footnote" frame="void" id="id15" rules="none">
+<table class="docutils footnote" frame="void" id="id16" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[4]</td><td>Here's an unreferenced footnote, with a reference to a
-nonexistent footnote: <a href="#id80"><span class="problematic" id="id81"><span id="id16"></span>[5]_</span></a>.</td></tr>
+nonexistent footnote: <a href="#id81"><span class="problematic" id="id82"><span id="id17"></span>[5]_</span></a>.</td></tr>
</tbody>
</table>
</div>
<div class="section" id="citations">
-<h2><a class="toc-backref" href="#id49">2.12&nbsp;&nbsp;&nbsp;Citations</a></h2>
+<h2><a class="toc-backref" href="#id50">2.12&nbsp;&nbsp;&nbsp;Citations</a></h2>
<table class="docutils citation" frame="void" id="cit2002" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label">[CIT2002]</td><td><em>(<a class="fn-backref" href="#id5">1</a>, <a class="fn-backref" href="#id17">2</a>)</em> Citations are text-labeled footnotes. They may be
+<tr><td class="label">[CIT2002]</td><td><em>(<a class="fn-backref" href="#id5">1</a>, <a class="fn-backref" href="#id18">2</a>)</em> Citations are text-labeled footnotes. They may be
rendered separately and differently from footnotes.</td></tr>
</tbody>
</table>
-<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="id17">[CIT2002]</a>, and a <a href="#id82"><span class="problematic" id="id83"><span id="id18"></span>[nonexistent]_</span></a>
+<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="id18">[CIT2002]</a>, and a <a href="#id83"><span class="problematic" id="id84"><span id="id19"></span>[nonexistent]_</span></a>
citation.</p>
</div>
<div class="section" id="targets">
-<span id="another-target"></span><h2><a class="toc-backref" href="#id50">2.13&nbsp;&nbsp;&nbsp;Targets</a></h2>
+<span id="another-target"></span><h2><a class="toc-backref" href="#id51">2.13&nbsp;&nbsp;&nbsp;Targets</a></h2>
<p id="example">This paragraph is pointed to by the explicit &quot;example&quot; target. A
-reference can be found under <a class="reference" href="#inline-markup">Inline Markup</a>, above. <a class="reference" href="#inline-hyperlink-targets">Inline
+reference can be found under <a class="reference internal" href="#inline-markup">Inline Markup</a>, above. <a class="reference internal" href="#inline-hyperlink-targets">Inline
hyperlink targets</a> are also possible.</p>
<p>Section headers are implicit targets, referred to by name. See
-<a class="reference" href="#id22">Targets</a>, which is a subsection of <a class="reference" href="#body-elements">Body Elements</a>.</p>
+<a class="reference internal" href="#id23">Targets</a>, which is a subsection of <a class="reference internal" href="#body-elements">Body Elements</a>.</p>
<p>Explicit external targets are interpolated into references such as
-&quot;<a class="reference" href="http://www.python.org/">Python</a> <a class="footnote-reference" href="#id25" id="id27">[5]</a>&quot;.</p>
-<p>Targets may be indirect and anonymous. Thus <a class="reference" href="#id22">this phrase</a> may also
-refer to the <a class="reference" href="#id22">Targets</a> section.</p>
-<p>Here's a <a href="#id84"><span class="problematic" id="id85">`hyperlink reference without a target`_</span></a>, which generates an
+&quot;<a class="reference external" href="http://www.python.org/">Python</a> <a class="footnote-reference" href="#id26" id="id28">[5]</a>&quot;.</p>
+<p>Targets may be indirect and anonymous. Thus <a class="reference internal" href="#id23">this phrase</a> may also
+refer to the <a class="reference internal" href="#id23">Targets</a> section.</p>
+<p>Here's a <a href="#id85"><span class="problematic" id="id86">`hyperlink reference without a target`_</span></a>, which generates an
error.</p>
<div class="section" id="duplicate-target-names">
-<h3><a class="toc-backref" href="#id51">2.13.1&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></h3>
+<h3><a class="toc-backref" href="#id52">2.13.1&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></h3>
<p>Duplicate names in section headers or other implicit targets will
generate &quot;info&quot; (level-1) system messages. Duplicate names in
explicit targets will generate &quot;warning&quot; (level-2) system messages.</p>
</div>
-<div class="section" id="id20">
-<h3><a class="toc-backref" href="#id52">2.13.2&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></h3>
+<div class="section" id="id21">
+<h3><a class="toc-backref" href="#id53">2.13.2&nbsp;&nbsp;&nbsp;Duplicate Target Names</a></h3>
<p>Since there are two &quot;Duplicate Target Names&quot; section headers, we
cannot uniquely refer to either of them by name. If we try to (like
-this: <a href="#id86"><span class="problematic" id="id87">`Duplicate Target Names`_</span></a>), an error is generated.</p>
+this: <a href="#id87"><span class="problematic" id="id88">`Duplicate Target Names`_</span></a>), an error is generated.</p>
</div>
</div>
<div class="section" id="directives">
-<h2><a class="toc-backref" href="#id53">2.14&nbsp;&nbsp;&nbsp;Directives</a></h2>
+<h2><a class="toc-backref" href="#id54">2.14&nbsp;&nbsp;&nbsp;Directives</a></h2>
<div class="contents local topic" id="contents">
<ul class="auto-toc simple">
-<li><a class="reference" href="#document-parts" id="id72">2.14.1&nbsp;&nbsp;&nbsp;Document Parts</a></li>
-<li><a class="reference" href="#images" id="id73">2.14.2&nbsp;&nbsp;&nbsp;Images</a></li>
-<li><a class="reference" href="#admonitions" id="id74">2.14.3&nbsp;&nbsp;&nbsp;Admonitions</a></li>
-<li><a class="reference" href="#topics-sidebars-and-rubrics" id="id75">2.14.4&nbsp;&nbsp;&nbsp;Topics, Sidebars, and Rubrics</a></li>
-<li><a class="reference" href="#target-footnotes" id="id76">2.14.5&nbsp;&nbsp;&nbsp;Target Footnotes</a></li>
-<li><a class="reference" href="#replacement-text" id="id77">2.14.6&nbsp;&nbsp;&nbsp;Replacement Text</a></li>
-<li><a class="reference" href="#compound-paragraph" id="id78">2.14.7&nbsp;&nbsp;&nbsp;Compound Paragraph</a></li>
-<li><a class="reference" href="#parsed-literal-blocks" id="id79">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></li>
+<li><a class="reference internal" href="#document-parts" id="id73">2.14.1&nbsp;&nbsp;&nbsp;Document Parts</a></li>
+<li><a class="reference internal" href="#images" id="id74">2.14.2&nbsp;&nbsp;&nbsp;Images</a></li>
+<li><a class="reference internal" href="#admonitions" id="id75">2.14.3&nbsp;&nbsp;&nbsp;Admonitions</a></li>
+<li><a class="reference internal" href="#topics-sidebars-and-rubrics" id="id76">2.14.4&nbsp;&nbsp;&nbsp;Topics, Sidebars, and Rubrics</a></li>
+<li><a class="reference internal" href="#target-footnotes" id="id77">2.14.5&nbsp;&nbsp;&nbsp;Target Footnotes</a></li>
+<li><a class="reference internal" href="#replacement-text" id="id78">2.14.6&nbsp;&nbsp;&nbsp;Replacement Text</a></li>
+<li><a class="reference internal" href="#compound-paragraph" id="id79">2.14.7&nbsp;&nbsp;&nbsp;Compound Paragraph</a></li>
+<li><a class="reference internal" href="#parsed-literal-blocks" id="id80">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></li>
</ul>
</div>
<p>These are just a sample of the many reStructuredText Directives. For
others, please see
-<a class="reference" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html">http://docutils.sourceforge.net/docs/ref/rst/directives.html</a>.</p>
+<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html">http://docutils.sourceforge.net/docs/ref/rst/directives.html</a>.</p>
<div class="section" id="document-parts">
-<h3><a class="toc-backref" href="#id72">2.14.1&nbsp;&nbsp;&nbsp;Document Parts</a></h3>
+<h3><a class="toc-backref" href="#id73">2.14.1&nbsp;&nbsp;&nbsp;Document Parts</a></h3>
<p>An example of the &quot;contents&quot; directive can be seen above this section
-(a local, untitled table of <a class="reference" href="#contents">contents</a>) and at the beginning of the
-document (a document-wide <a class="reference" href="#table-of-contents">table of contents</a>).</p>
+(a local, untitled table of <a class="reference internal" href="#contents">contents</a>) and at the beginning of the
+document (a document-wide <a class="reference internal" href="#table-of-contents">table of contents</a>).</p>
</div>
<div class="section" id="images">
-<h3><a class="toc-backref" href="#id73">2.14.2&nbsp;&nbsp;&nbsp;Images</a></h3>
+<h3><a class="toc-backref" href="#id74">2.14.2&nbsp;&nbsp;&nbsp;Images</a></h3>
<p>An image directive (also clickable -- a hyperlink reference):</p>
-<a class="reference image-reference" href="#directives"><img alt="../../../docs/user/rst/images/title.png" class="class1 class2" src="../../../docs/user/rst/images/title.png" /></a>
+<a class="reference internal image-reference" href="#directives"><img alt="../../../docs/user/rst/images/title.png" class="class1 class2" src="../../../docs/user/rst/images/title.png" /></a>
<p>Image with multiple IDs:</p>
<span id="image-target-2"></span><span id="image-target-1"></span><img alt="../../../docs/user/rst/images/title.png" id="image-target-3" src="../../../docs/user/rst/images/title.png" />
<p>A centered image:</p>
@@ -619,7 +618,7 @@ This is the legend.</div>
<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="height: 3cm;" />
</div>
<div class="section" id="admonitions">
-<h3><a class="toc-backref" href="#id74">2.14.3&nbsp;&nbsp;&nbsp;Admonitions</a></h3>
+<h3><a class="toc-backref" href="#id75">2.14.3&nbsp;&nbsp;&nbsp;Admonitions</a></h3>
<div class="attention">
<p class="first admonition-title">Attention!</p>
<p class="last">Directives at large.</p>
@@ -668,7 +667,7 @@ Reader discretion is strongly advised.</p>
</div>
</div>
<div class="section" id="topics-sidebars-and-rubrics">
-<h3><a class="toc-backref" href="#id75">2.14.4&nbsp;&nbsp;&nbsp;Topics, Sidebars, and Rubrics</a></h3>
+<h3><a class="toc-backref" href="#id76">2.14.4&nbsp;&nbsp;&nbsp;Topics, Sidebars, and Rubrics</a></h3>
<div class="sidebar">
<p class="first sidebar-title">Sidebar Title</p>
<p class="sidebar-subtitle">Optional Subtitle</p>
@@ -685,26 +684,26 @@ background color.</p>
<p class="rubric">This is a rubric</p>
</div>
<div class="section" id="target-footnotes">
-<h3><a class="toc-backref" href="#id76">2.14.5&nbsp;&nbsp;&nbsp;Target Footnotes</a></h3>
-<table class="docutils footnote" frame="void" id="id25" rules="none">
+<h3><a class="toc-backref" href="#id77">2.14.5&nbsp;&nbsp;&nbsp;Target Footnotes</a></h3>
+<table class="docutils footnote" frame="void" id="id26" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label">[5]</td><td><em>(<a class="fn-backref" href="#id26">1</a>, <a class="fn-backref" href="#id27">2</a>, <a class="fn-backref" href="#id28">3</a>, <a class="fn-backref" href="#id29">4</a>)</em> <a class="reference" href="http://www.python.org/">http://www.python.org/</a></td></tr>
+<tr><td class="label">[5]</td><td><em>(<a class="fn-backref" href="#id27">1</a>, <a class="fn-backref" href="#id28">2</a>, <a class="fn-backref" href="#id29">3</a>, <a class="fn-backref" href="#id30">4</a>)</em> <a class="reference external" href="http://www.python.org/">http://www.python.org/</a></td></tr>
</tbody>
</table>
-<table class="docutils footnote" frame="void" id="id30" rules="none">
+<table class="docutils footnote" frame="void" id="id31" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
-<tr><td class="label"><a class="fn-backref" href="#id31">[6]</a></td><td><a class="reference" href="http://docutils.sourceforge.net/">http://docutils.sourceforge.net/</a></td></tr>
+<tr><td class="label"><a class="fn-backref" href="#id32">[6]</a></td><td><a class="reference external" href="http://docutils.sourceforge.net/">http://docutils.sourceforge.net/</a></td></tr>
</tbody>
</table>
</div>
<div class="section" id="replacement-text">
-<h3><a class="toc-backref" href="#id77">2.14.6&nbsp;&nbsp;&nbsp;Replacement Text</a></h3>
-<p>I recommend you try <a class="reference" href="http://www.python.org/">Python, <em>the</em> best language around</a> <a class="footnote-reference" href="#id25" id="id28">[5]</a>.</p>
+<h3><a class="toc-backref" href="#id78">2.14.6&nbsp;&nbsp;&nbsp;Replacement Text</a></h3>
+<p>I recommend you try <a class="reference external" href="http://www.python.org/">Python, <em>the</em> best language around</a> <a class="footnote-reference" href="#id26" id="id29">[5]</a>.</p>
</div>
<div class="section" id="compound-paragraph">
-<h3><a class="toc-backref" href="#id78">2.14.7&nbsp;&nbsp;&nbsp;Compound Paragraph</a></h3>
+<h3><a class="toc-backref" href="#id79">2.14.7&nbsp;&nbsp;&nbsp;Compound Paragraph</a></h3>
<div class="some-class compound">
<p class="compound-first">Compound 1, paragraph 1.</p>
<p class="compound-middle">Compound 1, paragraph 2.</p>
@@ -772,23 +771,23 @@ paragraph.</td>
</div>
</div>
<div class="section" id="parsed-literal-blocks">
-<h3><a class="toc-backref" href="#id79">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></h3>
+<h3><a class="toc-backref" href="#id80">2.14.8&nbsp;&nbsp;&nbsp;Parsed Literal Blocks</a></h3>
<pre class="literal-block">
This is a parsed literal block.
This line is indented. The next line is blank.
Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <tt class="docutils literal"><span class="pre">literal</span>
-<span class="pre">text</span></tt>, footnotes <a class="footnote-reference" href="#id8" id="id21">[1]</a>, <span class="target" id="id22">targets</span>, and <a class="reference" href="http://www.python.org/">references</a>.
+<span class="pre">text</span></tt>, footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="id23">targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.
</pre>
</div>
</div>
<div class="section" id="substitution-definitions">
-<h2><a class="toc-backref" href="#id62">2.15&nbsp;&nbsp;&nbsp;Substitution Definitions</a></h2>
+<h2><a class="toc-backref" href="#id63">2.15&nbsp;&nbsp;&nbsp;Substitution Definitions</a></h2>
<p>An inline image (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" />) example:</p>
<p>(Substitution definitions are not visible in the HTML source.)</p>
</div>
<div class="section" id="comments">
-<h2><a class="toc-backref" href="#id63">2.16&nbsp;&nbsp;&nbsp;Comments</a></h2>
+<h2><a class="toc-backref" href="#id64">2.16&nbsp;&nbsp;&nbsp;Comments</a></h2>
<p>Here's one:</p>
<!-- Comments begin with two dots and a space. Anything may
follow, except for the syntax of footnotes, hyperlink
@@ -800,20 +799,20 @@ Comments may contain non-ASCII characters: ä ö ü æ ø å -->
<p>(View the HTML source to see the comment.)</p>
</div>
<div class="section" id="raw-text">
-<h2><a class="toc-backref" href="#id64">2.17&nbsp;&nbsp;&nbsp;Raw text</a></h2>
+<h2><a class="toc-backref" href="#id65">2.17&nbsp;&nbsp;&nbsp;Raw text</a></h2>
<p>This does not necessarily look nice, because there may be missing white space.</p>
<p>It's just there to freeze the behavior.</p>
A test.Second test.<div class="myclass">Another test with myclass set.</div><p>This is the <span class="myrawroleclass">fourth test</span> with myrawroleclass set.</p>
Fifth test in HTML.<br />Line two.</div>
<div class="section" id="container">
-<h2><a class="toc-backref" href="#id65">2.18&nbsp;&nbsp;&nbsp;Container</a></h2>
+<h2><a class="toc-backref" href="#id66">2.18&nbsp;&nbsp;&nbsp;Container</a></h2>
<div class="custom container">
<p>paragraph 1</p>
<p>paragraph 2</p>
</div>
</div>
<div class="section" id="colspanning-tables">
-<h2><a class="toc-backref" href="#id66">2.19&nbsp;&nbsp;&nbsp;Colspanning tables</a></h2>
+<h2><a class="toc-backref" href="#id67">2.19&nbsp;&nbsp;&nbsp;Colspanning tables</a></h2>
<p>This table has a cell spanning two columns:</p>
<table border="1" class="docutils">
<colgroup>
@@ -851,7 +850,7 @@ Fifth test in HTML.<br />Line two.</div>
</table>
</div>
<div class="section" id="rowspanning-tables">
-<h2><a class="toc-backref" href="#id67">2.20&nbsp;&nbsp;&nbsp;Rowspanning tables</a></h2>
+<h2><a class="toc-backref" href="#id68">2.20&nbsp;&nbsp;&nbsp;Rowspanning tables</a></h2>
<p>Here's a table with cells spanning several rows:</p>
<table border="1" class="docutils">
<colgroup>
@@ -884,7 +883,7 @@ cell.</td>
</table>
</div>
<div class="section" id="complex-tables">
-<h2><a class="toc-backref" href="#id68">2.21&nbsp;&nbsp;&nbsp;Complex tables</a></h2>
+<h2><a class="toc-backref" href="#id69">2.21&nbsp;&nbsp;&nbsp;Complex tables</a></h2>
<p>Here's a complex table, which should test all features.</p>
<table border="1" class="docutils">
<colgroup>
@@ -933,7 +932,7 @@ empty: <tt class="docutils literal"><span class="pre">--&gt;</span></tt></td>
</table>
</div>
<div class="section" id="list-tables">
-<h2><a class="toc-backref" href="#id69">2.22&nbsp;&nbsp;&nbsp;List Tables</a></h2>
+<h2><a class="toc-backref" href="#id70">2.22&nbsp;&nbsp;&nbsp;List Tables</a></h2>
<p>Here's a list table exercising all features:</p>
<table border="1" class="test docutils">
<caption>list table with integral header</caption>
@@ -966,7 +965,7 @@ crunchy, now would it?</td>
</table>
</div>
<div class="section" id="custom-roles">
-<h2><a class="toc-backref" href="#id70">2.23&nbsp;&nbsp;&nbsp;Custom Roles</a></h2>
+<h2><a class="toc-backref" href="#id71">2.23&nbsp;&nbsp;&nbsp;Custom Roles</a></h2>
<ul>
<li><p class="first">A role based on an existing role.</p>
<p><tt class="custom docutils literal"><span class="pre">one</span></tt> <tt class="custom docutils literal"><span class="pre">two</span></tt> <tt class="custom docutils literal"><span class="pre">three</span></tt></p>
@@ -984,7 +983,7 @@ crunchy, now would it?</td>
</div>
</div>
<div class="section" id="error-handling">
-<h1><a class="toc-backref" href="#id71">3&nbsp;&nbsp;&nbsp;Error Handling</a></h1>
+<h1><a class="toc-backref" href="#id72">3&nbsp;&nbsp;&nbsp;Error Handling</a></h1>
<p>Any errors caught during processing will generate system messages.</p>
<p>There should be five messages in the following, auto-generated
section, &quot;Docutils System Messages&quot;:</p>
@@ -992,20 +991,20 @@ section, &quot;Docutils System Messages&quot;:</p>
</div>
<div class="system-messages section">
<h1>Docutils System Messages</h1>
-<div class="system-message" id="id23">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 100); <em><a href="#id24">backlink</a></em></p>
+<div class="system-message" id="id24">
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 100); <em><a href="#id25">backlink</a></em></p>
Undefined substitution referenced: &quot;problematic&quot;.</div>
-<div class="system-message" id="id80">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/standalone_rst_html4css1.txt</tt>, line 358); <em><a href="#id81">backlink</a></em></p>
+<div class="system-message" id="id81">
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/standalone_rst_html4css1.txt</tt>, line 359); <em><a href="#id82">backlink</a></em></p>
Unknown target name: &quot;5&quot;.</div>
-<div class="system-message" id="id82">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 367); <em><a href="#id83">backlink</a></em></p>
+<div class="system-message" id="id83">
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 368); <em><a href="#id84">backlink</a></em></p>
Unknown target name: &quot;nonexistent&quot;.</div>
-<div class="system-message" id="id84">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 394); <em><a href="#id85">backlink</a></em></p>
+<div class="system-message" id="id85">
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 395); <em><a href="#id86">backlink</a></em></p>
Unknown target name: &quot;hyperlink reference without a target&quot;.</div>
-<div class="system-message" id="id86">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 407); <em><a href="#id87">backlink</a></em></p>
+<div class="system-message" id="id87">
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 408); <em><a href="#id88">backlink</a></em></p>
Duplicate target name, cannot be used as a unique reference: &quot;duplicate target names&quot;.</div>
</div>
</div>
diff --git a/test/functional/expected/standalone_rst_latex.tex b/test/functional/expected/standalone_rst_latex.tex
index 4cc2f0eab..a4c9c9f6a 100644
--- a/test/functional/expected/standalone_rst_latex.tex
+++ b/test/functional/expected/standalone_rst_latex.tex
@@ -12,9 +12,8 @@
\usepackage{color}
\usepackage{multirow}
\usepackage{ifthen}
-\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage[DIV12]{typearea}
-%% generator Docutils: http://docutils.sourceforge.net/
+% generated by Docutils <http://docutils.sourceforge.net/>
\newlength{\admonitionwidth}
\setlength{\admonitionwidth}{0.9\textwidth}
\newlength{\docinfowidth}
@@ -55,6 +54,9 @@
\newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}}
\newcommand{\titlereference}[1]{\textsl{#1}}
% end of "some commands"
+\ifthenelse{\isundefined{\hypersetup}}{
+\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+}{}
\title{reStructuredText Test Document\\
\large{Examples of Syntax Constructs}
}
@@ -67,7 +69,6 @@ pdfauthor={David Goodger;Me;Myself;I}
\raggedbottom
\begin{document}
\maketitle
-
%___________________________________________________________________________
\begin{center}
\begin{tabularx}{\docinfowidth}{lX}
@@ -179,7 +180,7 @@ reStructuredText construct.
\begin{list}{}{}
\item {} \href{\#duplicate-target-names}{2.13.1~~~Duplicate Target Names}
-\item {} \href{\#id20}{2.13.2~~~Duplicate Target Names}
+\item {} \href{\#id21}{2.13.2~~~Duplicate Target Names}
\end{list}
@@ -221,7 +222,7 @@ reStructuredText construct.
\item {} \href{\#some-tests-for-the-latex2e-writer}{4~~~Some Tests for the LaTeX2e Writer}
-\item {} \href{\#id23}{5~~~Option lists}
+\item {} \href{\#id24}{5~~~Option lists}
\begin{list}{}{}
\item {} \href{\#monospaced-non-alphanumeric-characters}{5.1~~~Monospaced non-alphanumeric characters}
@@ -314,13 +315,13 @@ A paragraph.
Paragraphs contain text and may contain inline markup: \emph{emphasis},
\textbf{strong emphasis}, \texttt{inline literals}, standalone hyperlinks
-(\href{http://www.python.org}{http://www.python.org}), external hyperlinks (\href{http://www.python.org/}{Python}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id26}{5}}), internal
+(\href{http://www.python.org}{http://www.python.org}), external hyperlinks (\href{http://www.python.org/}{Python}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id27}{5}}), internal
cross-references (\href{\#example}{example}), external hyperlinks with embedded URIs
(\href{http://www.python.org}{Python web site}), \href{http://www.python.org/}{anonymous hyperlink
-references}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id26}{5}} (\href{http://docutils.sourceforge.net/}{a second reference}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id31}{6}}), footnote references (manually
-numbered\raisebox{.5em}[0em]{\scriptsize\hyperlink{id8}{1}}, anonymous auto-numbered\raisebox{.5em}[0em]{\scriptsize\hyperlink{id11}{3}}, labeled auto-numbered\raisebox{.5em}[0em]{\scriptsize\hyperlink{label}{2}}, or symbolic\raisebox{.5em}[0em]{\scriptsize\hyperlink{id12}{*}}), citation references ([\hyperlink{cit2002}{CIT2002}]),
+references}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id27}{5}} (\href{http://docutils.sourceforge.net/}{a second reference}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id32}{6}}), footnote references (manually
+numbered\raisebox{.5em}[0em]{\scriptsize\hyperlink{id8}{1}}, anonymous auto-numbered\raisebox{.5em}[0em]{\scriptsize\hyperlink{id12}{3}}, labeled auto-numbered\raisebox{.5em}[0em]{\scriptsize\hyperlink{label}{2}}, or symbolic\raisebox{.5em}[0em]{\scriptsize\hyperlink{id13}{*}}), citation references ([\hyperlink{cit2002}{CIT2002}]),
substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png}), and \hypertarget{inline-hyperlink-targets}{inline hyperlink targets}
-(see \href{\#id22}{Targets} below for a reference back to here). Character-level
+(see \href{\#id23}{Targets} below for a reference back to here). Character-level
inline markup is also possible (although exceedingly ugly!) in \emph{re}\texttt{Structured}\emph{Text}. Problems are indicated by {\color{red}\bfseries{}{\textbar}problematic{\textbar}} text
(generated by processing errors; this one is intentional). Here is a
reference to the \href{\#doctitle}{doctitle} and the \href{\#subtitle}{subtitle}.
@@ -502,31 +503,23 @@ iv
\subsection*{2.4~~~Definition Lists}
\label{definition-lists}
\begin{description}
-%[visit_definition_list_item]
-\item[{Term}]
+\item[{Term}] \leavevmode
Definition
-%[depart_definition_list_item]
-%[visit_definition_list_item]
-\item[{Term}] (\textbf{classifier})
+\item[{Term}] \leavevmode (\textbf{classifier})
Definition paragraph 1.
Definition paragraph 2.
-%[depart_definition_list_item]
-%[visit_definition_list_item]
-\item[{Term}]
+\item[{Term}] \leavevmode
Definition
-%[depart_definition_list_item]
-%[visit_definition_list_item]
-\item[{Term}] (\textbf{classifier one})
+\item[{Term}] \leavevmode (\textbf{classifier one})
(\textbf{classifier two})
Definition
-%[depart_definition_list_item]
\end{description}
@@ -751,10 +744,9 @@ This is the footnote's second paragraph.
Footnotes may be numbered, either manually (as in\raisebox{.5em}[0em]{\scriptsize\hyperlink{id8}{1}}) or
automatically using a ``{\#}''-prefixed label. This footnote has a
label so it can be referred to from multiple places, both as a
-footnote reference (\raisebox{.5em}[0em]{\scriptsize\hyperlink{label}{2}}) and as a hyperlink reference
-(\href{\#label}{label}).
-\end{figure}
-\begin{figure}[b]\hypertarget{id11}$^{3}$
+footnote reference (\raisebox{.5em}[0em]{\scriptsize\hyperlink{label}{2}}) and as a \href{\#label}{hyperlink reference}.
+\hypertarget{label}{}\end{figure}
+\begin{figure}[b]\hypertarget{id12}$^{3}$
This footnote is numbered automatically and anonymously using a
label of ``{\#}'' only.
@@ -762,14 +754,14 @@ This is the second paragraph.
And this is the third paragraph.
\end{figure}
-\begin{figure}[b]\hypertarget{id12}$^{*}$
+\begin{figure}[b]\hypertarget{id13}$^{*}$
Footnotes may also use symbols, specified with a ``*'' label.
-Here's a reference to the next footnote:\raisebox{.5em}[0em]{\scriptsize\hyperlink{id14}{{\dag}}}.
+Here's a reference to the next footnote:\raisebox{.5em}[0em]{\scriptsize\hyperlink{id15}{{\dag}}}.
\end{figure}
-\begin{figure}[b]\hypertarget{id14}$^{{\dag}}$
+\begin{figure}[b]\hypertarget{id15}$^{{\dag}}$
This footnote shows the next symbol in the sequence.
\end{figure}
-\begin{figure}[b]\hypertarget{id15}$^{4}$
+\begin{figure}[b]\hypertarget{id16}$^{4}$
Here's an unreferenced footnote, with a reference to a
nonexistent footnote:{\color{red}\bfseries{}{[}5{]}{\_}}.
\end{figure}
@@ -805,14 +797,14 @@ reference can be found under \href{\#inline-markup}{Inline Markup}, above. \href
hyperlink targets} are also possible.
Section headers are implicit targets, referred to by name. See
-\href{\#id22}{Targets}, which is a subsection of \href{\#body-elements}{Body Elements}.
+\href{\#id23}{Targets}, which is a subsection of \href{\#body-elements}{Body Elements}.
Explicit external targets are interpolated into references such as
-``\href{http://www.python.org/}{Python}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id26}{5}}''.
+``\href{http://www.python.org/}{Python}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id27}{5}}''.
-Targets may be indirect and anonymous. Thus \href{\#id22}{this phrase} may also
-refer to the \href{\#id22}{Targets} section.
-\hypertarget{id22}{}
+Targets may be indirect and anonymous. Thus \href{\#id23}{this phrase} may also
+refer to the \href{\#id23}{Targets} section.
+\hypertarget{id23}{}
Here's a {\color{red}\bfseries{}`hyperlink reference without a target`{\_}}, which generates an
error.
@@ -831,10 +823,10 @@ explicit targets will generate ``warning'' (level-2) system messages.
%___________________________________________________________________________
-\hypertarget{id20}{}
-\pdfbookmark[2]{2.13.2~~~Duplicate Target Names}{id20}
+\hypertarget{id21}{}
+\pdfbookmark[2]{2.13.2~~~Duplicate Target Names}{id21}
\subsubsection*{2.13.2~~~Duplicate Target Names}
-\label{id20}
+\label{id21}
Since there are two ``Duplicate Target Names'' section headers, we
cannot uniquely refer to either of them by name. If we try to (like
@@ -914,7 +906,8 @@ A figure directive:
\includegraphics[width=50]{../../../docs/user/rst/images/biohazard.png}
\caption{A figure is an image with a caption and/or a legend:}{\small
-\begin{longtable}[c]{|p{0.16\locallinewidth}|p{0.56\locallinewidth}|}
+\leavevmode
+\begin{longtable}[c]{|p{0.156\locallinewidth}|p{0.563\locallinewidth}|}
\hline
re
@@ -1143,10 +1136,10 @@ This is a topic.
\pdfbookmark[2]{2.14.5~~~Target Footnotes}{target-footnotes}
\subsubsection*{2.14.5~~~Target Footnotes}
\label{target-footnotes}
-\begin{figure}[b]\hypertarget{id26}$^{5}$
+\begin{figure}[b]\hypertarget{id27}$^{5}$
\href{http://www.python.org/}{http://www.python.org/}
\end{figure}
-\begin{figure}[b]\hypertarget{id31}$^{6}$
+\begin{figure}[b]\hypertarget{id32}$^{6}$
\href{http://docutils.sourceforge.net/}{http://docutils.sourceforge.net/}
\end{figure}
@@ -1158,7 +1151,7 @@ This is a topic.
\subsubsection*{2.14.6~~~Replacement Text}
\label{replacement-text}
-I recommend you try \href{http://www.python.org/}{Python, \emph{the} best language around}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id26}{5}}.
+I recommend you try \href{http://www.python.org/}{Python, \emph{the} best language around}\raisebox{.5em}[0em]{\scriptsize\hyperlink{id27}{5}}.
%___________________________________________________________________________
@@ -1209,7 +1202,8 @@ Compound 5, block 3 (a paragraph).
Compound 7, with a table inside:
-\begin{longtable}[c]{|p{0.25\locallinewidth}|p{0.25\locallinewidth}|p{0.25\locallinewidth}|}
+\leavevmode
+\begin{longtable}[c]{|p{0.249\locallinewidth}|p{0.249\locallinewidth}|p{0.249\locallinewidth}|}
\hline
Left cell, first
@@ -1247,7 +1241,7 @@ This~is~a~parsed~literal~block.~\\
~~~~This~line~is~indented.~~The~next~line~is~blank.~\\
~\\
Inline~markup~is~supported,~e.g.~\emph{emphasis},~\textbf{strong},~\texttt{literal~\\
-text},~footnotes\raisebox{.5em}[0em]{\scriptsize\hyperlink{id8}{1}},~\hypertarget{id22}{targets},~and~\href{http://www.python.org/}{references}.
+text},~footnotes\raisebox{.5em}[0em]{\scriptsize\hyperlink{id8}{1}},~\hypertarget{id23}{targets},~and~\href{http://www.python.org/}{references}.
}\end{quote}
@@ -1317,7 +1311,8 @@ paragraph 2
This table has a cell spanning two columns:
-\begin{longtable}[c]{|p{0.07\locallinewidth}|p{0.07\locallinewidth}|p{0.09\locallinewidth}|}
+\leavevmode
+\begin{longtable}[c]{|p{0.075\locallinewidth}|p{0.075\locallinewidth}|p{0.086\locallinewidth}|}
\hline
\multicolumn{2}{|l|}{\textbf{
Inputs
@@ -1378,7 +1373,8 @@ True
Here's a table with cells spanning several rows:
-\begin{longtable}[c]{|p{0.30\locallinewidth}|p{0.16\locallinewidth}|p{0.23\locallinewidth}|}
+\leavevmode
+\begin{longtable}[c]{|p{0.296\locallinewidth}|p{0.156\locallinewidth}|p{0.226\locallinewidth}|}
\hline
\textbf{
Header row, column 1
@@ -1440,10 +1436,10 @@ This file is user by the standalone{\_}rst{\_}latex test.
%___________________________________________________________________________
-\hypertarget{id23}{}
-\pdfbookmark[0]{5~~~Option lists}{id23}
+\hypertarget{id24}{}
+\pdfbookmark[0]{5~~~Option lists}{id24}
\section*{5~~~Option lists}
-\label{id23}
+\label{id24}
The LaTeX-2e description environment is used for definition lists.
The definition is continued on the same line as the term, this should
@@ -1460,16 +1456,13 @@ verbose
\end{optionlist}
\end{quote}
\begin{description}
-%[visit_definition_list_item]
-\item[{In a definition list:}] ~
-\begin{optionlist}{3cm}
+\item[{In a definition list:}] \leavevmode \begin{optionlist}{3cm}
\item [-{}-help]
show help
\item [-v]
verbose
\end{optionlist}
-%[depart_definition_list_item]
\end{description}
@@ -1499,7 +1492,8 @@ width as the third line.
\subsection*{5.2~~~Various non-ASCII characters}
\label{various-non-ascii-characters}
-\begin{longtable}[c]{|p{0.03\locallinewidth}|p{0.42\locallinewidth}|}
+\leavevmode
+\begin{longtable}[c]{|p{0.028\locallinewidth}|p{0.424\locallinewidth}|}
\hline
©
diff --git a/test/functional/expected/standalone_rst_pseudoxml.txt b/test/functional/expected/standalone_rst_pseudoxml.txt
index 1578dd155..5c8143544 100644
--- a/test/functional/expected/standalone_rst_pseudoxml.txt
+++ b/test/functional/expected/standalone_rst_pseudoxml.txt
@@ -91,250 +91,250 @@
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id32" refid="structural-elements">
+ <reference ids="id33" refid="structural-elements">
<generated classes="sectnum">
1   
Structural Elements
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id33" refid="section-title">
+ <reference ids="id34" refid="section-title">
<generated classes="sectnum">
1.1   
Section Title
<list_item>
<paragraph>
- <reference ids="id34" refid="empty-section">
+ <reference ids="id35" refid="empty-section">
<generated classes="sectnum">
1.2   
Empty Section
<list_item>
<paragraph>
- <reference ids="id35" refid="transitions">
+ <reference ids="id36" refid="transitions">
<generated classes="sectnum">
1.3   
Transitions
<list_item>
<paragraph>
- <reference ids="id36" refid="body-elements">
+ <reference ids="id37" refid="body-elements">
<generated classes="sectnum">
2   
Body Elements
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id37" refid="paragraphs">
+ <reference ids="id38" refid="paragraphs">
<generated classes="sectnum">
2.1   
Paragraphs
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id38" refid="inline-markup">
+ <reference ids="id39" refid="inline-markup">
<generated classes="sectnum">
2.1.1   
Inline Markup
<list_item>
<paragraph>
- <reference ids="id39" refid="bullet-lists">
+ <reference ids="id40" refid="bullet-lists">
<generated classes="sectnum">
2.2   
Bullet Lists
<list_item>
<paragraph>
- <reference ids="id40" refid="enumerated-lists">
+ <reference ids="id41" refid="enumerated-lists">
<generated classes="sectnum">
2.3   
Enumerated Lists
<list_item>
<paragraph>
- <reference ids="id41" refid="definition-lists">
+ <reference ids="id42" refid="definition-lists">
<generated classes="sectnum">
2.4   
Definition Lists
<list_item>
<paragraph>
- <reference ids="id42" refid="field-lists">
+ <reference ids="id43" refid="field-lists">
<generated classes="sectnum">
2.5   
Field Lists
<list_item>
<paragraph>
- <reference ids="id43" refid="option-lists">
+ <reference ids="id44" refid="option-lists">
<generated classes="sectnum">
2.6   
Option Lists
<list_item>
<paragraph>
- <reference ids="id44" refid="literal-blocks">
+ <reference ids="id45" refid="literal-blocks">
<generated classes="sectnum">
2.7   
Literal Blocks
<list_item>
<paragraph>
- <reference ids="id45" refid="line-blocks">
+ <reference ids="id46" refid="line-blocks">
<generated classes="sectnum">
2.8   
Line Blocks
<list_item>
<paragraph>
- <reference ids="id46" refid="block-quotes">
+ <reference ids="id47" refid="block-quotes">
<generated classes="sectnum">
2.9   
Block Quotes
<list_item>
<paragraph>
- <reference ids="id47" refid="doctest-blocks">
+ <reference ids="id48" refid="doctest-blocks">
<generated classes="sectnum">
2.10   
Doctest Blocks
<list_item>
<paragraph>
- <reference ids="id48" refid="footnotes">
+ <reference ids="id49" refid="footnotes">
<generated classes="sectnum">
2.11   
Footnotes
<list_item>
<paragraph>
- <reference ids="id49" refid="citations">
+ <reference ids="id50" refid="citations">
<generated classes="sectnum">
2.12   
Citations
<list_item>
<paragraph>
- <reference ids="id50" refid="targets">
+ <reference ids="id51" refid="targets">
<generated classes="sectnum">
2.13   
Targets
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id51" refid="duplicate-target-names">
+ <reference ids="id52" refid="duplicate-target-names">
<generated classes="sectnum">
2.13.1   
Duplicate Target Names
<list_item>
<paragraph>
- <reference ids="id52" refid="id20">
+ <reference ids="id53" refid="id21">
<generated classes="sectnum">
2.13.2   
Duplicate Target Names
<list_item>
<paragraph>
- <reference ids="id53" refid="directives">
+ <reference ids="id54" refid="directives">
<generated classes="sectnum">
2.14   
Directives
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id54" refid="document-parts">
+ <reference ids="id55" refid="document-parts">
<generated classes="sectnum">
2.14.1   
Document Parts
<list_item>
<paragraph>
- <reference ids="id55" refid="images">
+ <reference ids="id56" refid="images">
<generated classes="sectnum">
2.14.2   
Images
<list_item>
<paragraph>
- <reference ids="id56" refid="admonitions">
+ <reference ids="id57" refid="admonitions">
<generated classes="sectnum">
2.14.3   
Admonitions
<list_item>
<paragraph>
- <reference ids="id57" refid="topics-sidebars-and-rubrics">
+ <reference ids="id58" refid="topics-sidebars-and-rubrics">
<generated classes="sectnum">
2.14.4   
Topics, Sidebars, and Rubrics
<list_item>
<paragraph>
- <reference ids="id58" refid="target-footnotes">
+ <reference ids="id59" refid="target-footnotes">
<generated classes="sectnum">
2.14.5   
Target Footnotes
<list_item>
<paragraph>
- <reference ids="id59" refid="replacement-text">
+ <reference ids="id60" refid="replacement-text">
<generated classes="sectnum">
2.14.6   
Replacement Text
<list_item>
<paragraph>
- <reference ids="id60" refid="compound-paragraph">
+ <reference ids="id61" refid="compound-paragraph">
<generated classes="sectnum">
2.14.7   
Compound Paragraph
<list_item>
<paragraph>
- <reference ids="id61" refid="parsed-literal-blocks">
+ <reference ids="id62" refid="parsed-literal-blocks">
<generated classes="sectnum">
2.14.8   
Parsed Literal Blocks
<list_item>
<paragraph>
- <reference ids="id62" refid="substitution-definitions">
+ <reference ids="id63" refid="substitution-definitions">
<generated classes="sectnum">
2.15   
Substitution Definitions
<list_item>
<paragraph>
- <reference ids="id63" refid="comments">
+ <reference ids="id64" refid="comments">
<generated classes="sectnum">
2.16   
Comments
<list_item>
<paragraph>
- <reference ids="id64" refid="raw-text">
+ <reference ids="id65" refid="raw-text">
<generated classes="sectnum">
2.17   
Raw text
<list_item>
<paragraph>
- <reference ids="id65" refid="container">
+ <reference ids="id66" refid="container">
<generated classes="sectnum">
2.18   
Container
<list_item>
<paragraph>
- <reference ids="id66" refid="colspanning-tables">
+ <reference ids="id67" refid="colspanning-tables">
<generated classes="sectnum">
2.19   
Colspanning tables
<list_item>
<paragraph>
- <reference ids="id67" refid="rowspanning-tables">
+ <reference ids="id68" refid="rowspanning-tables">
<generated classes="sectnum">
2.20   
Rowspanning tables
<list_item>
<paragraph>
- <reference ids="id68" refid="complex-tables">
+ <reference ids="id69" refid="complex-tables">
<generated classes="sectnum">
2.21   
Complex tables
<list_item>
<paragraph>
- <reference ids="id69" refid="list-tables">
+ <reference ids="id70" refid="list-tables">
<generated classes="sectnum">
2.22   
List Tables
<list_item>
<paragraph>
- <reference ids="id70" refid="error-handling">
+ <reference ids="id71" refid="error-handling">
<generated classes="sectnum">
3   
Error Handling
<section ids="structural-elements" names="structural\ elements">
- <title auto="1" refid="id32">
+ <title auto="1" refid="id33">
<generated classes="sectnum">
1   
Structural Elements
<section ids="section-title" names="section\ title">
- <title auto="1" refid="id33">
+ <title auto="1" refid="id34">
<generated classes="sectnum">
1.1   
Section Title
@@ -343,12 +343,12 @@
<paragraph>
That's it, the text just above this line.
<section ids="empty-section" names="empty\ section">
- <title auto="1" refid="id34">
+ <title auto="1" refid="id35">
<generated classes="sectnum">
1.2   
Empty Section
<section ids="transitions" names="transitions">
- <title auto="1" refid="id35">
+ <title auto="1" refid="id36">
<generated classes="sectnum">
1.3   
Transitions
@@ -359,19 +359,19 @@
It divides the section. Transitions may also occur between sections:
<transition>
<section ids="body-elements" names="body\ elements">
- <title auto="1" refid="id36">
+ <title auto="1" refid="id37">
<generated classes="sectnum">
2   
Body Elements
<section ids="paragraphs" names="paragraphs">
- <title auto="1" refid="id37">
+ <title auto="1" refid="id38">
<generated classes="sectnum">
2.1   
Paragraphs
<paragraph>
A paragraph.
<section ids="inline-markup" names="inline\ markup">
- <title auto="1" refid="id38">
+ <title auto="1" refid="id39">
<generated classes="sectnum">
2.1.1   
Inline Markup
@@ -393,7 +393,7 @@
<reference name="Python" refuri="http://www.python.org/">
Python
- <footnote_reference auto="1" ids="id26" refid="id25">
+ <footnote_reference auto="1" ids="id27" refid="id26">
5
), internal
cross-references (
@@ -408,26 +408,26 @@
anonymous hyperlink
references
- <footnote_reference auto="1" ids="id29" refid="id25">
+ <footnote_reference auto="1" ids="id30" refid="id26">
5
(
<reference anonymous="1" name="a second reference" refuri="http://docutils.sourceforge.net/">
a second reference
- <footnote_reference auto="1" ids="id31" refid="id30">
+ <footnote_reference auto="1" ids="id32" refid="id31">
6
), footnote references (manually
numbered
<footnote_reference ids="id1" refid="id8">
1
, anonymous auto-numbered
- <footnote_reference auto="1" ids="id2" refid="id11">
+ <footnote_reference auto="1" ids="id2" refid="id12">
3
, labeled auto-numbered
<footnote_reference auto="1" ids="id3" refid="label">
2
, or symbolic
- <footnote_reference auto="*" ids="id4" refid="id12">
+ <footnote_reference auto="*" ids="id4" refid="id13">
*
), citation references (
<citation_reference ids="id5" refid="cit2002">
@@ -440,7 +440,7 @@
inline hyperlink targets
(see
- <reference name="Targets" refid="id22">
+ <reference name="Targets" refid="id23">
Targets
below for a reference back to here). Character-level
inline markup is also possible (although exceedingly ugly!) in
@@ -451,7 +451,7 @@
<emphasis>
Text
. Problems are indicated by
- <problematic ids="id24" refid="id23">
+ <problematic ids="id25" refid="id24">
|problematic|
text
(generated by processing errors; this one is intentional). Here is a
@@ -510,7 +510,7 @@
option was supplied, there should be a
live link to PEP 258 here.
<section ids="bullet-lists" names="bullet\ lists">
- <title auto="1" refid="id39">
+ <title auto="1" refid="id40">
<generated classes="sectnum">
2.2   
Bullet Lists
@@ -554,7 +554,7 @@
<comment xml:space="preserve">
Even if this item contains a target and a comment.
<section ids="enumerated-lists" names="enumerated\ lists">
- <title auto="1" refid="id40">
+ <title auto="1" refid="id41">
<generated classes="sectnum">
2.3   
Enumerated Lists
@@ -603,7 +603,7 @@
<paragraph>
iv
<section ids="definition-lists" names="definition\ lists">
- <title auto="1" refid="id41">
+ <title auto="1" refid="id42">
<generated classes="sectnum">
2.4   
Definition Lists
@@ -641,7 +641,7 @@
<paragraph>
Definition
<section ids="field-lists" names="field\ lists">
- <title auto="1" refid="id42">
+ <title auto="1" refid="id43">
<generated classes="sectnum">
2.5   
Field Lists
@@ -675,7 +675,7 @@
about credits but just for ensuring that the class attribute
doesn't get stripped away.)
<section ids="option-lists" names="option\ lists">
- <title auto="1" refid="id43">
+ <title auto="1" refid="id44">
<generated classes="sectnum">
2.6   
Option Lists
@@ -788,7 +788,7 @@
There must be at least two spaces between the option and the
description.
<section ids="literal-blocks" names="literal\ blocks">
- <title auto="1" refid="id44">
+ <title auto="1" refid="id45">
<generated classes="sectnum">
2.7   
Literal Blocks
@@ -810,7 +810,7 @@
>
> Why didn't I think of that?
<section ids="line-blocks" names="line\ blocks">
- <title auto="1" refid="id45">
+ <title auto="1" refid="id46">
<generated classes="sectnum">
2.8   
Line Blocks
@@ -888,7 +888,7 @@
<line>
Singing...
<section ids="block-quotes" names="block\ quotes">
- <title auto="1" refid="id46">
+ <title auto="1" refid="id47">
<generated classes="sectnum">
2.9   
Block Quotes
@@ -904,7 +904,7 @@
<attribution>
Anne Elk (Miss)
<section ids="doctest-blocks" names="doctest\ blocks">
- <title auto="1" refid="id47">
+ <title auto="1" refid="id48">
<generated classes="sectnum">
2.10   
Doctest Blocks
@@ -914,11 +914,11 @@
>>> print '(cut and pasted from interactive Python sessions)'
(cut and pasted from interactive Python sessions)
<section ids="footnotes" names="footnotes">
- <title auto="1" refid="id48">
+ <title auto="1" refid="id49">
<generated classes="sectnum">
2.11   
Footnotes
- <footnote backrefs="id1 id9 id21" ids="id8" names="1">
+ <footnote backrefs="id1 id9 id22" ids="id8" names="1">
<label>
1
<paragraph>
@@ -939,12 +939,12 @@
footnote reference (
<footnote_reference auto="1" ids="id10" refid="label">
2
- ) and as a hyperlink reference
- (
- <reference name="label" refid="label">
- label
- ).
- <footnote auto="1" backrefs="id2" ids="id11" names="3">
+ ) and as a
+ <reference anonymous="1" name="hyperlink reference" refid="label">
+ hyperlink reference
+ .
+ <target anonymous="1" ids="id11" refid="label">
+ <footnote auto="1" backrefs="id2" ids="id12" names="3">
<label>
3
<paragraph>
@@ -954,35 +954,35 @@
This is the second paragraph.
<paragraph>
And this is the third paragraph.
- <footnote auto="*" backrefs="id4" ids="id12">
+ <footnote auto="*" backrefs="id4" ids="id13">
<label>
*
<paragraph>
Footnotes may also use symbols, specified with a "*" label.
Here's a reference to the next footnote:
- <footnote_reference auto="*" ids="id13" refid="id14">
+ <footnote_reference auto="*" ids="id14" refid="id15">
†
.
- <footnote auto="*" backrefs="id13" ids="id14">
+ <footnote auto="*" backrefs="id14" ids="id15">
<label>
†
<paragraph>
This footnote shows the next symbol in the sequence.
- <footnote ids="id15" names="4">
+ <footnote ids="id16" names="4">
<label>
4
<paragraph>
Here's an unreferenced footnote, with a reference to a
nonexistent footnote:
- <problematic ids="id80 id16" refid="id79">
+ <problematic ids="id81 id17" refid="id80">
[5]_
.
<section ids="citations" names="citations">
- <title auto="1" refid="id49">
+ <title auto="1" refid="id50">
<generated classes="sectnum">
2.12   
Citations
- <citation backrefs="id5 id17" ids="cit2002" names="cit2002">
+ <citation backrefs="id5 id18" ids="cit2002" names="cit2002">
<label>
CIT2002
<paragraph>
@@ -990,16 +990,16 @@
rendered separately and differently from footnotes.
<paragraph>
Here's a reference to the above,
- <citation_reference ids="id17" refid="cit2002">
+ <citation_reference ids="id18" refid="cit2002">
CIT2002
, and a
- <problematic ids="id82 id18" refid="id81">
+ <problematic ids="id83 id19" refid="id82">
[nonexistent]_
citation.
<target refid="another-target">
<section dupnames="targets" ids="targets another-target" names="another\ target">
- <title auto="1" refid="id50">
+ <title auto="1" refid="id51">
<generated classes="sectnum">
2.13   
Targets
@@ -1016,7 +1016,7 @@
are also possible.
<paragraph>
Section headers are implicit targets, referred to by name. See
- <reference name="Targets" refid="id22">
+ <reference name="Targets" refid="id23">
Targets
, which is a subsection of
<reference name="Body Elements" refid="body-elements">
@@ -1028,28 +1028,28 @@
<reference name="Python" refuri="http://www.python.org/">
Python
- <footnote_reference auto="1" ids="id27" refid="id25">
+ <footnote_reference auto="1" ids="id28" refid="id26">
5
".
<target ids="python" names="python" refuri="http://www.python.org/">
<paragraph>
Targets may be indirect and anonymous. Thus
- <reference anonymous="1" name="this phrase" refid="id22">
+ <reference anonymous="1" name="this phrase" refid="id23">
this phrase
may also
refer to the
- <reference name="Targets" refid="id22">
+ <reference name="Targets" refid="id23">
Targets
section.
- <target anonymous="1" ids="id19" refid="id22">
+ <target anonymous="1" ids="id20" refid="id23">
<paragraph>
Here's a
- <problematic ids="id84" refid="id83">
+ <problematic ids="id85" refid="id84">
`hyperlink reference without a target`_
, which generates an
error.
<section dupnames="duplicate\ target\ names" ids="duplicate-target-names">
- <title auto="1" refid="id51">
+ <title auto="1" refid="id52">
<generated classes="sectnum">
2.13.1   
Duplicate Target Names
@@ -1057,8 +1057,8 @@
Duplicate names in section headers or other implicit targets will
generate "info" (level-1) system messages. Duplicate names in
explicit targets will generate "warning" (level-2) system messages.
- <section dupnames="duplicate\ target\ names" ids="id20">
- <title auto="1" refid="id52">
+ <section dupnames="duplicate\ target\ names" ids="id21">
+ <title auto="1" refid="id53">
<generated classes="sectnum">
2.13.2   
Duplicate Target Names
@@ -1066,11 +1066,11 @@
Since there are two "Duplicate Target Names" section headers, we
cannot uniquely refer to either of them by name. If we try to (like
this:
- <problematic ids="id86" refid="id85">
+ <problematic ids="id87" refid="id86">
`Duplicate Target Names`_
), an error is generated.
<section ids="directives" names="directives">
- <title auto="1" refid="id53">
+ <title auto="1" refid="id54">
<generated classes="sectnum">
2.14   
Directives
@@ -1078,49 +1078,49 @@
<bullet_list classes="auto-toc">
<list_item>
<paragraph>
- <reference ids="id71" refid="document-parts">
+ <reference ids="id72" refid="document-parts">
<generated classes="sectnum">
2.14.1   
Document Parts
<list_item>
<paragraph>
- <reference ids="id72" refid="images">
+ <reference ids="id73" refid="images">
<generated classes="sectnum">
2.14.2   
Images
<list_item>
<paragraph>
- <reference ids="id73" refid="admonitions">
+ <reference ids="id74" refid="admonitions">
<generated classes="sectnum">
2.14.3   
Admonitions
<list_item>
<paragraph>
- <reference ids="id74" refid="topics-sidebars-and-rubrics">
+ <reference ids="id75" refid="topics-sidebars-and-rubrics">
<generated classes="sectnum">
2.14.4   
Topics, Sidebars, and Rubrics
<list_item>
<paragraph>
- <reference ids="id75" refid="target-footnotes">
+ <reference ids="id76" refid="target-footnotes">
<generated classes="sectnum">
2.14.5   
Target Footnotes
<list_item>
<paragraph>
- <reference ids="id76" refid="replacement-text">
+ <reference ids="id77" refid="replacement-text">
<generated classes="sectnum">
2.14.6   
Replacement Text
<list_item>
<paragraph>
- <reference ids="id77" refid="compound-paragraph">
+ <reference ids="id78" refid="compound-paragraph">
<generated classes="sectnum">
2.14.7   
Compound Paragraph
<list_item>
<paragraph>
- <reference ids="id78" refid="parsed-literal-blocks">
+ <reference ids="id79" refid="parsed-literal-blocks">
<generated classes="sectnum">
2.14.8   
Parsed Literal Blocks
@@ -1131,7 +1131,7 @@
http://docutils.sourceforge.net/docs/ref/rst/directives.html
.
<section ids="document-parts" names="document\ parts">
- <title auto="1" refid="id71">
+ <title auto="1" refid="id72">
<generated classes="sectnum">
2.14.1   
Document Parts
@@ -1146,7 +1146,7 @@
table of contents
).
<section ids="images" names="images">
- <title auto="1" refid="id72">
+ <title auto="1" refid="id73">
<generated classes="sectnum">
2.14.2   
Images
@@ -1254,7 +1254,7 @@
An image 3 cm high:
<image height="3cm" uri="../../../docs/user/rst/images/biohazard.png">
<section ids="admonitions" names="admonitions">
- <title auto="1" refid="id73">
+ <title auto="1" refid="id74">
<generated classes="sectnum">
2.14.3   
Admonitions
@@ -1304,7 +1304,7 @@
You can make up your own admonition too.
<target ids="docutils" names="docutils" refuri="http://docutils.sourceforge.net/">
<section ids="topics-sidebars-and-rubrics" names="topics,\ sidebars,\ and\ rubrics">
- <title auto="1" refid="id74">
+ <title auto="1" refid="id75">
<generated classes="sectnum">
2.14.4   
Topics, Sidebars, and Rubrics
@@ -1329,24 +1329,24 @@
<rubric>
This is a rubric
<section ids="target-footnotes" names="target\ footnotes">
- <title auto="1" refid="id75">
+ <title auto="1" refid="id76">
<generated classes="sectnum">
2.14.5   
Target Footnotes
- <footnote auto="1" backrefs="id26 id27 id28 id29" ids="id25" names="TARGET_NOTE:\ id25">
+ <footnote auto="1" backrefs="id27 id28 id29 id30" ids="id26" names="TARGET_NOTE:\ id26">
<label>
5
<paragraph>
<reference refuri="http://www.python.org/">
http://www.python.org/
- <footnote auto="1" backrefs="id31" ids="id30" names="TARGET_NOTE:\ id30">
+ <footnote auto="1" backrefs="id32" ids="id31" names="TARGET_NOTE:\ id31">
<label>
6
<paragraph>
<reference refuri="http://docutils.sourceforge.net/">
http://docutils.sourceforge.net/
<section ids="replacement-text" names="replacement\ text">
- <title auto="1" refid="id76">
+ <title auto="1" refid="id77">
<generated classes="sectnum">
2.14.6   
Replacement Text
@@ -1358,7 +1358,7 @@
the
best language around
- <footnote_reference auto="1" ids="id28" refid="id25">
+ <footnote_reference auto="1" ids="id29" refid="id26">
5
.
<substitution_definition names="Python">
@@ -1367,7 +1367,7 @@
the
best language around
<section ids="compound-paragraph" names="compound\ paragraph">
- <title auto="1" refid="id77">
+ <title auto="1" refid="id78">
<generated classes="sectnum">
2.14.7   
Compound Paragraph
@@ -1453,7 +1453,7 @@
<paragraph>
Compound 7, another paragraph.
<section ids="parsed-literal-blocks" names="parsed\ literal\ blocks">
- <title auto="1" refid="id78">
+ <title auto="1" refid="id79">
<generated classes="sectnum">
2.14.8   
Parsed Literal Blocks
@@ -1472,10 +1472,10 @@
literal
text
, footnotes
- <footnote_reference ids="id21" refid="id8">
+ <footnote_reference ids="id22" refid="id8">
1
,
- <target ids="id22" names="targets">
+ <target ids="id23" names="targets">
targets
, and
<reference name="references" refuri="http://www.python.org/">
@@ -1483,7 +1483,7 @@
<target ids="references" names="references" refuri="http://www.python.org/">
.
<section ids="substitution-definitions" names="substitution\ definitions">
- <title auto="1" refid="id62">
+ <title auto="1" refid="id63">
<generated classes="sectnum">
2.15   
Substitution Definitions
@@ -1496,7 +1496,7 @@
<paragraph>
(Substitution definitions are not visible in the HTML source.)
<section ids="comments" names="comments">
- <title auto="1" refid="id63">
+ <title auto="1" refid="id64">
<generated classes="sectnum">
2.16   
Comments
@@ -1513,7 +1513,7 @@
<paragraph>
(View the HTML source to see the comment.)
<section ids="raw-text" names="raw\ text">
- <title auto="1" refid="id64">
+ <title auto="1" refid="id65">
<generated classes="sectnum">
2.17   
Raw text
@@ -1537,7 +1537,7 @@
<raw format="latex" xml:space="preserve">
Fifth test in LaTeX.\\Line two.
<section ids="container" names="container">
- <title auto="1" refid="id65">
+ <title auto="1" refid="id66">
<generated classes="sectnum">
2.18   
Container
@@ -1547,7 +1547,7 @@
<paragraph>
paragraph 2
<section ids="colspanning-tables" names="colspanning\ tables">
- <title auto="1" refid="id66">
+ <title auto="1" refid="id67">
<generated classes="sectnum">
2.19   
Colspanning tables
@@ -1618,7 +1618,7 @@
<paragraph>
True
<section ids="rowspanning-tables" names="rowspanning\ tables">
- <title auto="1" refid="id67">
+ <title auto="1" refid="id68">
<generated classes="sectnum">
2.20   
Rowspanning tables
@@ -1670,7 +1670,7 @@
<paragraph>
body row 3
<section ids="complex-tables" names="complex\ tables">
- <title auto="1" refid="id68">
+ <title auto="1" refid="id69">
<generated classes="sectnum">
2.21   
Complex tables
@@ -1755,7 +1755,7 @@
-->
<entry>
<section ids="list-tables" names="list\ tables">
- <title auto="1" refid="id69">
+ <title auto="1" refid="id70">
<generated classes="sectnum">
2.22   
List Tables
@@ -1812,7 +1812,7 @@
<paragraph>
On a stick!
<section ids="error-handling" names="error\ handling">
- <title auto="1" refid="id70">
+ <title auto="1" refid="id71">
<generated classes="sectnum">
3   
Error Handling
@@ -1826,18 +1826,18 @@
<section classes="system-messages">
<title>
Docutils System Messages
- <system_message backrefs="id24" ids="id23" level="3" line="100" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id25" ids="id24" level="3" line="100" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Undefined substitution referenced: "problematic".
- <system_message backrefs="id80" ids="id79" level="3" line="358" source="functional/input/standalone_rst_pseudoxml.txt" type="ERROR">
+ <system_message backrefs="id81" ids="id80" level="3" line="359" source="functional/input/standalone_rst_pseudoxml.txt" type="ERROR">
<paragraph>
Unknown target name: "5".
- <system_message backrefs="id82" ids="id81" level="3" line="367" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id83" ids="id82" level="3" line="368" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Unknown target name: "nonexistent".
- <system_message backrefs="id84" ids="id83" level="3" line="394" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id85" ids="id84" level="3" line="395" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Unknown target name: "hyperlink reference without a target".
- <system_message backrefs="id86" ids="id85" level="3" line="407" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id87" ids="id86" level="3" line="408" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Duplicate target name, cannot be used as a unique reference: "duplicate target names".
diff --git a/test/functional/expected/standalone_rst_s5_html_1.html b/test/functional/expected/standalone_rst_s5_html_1.html
index b458449e1..7d9df9f36 100644
--- a/test/functional/expected/standalone_rst_s5_html_1.html
+++ b/test/functional/expected/standalone_rst_s5_html_1.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Slide Shows</title>
<meta name="author" content="David Goodger" />
@@ -71,10 +71,10 @@
<div class="contents handout topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
-<li><a class="reference" href="#introduction" id="id1">Introduction</a></li>
-<li><a class="reference" href="#features-1" id="id2">Features (1)</a></li>
-<li><a class="reference" href="#features-2" id="id3">Features (2)</a></li>
-<li><a class="reference" href="#checklist" id="id4">Checklist</a></li>
+<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
+<li><a class="reference internal" href="#features-1" id="id2">Features (1)</a></li>
+<li><a class="reference internal" href="#features-2" id="id3">Features (2)</a></li>
+<li><a class="reference internal" href="#checklist" id="id4">Checklist</a></li>
</ul>
</div>
<p class="handout">This is a test. This is only a test. If this were a real slide
diff --git a/test/functional/expected/standalone_rst_s5_html_2.html b/test/functional/expected/standalone_rst_s5_html_2.html
index ff5a957f0..f02dc1927 100644
--- a/test/functional/expected/standalone_rst_s5_html_2.html
+++ b/test/functional/expected/standalone_rst_s5_html_2.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Slide Shows</title>
<meta name="author" content="David Goodger" />
@@ -67,10 +67,10 @@
<div class="contents handout topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
-<li><a class="reference" href="#introduction" id="id1">Introduction</a></li>
-<li><a class="reference" href="#features-1" id="id2">Features (1)</a></li>
-<li><a class="reference" href="#features-2" id="id3">Features (2)</a></li>
-<li><a class="reference" href="#checklist" id="id4">Checklist</a></li>
+<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
+<li><a class="reference internal" href="#features-1" id="id2">Features (1)</a></li>
+<li><a class="reference internal" href="#features-2" id="id3">Features (2)</a></li>
+<li><a class="reference internal" href="#checklist" id="id4">Checklist</a></li>
</ul>
</div>
<p class="handout">This is a test. This is only a test. If this were a real slide
diff --git a/test/functional/input/data/standard.txt b/test/functional/input/data/standard.txt
index a7e7a9b41..7e63afd69 100644
--- a/test/functional/input/data/standard.txt
+++ b/test/functional/input/data/standard.txt
@@ -338,8 +338,9 @@ Footnotes
.. [#label] Footnotes may be numbered, either manually (as in [1]_) or
automatically using a "#"-prefixed label. This footnote has a
label so it can be referred to from multiple places, both as a
- footnote reference ([#label]_) and as a hyperlink reference
- (label_).
+ footnote reference ([#label]_) and as a `hyperlink reference`__.
+
+ __ label_
.. [#] This footnote is numbered automatically and anonymously using a
label of "#" only.
diff --git a/test/functional/tests/standalone_rst_html4css1.py b/test/functional/tests/standalone_rst_html4css1.py
index c34298eab..9f80e6d79 100644
--- a/test/functional/tests/standalone_rst_html4css1.py
+++ b/test/functional/tests/standalone_rst_html4css1.py
@@ -1,4 +1,4 @@
-execfile('functional/tests/_standalone_rst_defaults.py')
+exec(open('functional/tests/_standalone_rst_defaults.py').read())
# Source and destination file names.
test_source = "standalone_rst_html4css1.txt"
diff --git a/test/functional/tests/standalone_rst_latex.py b/test/functional/tests/standalone_rst_latex.py
index f0c40b75a..39a5e1e5e 100644
--- a/test/functional/tests/standalone_rst_latex.py
+++ b/test/functional/tests/standalone_rst_latex.py
@@ -1,4 +1,4 @@
-execfile('functional/tests/_standalone_rst_defaults.py')
+exec(open('functional/tests/_standalone_rst_defaults.py').read())
# Source and destination file names.
test_source = "standalone_rst_latex.txt"
diff --git a/test/functional/tests/standalone_rst_pseudoxml.py b/test/functional/tests/standalone_rst_pseudoxml.py
index b9b2df309..7f9b06f04 100644
--- a/test/functional/tests/standalone_rst_pseudoxml.py
+++ b/test/functional/tests/standalone_rst_pseudoxml.py
@@ -1,4 +1,4 @@
-execfile('functional/tests/_standalone_rst_defaults.py')
+exec(open('functional/tests/_standalone_rst_defaults.py').read())
# Source and destination file names.
test_source = "standalone_rst_pseudoxml.txt"
diff --git a/test/functional/tests/standalone_rst_s5_html_1.py b/test/functional/tests/standalone_rst_s5_html_1.py
index ce27f687a..9939ad688 100755
--- a/test/functional/tests/standalone_rst_s5_html_1.py
+++ b/test/functional/tests/standalone_rst_s5_html_1.py
@@ -1,4 +1,4 @@
-execfile('functional/tests/_standalone_rst_defaults.py')
+exec(open('functional/tests/_standalone_rst_defaults.py').read())
# Source and destination file names:
test_source = 'standalone_rst_s5_html.txt'
diff --git a/test/functional/tests/standalone_rst_s5_html_2.py b/test/functional/tests/standalone_rst_s5_html_2.py
index aea7a9207..385558ac3 100755
--- a/test/functional/tests/standalone_rst_s5_html_2.py
+++ b/test/functional/tests/standalone_rst_s5_html_2.py
@@ -1,5 +1,5 @@
# initialize with the settings & definitions from test 1:
-execfile('functional/tests/standalone_rst_s5_html_1.py')
+exec(open('functional/tests/standalone_rst_s5_html_1.py').read())
# overrides specific to this test:
test_destination = 'standalone_rst_s5_html_2.html'
diff --git a/test/test_dependencies.py b/test/test_dependencies.py
index e24079679..c9463b440 100755
--- a/test/test_dependencies.py
+++ b/test/test_dependencies.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
@@ -28,7 +28,7 @@ class RecordDependenciesTests(unittest.TestCase):
settings.setdefault('settings_overrides', {})
settings['settings_overrides'] = settings['settings_overrides'].copy()
settings['settings_overrides']['_disable_config'] = 1
- if not settings['settings_overrides'].has_key('record_dependencies'):
+ if 'record_dependencies' not in settings['settings_overrides']:
settings['settings_overrides']['record_dependencies'] = \
docutils.utils.DependencyList(recordfile)
docutils.core.publish_file(destination=DocutilsTestSupport.DevNull(),
diff --git a/test/test_functional.py b/test/test_functional.py
index 1297fff57..d2dff949d 100755
--- a/test/test_functional.py
+++ b/test/test_functional.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
@@ -92,12 +92,13 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase):
namespace['settings_overrides'] = {'_disable_config': 1}
# Read the variables set in the default config file and in
# the current config file into namespace:
- execfile(join_path(datadir, 'tests', '_default.py'), namespace)
- execfile(self.configfile, namespace)
+ defaultpy = open(join_path(datadir, 'tests', '_default.py')).read()
+ exec(defaultpy, namespace)
+ exec(open(self.configfile).read(), namespace)
# Check for required settings:
- assert namespace.has_key('test_source'),\
+ assert 'test_source' in namespace,\
"No 'test_source' supplied in " + self.configfile
- assert namespace.has_key('test_destination'),\
+ assert 'test_destination' in namespace,\
"No 'test_destination' supplied in " + self.configfile
# Set source_path and destination_path if not given:
namespace.setdefault('source_path',
@@ -151,7 +152,7 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase):
print >>sys.stderr, diff
raise
# Execute optional function containing extra tests:
- if namespace.has_key('_test_more'):
+ if '_test_more' in namespace:
namespace['_test_more'](join_path(datadir, 'expected'),
join_path(datadir, 'output'),
self, namespace)
diff --git a/test/test_io.py b/test/test_io.py
index e2430b37d..dfcd0f3c7 100755
--- a/test/test_io.py
+++ b/test/test_io.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_language.py b/test/test_language.py
index 3f929bd05..6fd0ee546 100755
--- a/test/test_language.py
+++ b/test/test_language.py
@@ -76,10 +76,10 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
missing = [] # in ref but not in l.
too_much = [] # in l but not in ref.
for label in ref_dict.keys():
- if not l_dict.has_key(label):
+ if label not in l_dict:
missing.append(label)
for label in l_dict.keys():
- if not ref_dict.has_key(label):
+ if label not in ref_dict:
too_much.append(label)
return (missing, too_much)
@@ -140,7 +140,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
canonical.sort()
canonical.remove('restructuredtext-test-directive')
for name in canonical:
- if not inverted.has_key(name):
+ if name not in inverted:
failures.append('"%s": translation missing' % name)
if failures:
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
@@ -175,7 +175,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
canonical.sort()
canonical.remove('restructuredtext-unimplemented-role')
for name in canonical:
- if not inverted.has_key(name):
+ if name not in inverted:
failures.append('"%s": translation missing' % name)
if failures:
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
diff --git a/test/test_nodes.py b/test/test_nodes.py
index 5c419f09b..ff6aac940 100755
--- a/test/test_nodes.py
+++ b/test/test_nodes.py
@@ -21,7 +21,7 @@ class TextTests(unittest.TestCase):
def setUp(self):
self.text = nodes.Text('Line 1.\nLine 2.')
- self.unicode_text = nodes.Text(u'Möhren')
+ self.unicode_text = nodes.Text(unicode('Möhren', 'utf8'))
def test_repr(self):
self.assertEquals(repr(self.text), r"<#text: 'Line 1.\nLine 2.'>")
@@ -30,7 +30,7 @@ class TextTests(unittest.TestCase):
self.assertEquals(str(self.text), 'Line 1.\nLine 2.')
def test_unicode(self):
- self.assertEquals(unicode(self.unicode_text), u'Möhren')
+ self.assertEquals(unicode(self.unicode_text), unicode('Möhren', 'utf8'))
self.assertEquals(str(self.unicode_text), 'M\xf6hren')
def test_astext(self):
@@ -39,6 +39,10 @@ class TextTests(unittest.TestCase):
def test_pformat(self):
self.assertEquals(self.text.pformat(), 'Line 1.\nLine 2.\n')
+ def test_asciirestriction(self):
+ self.assertRaises(UnicodeError, nodes.Text, 'hol%s' % chr(224))
+ # more specifically: UnicodeDecodeError since py2.3
+
class ElementTests(unittest.TestCase):
@@ -91,7 +95,7 @@ class ElementTests(unittest.TestCase):
def test_normal_attributes(self):
element = nodes.Element()
- self.assert_(not element.has_key('foo'))
+ self.assert_('foo' not in element)
self.assertRaises(KeyError, element.__getitem__, 'foo')
element['foo'] = 'sometext'
self.assertEquals(element['foo'], 'sometext')
@@ -163,8 +167,10 @@ class ElementTests(unittest.TestCase):
self.assertEquals(len(parent), 5)
def test_unicode(self):
- node = nodes.Element(u'Möhren', nodes.Text(u'Möhren', u'Möhren'))
- self.assertEquals(unicode(node), u'<Element>Möhren</Element>')
+ node = nodes.Element(u'Möhren', nodes.Text(unicode('Möhren', 'utf8'),
+ unicode('Möhren', 'utf8')))
+ self.assertEquals(unicode(node), unicode('<Element>Möhren</Element>',
+ 'utf8'))
class MiscTests(unittest.TestCase):
@@ -173,7 +179,7 @@ class MiscTests(unittest.TestCase):
node_class_names = []
for x in dir(nodes):
c = getattr(nodes, x)
- if isinstance(c, ClassType) and issubclass(c, nodes.Node) \
+ if isinstance(c, (type, ClassType)) and issubclass(c, nodes.Node) \
and len(c.__bases__) > 1:
node_class_names.append(x)
node_class_names.sort()
diff --git a/test/test_parsers/test_parser.py b/test/test_parsers/test_parser.py
new file mode 100644
index 000000000..1d684bdad
--- /dev/null
+++ b/test/test_parsers/test_parser.py
@@ -0,0 +1,31 @@
+#! /usr/bin/env python
+
+# $Id$
+# Author: Stefan Rank <strank(AT)strank(DOT)info>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for basic functionality of parser classes.
+"""
+
+import unittest
+import DocutilsTestSupport # must be imported before docutils
+import docutils
+from docutils import parsers, utils, frontend
+
+
+
+class RstParserTests(unittest.TestCase):
+
+ def test_inputrestrictions(self):
+ parser_class = parsers.get_parser_class('rst')
+ parser = parser_class()
+ document = utils.new_document('test data', frontend.OptionParser(
+ components=(parser, )).get_default_values())
+
+ self.assertRaises(UnicodeError, # UnicodeDecodeError since py2.3
+ parser.parse, 'hol%s' % chr(224), document)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/test_parsers/test_rst/test_citations.py b/test/test_parsers/test_rst/test_citations.py
index d17fd56d3..09f7cef81 100755
--- a/test/test_parsers/test_rst/test_citations.py
+++ b/test/test_parsers/test_rst/test_citations.py
@@ -129,6 +129,51 @@ No blank line.
<comment xml:space="preserve">
[*citationlabelwithmarkup*] this isn't a citation
"""],
+["""
+isolated internals : ``.-_``.
+
+.. [citation.withdot] one dot
+
+.. [citation-withdot] one hyphen
+
+.. [citation_withunderscore] one underscore
+
+.. [citation:with:colons] two colons
+
+.. [citation+withplus] one plus
+""",
+"""<document source="test data">
+ <paragraph>
+ isolated internals : \n\
+ <literal>
+ .-_
+ .
+ <citation ids="citation-withdot" names="citation.withdot">
+ <label>
+ citation.withdot
+ <paragraph>
+ one dot
+ <citation ids="id1" names="citation-withdot">
+ <label>
+ citation-withdot
+ <paragraph>
+ one hyphen
+ <citation ids="citation-withunderscore" names="citation_withunderscore">
+ <label>
+ citation_withunderscore
+ <paragraph>
+ one underscore
+ <citation ids="citation-with-colons" names="citation:with:colons">
+ <label>
+ citation:with:colons
+ <paragraph>
+ two colons
+ <citation ids="citation-withplus" names="citation+withplus">
+ <label>
+ citation+withplus
+ <paragraph>
+ one plus
+"""],
]
diff --git a/test/test_parsers/test_rst/test_directives/test_block_quotes.py b/test/test_parsers/test_rst/test_directives/test_block_quotes.py
index d56f49e3d..5faf2c008 100755
--- a/test/test_parsers/test_rst/test_directives/test_block_quotes.py
+++ b/test/test_parsers/test_rst/test_directives/test_block_quotes.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_parsers/test_rst/test_directives/test_class.py b/test/test_parsers/test_rst/test_directives/test_class.py
index 9cdd8c432..474a01903 100755
--- a/test/test_parsers/test_rst/test_directives/test_class.py
+++ b/test/test_parsers/test_rst/test_directives/test_class.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_parsers/test_rst/test_directives/test_images.py b/test/test_parsers/test_rst/test_directives/test_images.py
index 1ce24d4a4..7c8fa2299 100755
--- a/test/test_parsers/test_rst/test_directives/test_images.py
+++ b/test/test_parsers/test_rst/test_directives/test_images.py
@@ -385,7 +385,7 @@ u"""\
<system_message level="3" line="1" source="test data" type="ERROR">
<paragraph>
Error in "image" directive:
- invalid option value: (option: "align"; value: u\'\\xe4\')
+ invalid option value: (option: "align"; value: \'\\xe4\')
"\xe4" unknown; choose from "top", "middle", "bottom", "left", "center", or "right".
<literal_block xml:space="preserve">
.. image:: picture.png
diff --git a/test/test_parsers/test_rst/test_directives/test_parsed_literals.py b/test/test_parsers/test_rst/test_directives/test_parsed_literals.py
index be6b9aabc..50b8303bf 100755
--- a/test/test_parsers/test_rst/test_directives/test_parsed_literals.py
+++ b/test/test_parsers/test_rst/test_directives/test_parsed_literals.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_parsers/test_rst/test_directives/test_raw.py b/test/test_parsers/test_rst/test_directives/test_raw.py
index 63cee274f..1e2d9c5ca 100755
--- a/test/test_parsers/test_rst/test_directives/test_raw.py
+++ b/test/test_parsers/test_rst/test_directives/test_raw.py
@@ -122,12 +122,12 @@ Raw input file is UTF-16-encoded, and is not valid ASCII.
:file: %s
:encoding: ascii
""" % utf_16_file_rel],
-["""\
+[unicode("""\
.. raw:: html
:encoding: utf-8
Should the parser complain becau\xdfe there is no :file:? BUG?
-""",
+""", 'iso-8859-1'),
"""\
<document source="test data">
<raw format="html" xml:space="preserve">
@@ -153,11 +153,11 @@ Raw input file is UTF-16-encoded, and is not valid ASCII.
<system_message level="4" line="1" source="test data" type="SEVERE">
<paragraph>
Problems with "raw" directive path:
- [Errno 2] No such file or directory: 'non-existent.file'.
+ [Errno 2] No such file or directory: u'non-existent.file'.
<literal_block xml:space="preserve">
.. raw:: html
:file: non-existent.file
-"""],
+"""], # note that this output is rewritten below for certain python versions
]
# Skip tests whose output contains "UnicodeDecodeError" if we are not
@@ -171,6 +171,16 @@ if sys.version_info < (2, 3):
# Assume we have only one of these tests.
break
+# Rewrite tests that depend on the output of IOError as it is
+# platform-dependent before python 2.4 for a unicode path.
+if sys.version_info < (2, 4):
+ # remove the unicode repr u except for py2.3 on windows:
+ if not sys.platform.startswith('win') or sys.version_info < (2, 3):
+ for i in range(len(totest['raw'])):
+ if totest['raw'][i][1].find("u'non-existent.file'") != -1:
+ totest['raw'][i][1] = totest['raw'][i][1].replace(
+ "u'non-existent.file'", "'non-existent.file'")
+
if __name__ == '__main__':
import unittest
diff --git a/test/test_parsers/test_rst/test_directives/test_sectnum.py b/test/test_parsers/test_rst/test_directives/test_sectnum.py
index 8b4b26ca0..adff92b32 100755
--- a/test/test_parsers/test_rst/test_directives/test_sectnum.py
+++ b/test/test_parsers/test_rst/test_directives/test_sectnum.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py
index 19c8ef6f2..d97516767 100755
--- a/test/test_parsers/test_rst/test_directives/test_tables.py
+++ b/test/test_parsers/test_rst/test_directives/test_tables.py
@@ -37,12 +37,12 @@ else:
null_bytes_code = """
import csv
import cStringIO
-csv_data = open('%s', 'rb').read().decode('latin-1')
+csv_data = open('%s', 'rb').read()
csv_file = cStringIO.StringIO(csv_data)
reader = csv.reader(csv_file)
reader.next()
""" % utf_16_csv
-null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes_code)[1][0]
+null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes_code)[0]
totest = {}
@@ -562,11 +562,11 @@ u"""\
<system_message level="4" line="1" source="test data" type="SEVERE">
<paragraph>
Problems with "csv-table" directive path:
- [Errno 2] No such file or directory: 'bogus.csv'.
+ [Errno 2] No such file or directory: u'bogus.csv'.
<literal_block xml:space="preserve">
.. csv-table:: no such file
:file: bogus.csv
-"""],
+"""], # note that this output is rewritten below for certain python versions
["""\
.. csv-table:: bad URL
:url: bogus.csv
@@ -1074,6 +1074,18 @@ totest['list-table'] = [
]
+if csv:
+ # Rewrite csv tests that depend on the output of IOError as it is
+ # platform-dependent before python 2.4 for a unicode path.
+ # Here only needed for python 2.3 on non-windows
+ import sys
+ if sys.version_info < (2, 4) and not sys.platform.startswith('win'):
+ for i in range(len(totest['csv-table'])):
+ if totest['csv-table'][i][1].find("u'bogus.csv'") != -1:
+ totest['csv-table'][i][1] = totest['csv-table'][i][1].replace(
+ "u'bogus.csv'", "'bogus.csv'")
+
+
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_title.py b/test/test_parsers/test_rst/test_directives/test_title.py
index d8c5743cb..c76a8c0ef 100755
--- a/test/test_parsers/test_rst/test_directives/test_title.py
+++ b/test/test_parsers/test_rst/test_directives/test_title.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_publisher.py b/test/test_publisher.py
index 45427d532..b532229b0 100755
--- a/test/test_publisher.py
+++ b/test/test_publisher.py
@@ -37,7 +37,7 @@ pseudoxml_output = """\
Unknown target name: "nonexistent".
"""
exposed_pseudoxml_output = """\
-<document ids="test-document" internal:refnames="{u\'nonexistent\': [<reference: <#text: u\'nonexistent\'>>]}" names="test\ document" source="<string>" title="Test Document">
+<document ids="test-document" internal:refnames="{u\'nonexistent\': [<reference: <#text: \'nonexistent\'>>]}" names="test\ document" source="<string>" title="Test Document">
<title>
Test Document
<paragraph>
diff --git a/test/test_settings.py b/test/test_settings.py
index 2cf4e080c..fb050b2ad 100755
--- a/test/test_settings.py
+++ b/test/test_settings.py
@@ -92,8 +92,8 @@ class ConfigFileTests(unittest.TestCase):
def compare_output(self, result, expected):
"""`result` and `expected` should both be dicts."""
- self.assert_(result.has_key('record_dependencies'))
- if not expected.has_key('record_dependencies'):
+ self.assert_('record_dependencies' in result)
+ if 'record_dependencies' not in expected:
# Delete it if we don't want to test it.
del result['record_dependencies']
result = pprint.pformat(result) + '\n'
diff --git a/test/test_transforms/test___init__.py b/test/test_transforms/test___init__.py
index be7c3df4a..ce4cd9ec5 100755
--- a/test/test_transforms/test___init__.py
+++ b/test/test_transforms/test___init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_transforms/test_expose_internals.py b/test/test_transforms/test_expose_internals.py
index f9bdfa278..c3af79573 100755
--- a/test/test_transforms/test_expose_internals.py
+++ b/test/test_transforms/test_expose_internals.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_transforms/test_writer_aux.py b/test/test_transforms/test_writer_aux.py
index b058dcfc8..a14e6074f 100755
--- a/test/test_transforms/test_writer_aux.py
+++ b/test/test_transforms/test_writer_aux.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_utils.py b/test/test_utils.py
index 9461ca248..9f0eda54b 100755
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -172,12 +172,14 @@ class ExtensionOptionTests(unittest.TestCase):
nodes.field_body('', nodes.paragraph('', '2.0')))
field_list += nodes.field(
'', nodes.field_name('', 'cdef'),
- nodes.field_body('', nodes.paragraph('', 'hol%s' % chr(224))))
+ nodes.field_body('', nodes.paragraph('',
+ unicode('hol%s' % chr(224), 'iso-8859-1'))))
field_list += nodes.field(
'', nodes.field_name('', 'empty'), nodes.field_body())
self.assertEquals(
utils.extract_extension_options(field_list, self.optionspec),
- {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224)),
+ {'a': 1, 'bbb': 2.0,
+ 'cdef': unicode('hol%s' % chr(224), 'iso-8859-1'),
'empty': None})
self.assertRaises(KeyError, utils.extract_extension_options,
field_list, {})
diff --git a/test/test_writers/test_docutils_xml.py b/test/test_writers/test_docutils_xml.py
index 3362b4222..987fec957 100755
--- a/test/test_writers/test_docutils_xml.py
+++ b/test/test_writers/test_docutils_xml.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_writers/test_html4css1_misc.py b/test/test_writers/test_html4css1_misc.py
index e94cad828..2013f102c 100755
--- a/test/test_writers/test_html4css1_misc.py
+++ b/test/test_writers/test_html4css1_misc.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_writers/test_html4css1_parts.py b/test/test_writers/test_html4css1_parts.py
index add7a2d39..eb3664682 100755
--- a/test/test_writers/test_html4css1_parts.py
+++ b/test/test_writers/test_html4css1_parts.py
@@ -61,9 +61,9 @@ A simple `anonymous reference`__
__ http://www.test.com/test_url
""",
"""\
-{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
'html_body': '''<div class="document">
-<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
</div>\\n''',
'html_head': '''...<title></title>\\n'''}
"""],
@@ -88,10 +88,10 @@ reference and the target.
.. _`named reference`: http://www.test.com/test_url
""",
"""\
-{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
reference and the target.</p>\\n''',
'html_body': '''<div class="document">
-<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
reference and the target.</p>
</div>\\n''',
'html_head': '''...<title></title>\\n'''}
@@ -223,9 +223,9 @@ A simple `anonymous reference`__
__ http://www.test.com/test_url
""",
"""\
-{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
'html_body': '''<div class="document">
-<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
</div>\\n''',
'html_head': '''...<title></title>\\n'''}
"""],
@@ -236,10 +236,10 @@ reference and the target.
.. _`named reference`: http://www.test.com/test_url
""",
"""\
-{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
reference and the target.</p>\\n''',
'html_body': '''<div class="document">
-<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
reference and the target.</p>
</div>\\n''',
'html_head': '''...<title></title>\\n'''}
diff --git a/test/test_writers/test_html4css1_template.py b/test/test_writers/test_html4css1_template.py
index 98714fde6..24b855eb9 100755
--- a/test/test_writers/test_html4css1_template.py
+++ b/test/test_writers/test_html4css1_template.py
@@ -49,7 +49,7 @@ r'''head_prefix = """\
head = """\
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title>Document Title</title>
<meta name="author" content="Me" />"""
@@ -106,7 +106,7 @@ head_prefix = """\
head = """\
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title>Document Title</title>
<meta name="author" content="Me" />"""
@@ -175,7 +175,7 @@ footer text
meta = """\
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<meta name="author" content="Me" />"""
@@ -193,7 +193,7 @@ html_prolog = """\
html_head = """\
<meta http-equiv="Content-Type" content="text/html; charset=%s" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title>Document Title</title>
<meta name="author" content="Me" />"""
diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py
index 75349a599..217bff415 100755
--- a/test/test_writers/test_latex2e.py
+++ b/test/test_writers/test_latex2e.py
@@ -36,9 +36,8 @@ latex_head = """\
\\usepackage{color}
\\usepackage{multirow}
\\usepackage{ifthen}
-\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\\usepackage[DIV12]{typearea}
-%% generator Docutils: http://docutils.sourceforge.net/
+% generated by Docutils <http://docutils.sourceforge.net/>
\\newlength{\\admonitionwidth}
\\setlength{\\admonitionwidth}{0.9\\textwidth}
\\newlength{\\docinfowidth}
@@ -79,12 +78,32 @@ latex_head = """\
\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}}
\\newcommand{\\titlereference}[1]{\\textsl{#1}}
% end of "some commands"
+\\ifthenelse{\\isundefined{\\hypersetup}}{
+\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+}{}
"""
totest = {}
totest_latex_toc = {}
totest_latex_citations = {}
+totest['url_chars'] = [
+["http://nowhere/url_with%28parens%29",
+latex_head + """\
+\\title{}
+\\author{}
+\\date{}
+\\raggedbottom
+\\begin{document}
+
+\\setlength{\\locallinewidth}{\\linewidth}
+
+\\href{http://nowhere/url_with\\%28parens\\%29}{http://nowhere/url{\\_}with{\\%}28parens{\\%}29}
+
+\\end{document}
+"""],
+]
+
totest['table_of_contents'] = [
# input
["""\
@@ -432,7 +451,8 @@ latex_head + """\
\\setlength{\\locallinewidth}{\\linewidth}
-\\begin{longtable}[c]{|p{0.07\locallinewidth}|p{0.07\locallinewidth}|}
+\\leavevmode
+\\begin{longtable}[c]{|p{0.075\locallinewidth}|p{0.075\locallinewidth}|}
\\caption{Foo}\\\\
\\hline
& \\\\
@@ -466,7 +486,8 @@ latex_head + """\
\\setlength{\\locallinewidth}{\\linewidth}
-\\begin{longtable}[c]{p{0.07\locallinewidth}p{0.07\locallinewidth}}
+\\leavevmode
+\\begin{longtable}[c]{p{0.075\locallinewidth}p{0.075\locallinewidth}}
1
&
diff --git a/test/test_writers/test_null.py b/test/test_writers/test_null.py
index 5c24fa4b6..c5203859e 100755
--- a/test/test_writers/test_null.py
+++ b/test/test_writers/test_null.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_writers/test_pseudoxml.py b/test/test_writers/test_pseudoxml.py
index 97b9dce08..11d8210d7 100755
--- a/test/test_writers/test_pseudoxml.py
+++ b/test/test_writers/test_pseudoxml.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
diff --git a/test/test_writers/test_s5.py b/test/test_writers/test_s5.py
index 70a3988f1..8f4a26b8e 100755
--- a/test/test_writers/test_s5.py
+++ b/test/test_writers/test_s5.py
@@ -43,7 +43,7 @@ Slide text.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Show Title</title>
<link rel="stylesheet" href="../docutils/writers/html4css1/html4css1.css" type="text/css" />
@@ -108,7 +108,7 @@ We're just checking the settings
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Bogus Slide Show</title>
<link rel="stylesheet" href="../docutils/writers/html4css1/html4css1.css" type="text/css" />
diff --git a/tools/dev/create_unimap.py b/tools/dev/create_unimap.py
index 2415be786..0f733c69f 100755
--- a/tools/dev/create_unimap.py
+++ b/tools/dev/create_unimap.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This file has been placed in the public domain.
# Call: create_unimap.py < unicode.xml > unicode_latex.py
@@ -64,7 +64,7 @@ unicode_map.update(text_map)
# entries for those chars for which no text entry exists.
print '# $%s$' % 'Id'
-print '# Author: Felix Wiemann <Felix.Wiemann@ososo.de>'
+print '# Author: Lea Wiemann <LeWiemann@gmail.com>'
print '# Copyright: This file has been placed in the public domain.'
print
print '# This is a mapping of Unicode characters to LaTeX equivalents.'
diff --git a/tools/dev/profile_docutils.py b/tools/dev/profile_docutils.py
index e06848371..90b083787 100755
--- a/tools/dev/profile_docutils.py
+++ b/tools/dev/profile_docutils.py
@@ -1,7 +1,7 @@
#!/usr/bin/python -i
# $Id$
-# Author: Felix Wiemann <Felix.Wiemann@ososo.de>
+# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This script has been placed in the public domain.
import os.path
@@ -34,6 +34,6 @@ stats.sort_stats('time')
stats.print_stats(40)
try:
- execfile(os.environ['PYTHONSTARTUP'])
+ exec(open(os.environ['PYTHONSTARTUP']).read())
except:
pass
diff --git a/tools/dev/unicode2rstsubs.py b/tools/dev/unicode2rstsubs.py
index 9161e10c1..22ac07ecc 100755
--- a/tools/dev/unicode2rstsubs.py
+++ b/tools/dev/unicode2rstsubs.py
@@ -129,11 +129,11 @@ class CharacterEntitySetExtractor:
set = self.entity_set_name(attributes['set'])
if not set:
return
- if not self.sets.has_key(set):
+ if set not in self.sets:
print 'bad set: %r' % set
return
entity = attributes['id']
- assert (not self.sets[set].has_key(entity)
+ assert (entity not in self.sets[set]
or self.sets[set][entity] == self.charid), \
('sets[%r][%r] == %r (!= %r)'
% (set, entity, self.sets[set][entity], self.charid))
diff --git a/tools/editors/emacs/README.txt b/tools/editors/emacs/README.txt
index 2c3e32ce5..8c35a2490 100644
--- a/tools/editors/emacs/README.txt
+++ b/tools/editors/emacs/README.txt
@@ -8,13 +8,14 @@
This directory contains the following Emacs lisp package files:
-* rst.el: Emacs support for reStructuredText_. This file contains
+* rst.el: Emacs support for reStructuredText_. This file contains a
+ major mode that provides:
* Section decoration/adornment creation and updating (M. Blais);
* Table-of-contents mode and insertion (M. Blais);
* Font-lock syntax highlighting (S. Merten);
* Some handy editing functions (D. Goodger).
- * Some functions for converting documents from emacs (M. Blais).
+ * Some functions for converting rest documents from within emacs (M. Blais).
* tests subdirectory: automated tests for some of the features in rst.el.
Please make sure the tests pass if you change the LISP code. Just type "make"
diff --git a/tools/editors/emacs/rst.el b/tools/editors/emacs/rst.el
index 69ed23a9a..6caa77819 100644
--- a/tools/editors/emacs/rst.el
+++ b/tools/editors/emacs/rst.el
@@ -1,12 +1,10 @@
-;;; rst.el --- ReStructuredText Support for Emacs
+;;; rst.el --- Mode for viewing and editing reStructuredText-documents.
-;; Copyright 2003-2006 by Martin Blais, Stefan Merten, and David Goodger.
+;; Copyright 2003-2008 by Martin Blais, Stefan Merten, and David Goodger.
;; Authors: Martin Blais <blais@furius.ca>,
;; Stefan Merten <smerten@oekonux.de>,
;; David Goodger <goodger@python.org>
-;; Revision: $Revision$
-;; Date: $Date$
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License version 2,
@@ -24,13 +22,11 @@
;;; Commentary:
-;; Support code for editing reStructuredText with Emacs. The latest
-;; version of this file lies in the docutils source code repository.
-;;
-
-;;; Description
-
-;; Basically, this package contains:
+;; This package provides major mode rst-mode, which supports documents marked up
+;; using the reStructuredText format. Support includes font locking as well as
+;; some convenience functions for editing. It does this by defining a Emacs
+;; major mode: rst-mode (ReST). This mode is derived from text-mode (and
+;; inherits much of it). This package also contains:
;;
;; - Functions to automatically adjust and cycle the section underline
;; decorations;
@@ -38,8 +34,7 @@
;; from it;
;; - Functions to insert and automatically update a TOC in your source
;; document;
-;; - A mode which supports font-lock highlighting of reStructuredText
-;; structures;
+;; - Font-lock highlighting of notable reStructuredText structures;
;; - Some other convenience functions.
;;
;; See the accompanying document in the docutils documentation about
@@ -50,290 +45,170 @@
;;
;; For full details on how to use the contents of this file, see
;; http://docutils.sourceforge.net/docs/user/emacs.html
-
-;;; Download
-
-;; Click `Here <rst.el>`_ for download.
-
-;;; Packaging
-
-;; **IMPORTANT NOTE TO PACKAGERS**: this package is the result of merging:
-;;
-;; - restructuredtext.el
-;; - rst-mode.el
-;; - rst-html.el
-;;
-;; Those files are now OBSOLETE and have been replaced by this single package
-;; file (2005-10-30).
-
-;;; Installation instructions
-
-;; Add this line to your .emacs file and bind the versatile sectioning commands
-;; in text mode, like this::
-;;
-;; (require 'rst)
-;; (add-hook 'text-mode-hook 'rst-text-mode-bindings)
-;;
-;; rst-prefix-map is the prefix map for all the functionality provide by this
-;; module. In addition, other shorter bindings are also provided on the
-;; mode-specific-map prefix (i.e C-c).
-;;
;;
-;; C-c p a (also C-=): rst-adjust
;;
-;; Updates or rotates the section title around point or promotes/demotes
-;; the decorations within the region (see full details below).
+;; There are a number of convenient keybindings provided by rst-mode. The main
+;; one is
;;
-;; Note that C-= is a good binding, since it allows you to specify a
-;; negative arg easily with C-- C-= (easy to type), as well as ordinary
-;; prefix arg with C-u C-=.
+;; C-c C-a (also C-=): rst-adjust
;;
-;; C-c p h: rst-display-decorations-hierarchy
+;; Updates or rotates the section title around point or promotes/demotes the
+;; decorations within the region (see full details below). Note that C-= is a
+;; good binding, since it allows you to specify a negative arg easily with C--
+;; C-= (easy to type), as well as ordinary prefix arg with C-u C-=.
;;
-;; Displays the level decorations that are available in the file.
+;; For more on bindings, see rst-mode-map below. There are also many variables
+;; that can be customized, look for defcustom and defvar in this file.
;;
-;; C-c p t: rst-toc
-;;
-;; Displays the hierarchical table-of-contents of the document and allows
-;; you to jump to any section from it.
-;;
-;; C-c p i: rst-toc-insert
-;;
-;; Inserts a table-of-contents in the document at the column where the
-;; cursor is.
-;;
-;; C-c p u: rst-toc-insert-update
+;; If you use the table-of-contents feature, you may want to add a hook to
+;; update the TOC automatically everytime you adjust a section title::
;;
-;; Find an existing inserted table-of-contents in the document an
-;; updates it.
+;; (add-hook 'rst-adjust-hook 'rst-toc-update)
;;
-;; C-c p p, C-c p n (C-c C-p, C-c C-n): rst-backward-section,
-;; rst-forward-section
+;; Syntax highlighting: font-lock is enabled by default. If you want to turn off
+;; syntax highlighting to rst-mode, you can use the following::
;;
-;; Navigate between section titles.
+;; (setq font-lock-global-modes '(not rst-mode ...))
;;
-;; C-c p l, C-c p r (C-c C-l, C-c C-r): rst-shift-region-left,
-;; rst-shift-region-right
+
+
+;; CUSTOMIZATION
;;
-;; Shift the region left or right by two-char increments, which is perfect
-;; for bulleted lists.
+;; rst
+;; ---
+;; This group contains some general customizable features.
;;
+;; The group is contained in the wp group.
;;
-;; Other specialized and more generic functions are also available (see source
-;; code). The most important function provided by this file for section title
-;; adjustments is rst-adjust.
+;; rst-faces
+;; ---------
+;; This group contains all necessary for customizing fonts. The default
+;; settings use standard font-lock-*-face's so if you set these to your
+;; liking they are probably good in rst-mode also.
;;
-;; There are many variables that can be customized, look for defcustom and
-;; defvar in this file.
+;; The group is contained in the faces group as well as in the rst group.
;;
-;; If you use the table-of-contents feature, you may want to add a hook to
-;; update the TOC automatically everytime you adjust a section title::
+;; rst-faces-defaults
+;; ------------------
+;; This group contains all necessary for customizing the default fonts used for
+;; section title faces.
;;
-;; (add-hook 'rst-adjust-hook 'rst-toc-insert-update)
+;; The general idea for section title faces is to have a non-default background
+;; but do not change the background. The section level is shown by the
+;; lightness of the background color. If you like this general idea of
+;; generating faces for section titles but do not like the details this group
+;; is the point where you can customize the details. If you do not like the
+;; general idea, however, you should customize the faces used in
+;; rst-adornment-faces-alist.
;;
-;; rst-mode
-;; --------
+;; Note: If you are using a dark background please make sure the variable
+;; frame-background-mode is set to the symbol dark. This triggers
+;; some default values which are probably right for you.
;;
-;; There is a special mode that you can setup if you want to have syntax
-;; highlighting. The mode is based on `text-mode' and inherits some things from
-;; it. Particularly `text-mode-hook' is run before `rst-mode-hook'.
+;; The group is contained in the rst-faces group.
;;
+;; All customizable features have a comment explaining their meaning. Refer to
+;; the customization of your Emacs (try ``M-x customize``).
+
+
+;;; DOWNLOAD
+
+;; The latest version of this file lies in the docutils source code repository:
+;; http://svn.berlios.de/svnroot/repos/docutils/trunk/docutils/tools/editors/emacs/rst.el
+
+
+;;; INSTALLATION
+
;; Add the following lines to your `.emacs' file:
;;
-;; (setq auto-mode-alist
-;; (append '(("\\.rst$" . rst-mode)
-;; ("\\.rest$" . rst-mode)) auto-mode-alist))
+;; (require 'rst)
;;
;; If you are using `.txt' as a standard extension for reST files as
;; http://docutils.sourceforge.net/FAQ.html#what-s-the-standard-filename-extension-for-a-restructuredtext-file
;; suggests you may use one of the `Local Variables in Files' mechanism Emacs
-;; provides to set the major mode automatically. For instance you may use::
+;; provides to set the major mode automatically. For instance you may use::
;;
;; .. -*- mode: rst -*-
;;
-;; in the very first line of your file. However, because this is a major
-;; security breach you or your administrator may have chosen to switch that
-;; feature off. See `Local Variables in Files' in the Emacs documentation for a
-;; more complete discussion.
+;; in the very first line of your file. The following code is useful if you want
+;; to automatically enter rst-mode from any file with compatible extensions:
+;;
+;; (setq auto-mode-alist
+;; (append '(("\\.txt$" . rst-mode)
+;; ("\\.rst$" . rst-mode)
+;; ("\\.rest$" . rst-mode)) auto-mode-alist))
+;;
;;; BUGS
-;; David: If I try rst-toc-insert in docs/dev/rst/alternatives.txt, it skips the
-;; section 5 title, "... Or Not To Do?". Perhaps it mistakes it for a comment? A
-;; comment requires two periods and a space or newline; three periods is not a
-;; comment.
-
-;; Doing a line block creates two pipes, Wtf, should be one?
+;; - rst-enumeration-region: Select a single paragraph, with the top at one
+;; blank line before the beginning, and it will fail.
+;; - The active region goes away when we shift it left or right, and this
+;; prevents us from refilling it automatically when shifting many times.
+;; - The suggested decorations when adjusting should not have to cycle
+;; below one below the last section decoration level preceding the
+;; cursor. We need to fix that.
-;;; TODO list
+;;; TODO LIST
-;; Bindings
-;; --------
-;; - We need to automatically add the rst-text-mode-bindings to rst-mode
-;; - We need to find better bindings because C-= does not generate an event on
-;; the Macs.
-;;
;; rst-toc-insert features
;; ------------------------
;; - rst-toc-insert: We should parse the contents:: options to figure out how
;; deep to render the inserted TOC.
;; - On load, detect any existing TOCs and set the properties for links.
;; - TOC insertion should have an option to add empty lines.
-;; - TOC insertion should deal with multiple lines
-;;
+;; - TOC insertion should deal with multiple lines.
;; - There is a bug on redo after undo of adjust when rst-adjust-hook uses the
;; automatic toc update. The cursor ends up in the TOC and this is
;; annoying. Gotta fix that.
-;;
;; - numbering: automatically detect if we have a section-numbering directive in
-;; the corresponding section, to render the toc
+;; the corresponding section, to render the toc.
;;
;; bulleted and enumerated list items
;; ----------------------------------
;; - We need to provide way to rebullet bulleted lists, and that would include
;; automatic enumeration as well.
;;
-;; rst-mode
-;; --------
-;; - Look at the possibility of converting rst-mode from a Major mode to a Minor
-;; mode of text-mode.
-;;
;; Other
;; -----
+;; - It would be nice to differentiate between text files using
+;; reStructuredText_ and other general text files. If we had a
+;; function to automatically guess whether a .txt file is following the
+;; reStructuredText_ conventions, we could trigger rst-mode without
+;; having to hard-code this in every text file, nor forcing the user to
+;; add a local mode variable at the top of the file.
+;; We could perform this guessing by searching for a valid decoration
+;; at the top of the document or searching for reStructuredText_
+;; directives further on.
+;;
+;; - We should support imenu in our major mode, with the menu filled with the
+;; section titles (this should be really easy).
+;;
;; - We should rename "adornment" to "decoration" or vice-versa in this
-;; document.
-;; - Add an option to forego using the file structure in order to make
-;; suggestion, and to always use the preferred decorations to do that.
-;; - We need to automatically recenter on rst-forward-section movment commands.
+;; document (Stefan's code ("adornment") vs Martin ("decoration")), maybe some
+;; functions even overlap.
+;;
+;; - We need to automatically recenter on rst-forward-section movement commands.
-;;; History:
+;;; HISTORY
;;
-;;; Code:
+;;; CODE
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Bindings and hooks
-
(defgroup rst nil "Support for reStructuredText documents"
:group 'wp
:version "21.1"
:link '(url-link "http://docutils.sourceforge.net/rst.html"))
-(defun rst-toc-or-hierarchy ()
- "Binding for either TOC or decorations hierarchy."
- (interactive)
- (if (not current-prefix-arg)
- (rst-toc)
- (rst-display-decorations-hierarchy)))
-
-;; Define a prefix map for the long form of key combinations.
-(defvar rst-prefix-map (make-sparse-keymap)
- "Keymap for rst commands.")
-
-(dolist (m '(("a" . rst-adjust)
- ("=" . rst-adjust)
- ("t" . rst-toc)
- ("i" . rst-toc-insert)
- ("+" . rst-toc-insert)
- ("u" . rst-toc-insert-update)
- ("f" . rst-goto-section)
- ;;([return] . rst-goto-section)
- ("h" . rst-display-decorations-hierarchy)
- ("s" . rst-straighten-decorations)
- ("w" . rst-straighten-bullets-region)
- ("b" . rst-listify-region)
- ("e" . rst-enumerate-region)
- ("p" . rst-backward-section)
- ("n" . rst-forward-section)
- ("m" . rst-mark-section)
- ("r" . rst-shift-region-right)
- ("l" . rst-shift-region-left)
- ("v" . rst-convert-bullets-to-enumeration)
- ("B" . rst-line-block-region)
- ("c" . rst-compile)
- ("C" . rst-compile-alt-toolset)
- ("x" . rst-compile-pseudo-region)
- ("q" . rst-compile-pdf-preview)
- ("Q" . rst-compile-slides-preview)
- ))
- (define-key rst-prefix-map (car m) (cdr m)))
-
-(defun rst-text-mode-bindings ()
- "Default text mode hook for rest."
-
- ;; Direct command (somehow this one does not work on the Mac).
- (local-set-key [(control ?=)] 'rst-adjust)
-
- (define-key mode-specific-map [(control p)] 'rst-backward-section)
- (define-key mode-specific-map [(control n)] 'rst-forward-section)
- (define-key mode-specific-map [(control r)] 'rst-shift-region-right)
- (define-key mode-specific-map [(control l)] 'rst-shift-region-left)
-
- ;; Bind the rst commands on the C-c p prefix.
- (define-key mode-specific-map [(p)] rst-prefix-map)
-
- ;; Set comment syntax in text-mode to a ReST comment.
- (when (or (eq major-mode 'text-mode)
- (eq major-mode 'rst-mode))
- (set (make-local-variable 'comment-start) ".. "))
- )
-
-
-;; Note: we cannot bind the TOC update on file write because it messes with
-;; undo. If we disable undo, since it adds and removes characters, the
-;; positions in the undo list are not making sense anymore. Dunno what to do
-;; with this, it would be nice to update when saving.
-;;
-;; (add-hook 'write-contents-hooks 'rst-toc-insert-update-fun)
-;; (defun rst-toc-insert-update-fun ()
-;; ;; Disable undo for the write file hook.
-;; (let ((buffer-undo-list t)) (rst-toc-insert-update) ))
-
-
-;; Additional abbreviations for text-mode.
-(define-abbrev text-mode-abbrev-table
- "con" ".. contents::\n..\n " nil 0)
-
-
-;; Bulleted item lists.
-(defvar rst-bullets
- '(?- ?* ?+)
- "List of all possible bullet characters for bulleted lists.")
-
-;; Paragraph separation customization. This will work better for
-;; bullet and enumerated lists in restructuredtext documents and
-;; should not affect filling for other documents too much. Set it up
-;; like this:
-;;
-;; (add-hook 'text-mode-hook 'rst-set-paragraph-separation)
-(defvar rst-extra-paragraph-start
- (format "\\|[ \t]*\\(%s \\|[0-9]+\\. \\)"
- (regexp-opt (mapcar 'char-to-string rst-bullets)))
- "Extra parapraph-separate patterns to add for `text-mode'.")
-;; FIXME: What about the missing >?
-;; The author uses a hardcoded for paragraph-separate: "\f\\|>*[ \t]*$"
-
-(defun rst-set-paragraph-separation ()
- "Set the paragraph separation for restructuredtext."
- ;; FIXME: the variable should be made automatically buffer local rather than
- ;; using a function here, this function is unnecessary.
- (make-local-variable 'paragraph-start) ; prevent it growing every time
- (setq paragraph-start (concat paragraph-start rst-extra-paragraph-start)))
-
-;; FIXME: What about paragraph-separate? paragraph-start and paragraph-separate
-;; are different. The author hardcodes the value to
-;; "\f\\|>*[ \t]*$\\|>*[ \t]*[-+*] \\|>*[ \t]*[0-9#]+\\. "
-
-;; FIXME: the variables above are in limbo and need some fixing.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Support functions
+;; Define some generic support functions.
-(require 'cl)
+(require 'cl) ;; We need this for destructuring-bind below.
;; Generic Filter function.
(unless (fboundp 'filter)
@@ -364,6 +239,227 @@ is for which (pred elem) is true)"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Mode definition.
+
+(defconst rst-use-unicode
+ (string-equal "\u0020" " ")
+ "Non-nil if we can use unicode characters.")
+
+;; Key bindings.
+(defvar rst-mode-map
+ (let ((map (make-sparse-keymap)))
+
+ ;;
+ ;; Section Decorations.
+ ;;
+ ;; The adjustment function that decorates or rotates a section title.
+ (define-key map [(control c) (control a)] 'rst-adjust)
+ (define-key map [(control c) (control ?=)] 'rst-adjust)
+ (define-key map [(control ?=)] 'rst-adjust) ;; (Does not work on the Mac OSX.)
+ ;; Display the hierarchy of decorations implied by the current document contents.
+ (define-key map [(control c) (control h)] 'rst-display-decorations-hierarchy)
+ ;; Homogeneize the decorations in the document.
+ (define-key map [(control c) (control s)] 'rst-straighten-decorations)
+;; (define-key map [(control c) (control s)] 'rst-straighten-deco-spacing)
+
+ ;;
+ ;; Section Movement and Selection.
+ ;;
+ ;; Mark the subsection where the cursor is.
+ (define-key map [(control c) (control m)] 'rst-mark-section)
+ ;; Move forward/backward between section titles.
+ (define-key map [(control c) (control n)] 'rst-forward-section)
+ (define-key map [(control c) (control p)] 'rst-backward-section)
+
+ ;;
+ ;; Operating on Blocks of Text.
+ ;;
+ ;; Makes paragraphs in region as a bullet list.
+ (define-key map [(control c) (control b)] 'rst-bullet-list-region)
+ ;; Makes paragraphs in region as a enumeration.
+ (define-key map [(control c) (control e)] 'rst-enumerate-region)
+ ;; Converts bullets to an enumeration.
+ (define-key map [(control c) (control v)] 'rst-convert-bullets-to-enumeration)
+ ;; Makes region a line-block.
+ (define-key map [(control c) (control d)] 'rst-line-block-region)
+ ;; Make sure that all the bullets in the region are consistent.
+ (define-key map [(control c) (control w)] 'rst-straighten-bullets-region)
+ ;; Shift region left or right (taking into account of enumerations/bullets, etc.).
+ (define-key map [(control c) (control l)] 'rst-shift-region-left)
+ (define-key map [(control c) (control r)] 'rst-shift-region-right)
+ ;; Comment/uncomment the active region.
+ (define-key map [(control c) (control c)] 'comment-region)
+
+ ;;
+ ;; Table-of-Contents Features.
+ ;;
+ ;; Enter a TOC buffer to view and move to a specific section.
+ (define-key map [(control c) (control t)] 'rst-toc)
+ ;; Insert a TOC here.
+ (define-key map [(control c) (control i)] 'rst-toc-insert)
+ ;; Update the document's TOC (without changing the cursor position).
+ (define-key map [(control c) (control u)] 'rst-toc-update)
+ ;; Got to the section under the cursor (cursor must be in TOC).
+ (define-key map [(control c) (control f)] 'rst-goto-section)
+
+ ;;
+ ;; Converting Documents from Emacs.
+ ;;
+ ;; Run one of two pre-configured toolset commands on the document.
+ (define-key map [(control c) (?1)] 'rst-compile)
+ (define-key map [(control c) (?2)] 'rst-compile-alt-toolset)
+ ;; Convert the active region to pseudo-xml using the docutils tools.
+ (define-key map [(control c) (?3)] 'rst-compile-pseudo-region)
+ ;; Convert the current document to PDF and launch a viewer on the results.
+ (define-key map [(control c) (?4)] 'rst-compile-pdf-preview)
+ ;; Convert the current document to S5 slides and view in a web browser.
+ (define-key map [(control c) (?5)] 'rst-compile-slides-preview)
+
+ map)
+ "Keymap for ReStructuredText mode commands. This inherits from Text mode.")
+
+
+;; Abbrevs.
+(defvar rst-mode-abbrev-table nil
+ "Abbrev table used while in rst mode.")
+(define-abbrev-table 'rst-mode-abbrev-table
+ '(
+ ("contents" ".. contents::\n..\n " nil 0)
+ ("con" ".. contents::\n..\n " nil 0)
+ ("cont" "[...]" nil 0)
+ ("skip" "\n\n[...]\n\n " nil 0)
+ ("seq" "\n\n[...]\n\n " nil 0)
+ ;; FIXME: Add footnotes, links, and more.
+ ))
+
+
+;; Syntax table.
+(defvar rst-mode-syntax-table
+ (let ((st (copy-syntax-table text-mode-syntax-table)))
+
+ (modify-syntax-entry ?$ "." st)
+ (modify-syntax-entry ?% "." st)
+ (modify-syntax-entry ?& "." st)
+ (modify-syntax-entry ?' "." st)
+ (modify-syntax-entry ?* "." st)
+ (modify-syntax-entry ?+ "." st)
+ (modify-syntax-entry ?. "_" st)
+ (modify-syntax-entry ?/ "." st)
+ (modify-syntax-entry ?< "." st)
+ (modify-syntax-entry ?= "." st)
+ (modify-syntax-entry ?> "." st)
+ (modify-syntax-entry ?\\ "\\" st)
+ (modify-syntax-entry ?| "." st)
+ (modify-syntax-entry ?_ "." st)
+ (when rst-use-unicode
+ ;; Use strings because unicode literals are not understood before Emacs
+ ;; 22
+ (modify-syntax-entry (aref "\u00ab" 0) "." st)
+ (modify-syntax-entry (aref "\u00bb" 0) "." st)
+ (modify-syntax-entry (aref "\u2018" 0) "." st)
+ (modify-syntax-entry (aref "\u2019" 0) "." st)
+ (modify-syntax-entry (aref "\u201c" 0) "." st)
+ (modify-syntax-entry (aref "\u201d" 0) "." st))
+
+ st)
+ "Syntax table used while in `rst-mode'.")
+
+
+(defcustom rst-mode-hook nil
+ "Hook run when Rst Mode is turned on. The hook for Text Mode is run before
+ this one."
+ :group 'rst
+ :type '(hook))
+
+
+;;;###autoload
+(define-derived-mode rst-mode text-mode "ReST"
+ :abbrev-table rst-mode-abbrev-table
+ :syntax-table rst-mode-syntax-table
+ :group 'rst
+ "Major mode for editing reStructuredText documents.
+
+There are a number of convenient keybindings provided by
+rst-mode. The main one is \[rst-adjust\], it updates or rotates
+the section title around point or promotes/demotes the
+decorations within the region (see full details below). Use
+negative prefix arg to rotate in the other direction.
+\\{rst-mode-map}
+
+Turning on `rst-mode' calls the normal hooks `text-mode-hook' and
+`rst-mode-hook'. This mode also supports font-lock highlighting."
+
+ (set (make-local-variable 'paragraph-separate) paragraph-start)
+ (set (make-local-variable 'indent-line-function)
+ (if (<= emacs-major-version 21)
+ 'indent-relative-maybe
+ 'indent-relative))
+ (set (make-local-variable 'paragraph-start)
+ "\f\\|>*[ \t]*$\\|>*[ \t]*[-+*] \\|>*[ \t]*[0-9#]+\\. ")
+ (set (make-local-variable 'adaptive-fill-mode) t)
+
+ ;; FIXME: No need to reset this.
+ ;; (set (make-local-variable 'indent-line-function) 'indent-relative)
+
+ ;; The details of the following comment setup is important because it affects
+ ;; auto-fill, and it is pretty common in running text to have an ellipsis
+ ;; ("...") which trips because of the rest comment syntax (".. ").
+ (set (make-local-variable 'comment-start) ".. ")
+ (set (make-local-variable 'comment-start-skip) "^\\.\\. ")
+ (set (make-local-variable 'comment-multi-line) nil)
+
+ ;; Special variables
+ (make-local-variable 'rst-adornment-level-alist)
+
+ ;; Font lock
+ (set (make-local-variable 'font-lock-defaults)
+ '(rst-font-lock-keywords
+ t nil nil nil
+ (font-lock-multiline . t)
+ (font-lock-mark-block-function . mark-paragraph)))
+ (when (boundp 'font-lock-support-mode)
+ ;; rst-mode does not need font-lock-support-mode and works not well with
+ ;; jit-lock-mode because reST is not made for machines
+ (set (make-local-variable 'font-lock-support-mode) nil)))
+
+;;;###autoload
+(define-minor-mode rst-minor-mode
+ "ReST Minor Mode.
+Toggle ReST minor mode.
+With no argument, this command toggles the mode.
+Non-null prefix argument turns on the mode.
+Null prefix argument turns off the mode.
+
+When ReST minor mode is enabled, the ReST mode
+keybindings are installed on top of the major
+mode bindings. Use this for modes derived from
+text-mode, like mail-mode.."
+ ;; The initial value.
+ nil
+ ;; The indicator for the mode line.
+ " ReST"
+ ;; The minor mode bindings.
+ rst-mode-map
+ :group 'rst)
+
+;; FIXME: can I somehow install these too?
+;; :abbrev-table rst-mode-abbrev-table
+;; :syntax-table rst-mode-syntax-table
+
+
+
+
+
+;; Bulleted item lists.
+(defcustom rst-bullets
+ '(?- ?* ?+)
+ "List of all possible bullet characters for bulleted lists."
+ :group 'rst)
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section Decoration Adjusment
;; ============================
;;
@@ -567,8 +663,8 @@ suggest a better match."
(copy-list (car curpotential)) ))
-(defun rst-delete-line ()
- "A version of `kill-line' that does not use the `kill-ring'."
+(defun rst-delete-entire-line ()
+ "Delete the entire current line without using the `kill-ring'."
(delete-region (line-beginning-position) (min (+ 1 (line-end-position))
(point-max))))
@@ -586,9 +682,7 @@ requested decoration."
(interactive)
(let (marker
- len
- ec
- (c ?-))
+ len)
(end-of-line)
(setq marker (point-marker))
@@ -613,14 +707,14 @@ requested decoration."
;; Avoid removing the underline of a title right above us.
(save-excursion (forward-line -1)
(not (looking-at rst-section-text-regexp)))
- (rst-delete-line)))
+ (rst-delete-entire-line)))
;; Remove following line if it consists only of a single repeated
;; character
(save-excursion
(forward-line +1)
(and (rst-line-homogeneous-p 1)
- (rst-delete-line))
+ (rst-delete-entire-line))
;; Add a newline if we're at the end of the buffer, for the subsequence
;; inserting of the underline
(if (= (point) (buffer-end 1))
@@ -682,7 +776,7 @@ function to remove redundancies and inconsistencies."
(curline 1))
;; Iterate over all the section titles/decorations in the file.
(save-excursion
- (beginning-of-buffer)
+ (goto-char (point-min))
(while (< (point) (buffer-end 1))
(if (rst-line-homogeneous-nodent-p)
(progn
@@ -721,14 +815,12 @@ list element should be unique."
(let ((hierarchy-alist (list)))
(dolist (x decorations)
(let ((char (car x))
- (style (cadr x))
- (indent (caddr x)))
+ (style (cadr x)))
(unless (assoc (cons char style) hierarchy-alist)
- (setq hierarchy-alist
- (append hierarchy-alist
- (list (cons (cons char style) x)))) )
+ (push (cons (cons char style) x) hierarchy-alist))
))
- (mapcar 'cdr hierarchy-alist)
+
+ (mapcar 'cdr (nreverse hierarchy-alist))
))
@@ -836,7 +928,7 @@ previous and next decorations is returned."
))
-(defun rst-decoration-complete-p (deco &optional point)
+(defun rst-decoration-complete-p (deco)
"Return true if the decoration DECO around POINT is complete."
;; Note: we assume that the detection of the overline as being the underline
;; of a preceding title has already been detected, and has been eliminated
@@ -886,8 +978,7 @@ REVERSE-DIRECTION is used to reverse the cycling order."
;; Search for next decoration.
(cadr
(let ((cur (if reverse-direction rotdecos
- (reverse rotdecos)))
- found)
+ (reverse rotdecos))))
(while (and cur
(not (and (eq char (caar cur))
(eq style (cadar cur)))))
@@ -932,7 +1023,10 @@ b. a negative numerical argument, which generally inverts the
prefix for example."
(interactive)
- (let* ( ;; Parse the positive and negative prefix arguments.
+ (let* (;; Save our original position on the current line.
+ (origpt (set-marker (make-marker) (point)))
+
+ ;; Parse the positive and negative prefix arguments.
(reverse-direction
(and current-prefix-arg
(< (prefix-numeric-value current-prefix-arg) 0)))
@@ -948,11 +1042,20 @@ b. a negative numerical argument, which generally inverts the
;; Run the hooks to run after adjusting.
(run-hooks 'rst-adjust-hook)
+ ;; Make sure to reset the cursor position properly after we're done.
+ (goto-char origpt)
+
))
(defvar rst-adjust-hook nil
"Hooks to be run after running `rst-adjust'.")
+(defvar rst-new-decoration-down nil
+ "If true, a new decoration being added will be initialized to
+ be one level down from the previous decoration. If nil, a new
+ decoration will be equal to the level of the previous
+ decoration.")
+
(defun rst-adjust-decoration (&optional toggle-style reverse-direction)
"Adjust/rotate the section decoration for the section title around point.
@@ -1163,7 +1266,8 @@ of the right hand fingers and the binding is unused in `text-mode'."
(setq cur
(if prev
(if (not reverse-direction)
- (or (cadr (rst-get-decoration-match hier prev))
+ (or (funcall (if rst-new-decoration-down 'cadr 'car)
+ (rst-get-decoration-match hier prev))
(rst-suggest-new-decoration hier prev))
prev)
(copy-list (car rst-preferred-decorations))
@@ -1316,18 +1420,17 @@ DECORATIONS."
(dolist (x decorations)
(insert (format "\nSection Level %d" level))
(apply 'rst-update-section x)
- (end-of-buffer)
+ (goto-char (point-max))
(insert "\n")
(incf level)
))
)))
-(defun rst-straighten-decorations (&optional buffer)
- "Redo all the decorations in the given buffer BUFFER.
+(defun rst-straighten-decorations ()
+ "Redo all the decorations in the current buffer.
This is done using our preferred set of decorations. This can be
used, for example, when using somebody else's copy of a document,
-in order to adapt it to our preferred style. If no buffer is
-specified, the default buffer is used."
+in order to adapt it to our preferred style."
(interactive)
(save-excursion
(let* ((alldecos (rst-find-all-decorations))
@@ -1356,17 +1459,25 @@ specified, the default buffer is used."
)))
-(defun rst-straighten-deco-spacing (&optional buffer)
- "Adjust the spacing before and after decorations in BUFFER.
-The spacing will be standard. If no buffer is specified, the
-default buffer is used."
+
+
+(defun rst-straighten-deco-spacing ()
+ "Adjust the spacing before and after decorations in the entire document.
+The spacing will be set to two blank lines before the first two
+section levels, and one blank line before any of the other
+section levels."
+;; FIXME: we need to take care of subtitle at some point.
(interactive)
(save-excursion
(let* ((alldecos (rst-find-all-decorations)))
- (dolist (deco alldecos)
- ;; Go to the appropriate position
- (prin1 deco)
-;; FIXME: todo
+
+ ;; Work the list from the end, so that we don't have to use markers to
+ ;; adjust for the changes in the document.
+ (dolist (deco (nreverse alldecos))
+ ;; Go to the appropriate position.
+ (goto-line (car deco))
+ (insert "@\n")
+;; FIXME: todo, we
)
)))
@@ -1457,10 +1568,8 @@ adjust. If bullets are found on levels beyond the
(defun rst-rstrip (str)
"Strips the whitespace at the end of string STR."
- (let ((tmp))
- (string-match "[ \t\n]*\\'" str)
- (substring str 0 (match-beginning 0))
- ))
+ (string-match "[ \t\n]*\\'" str)
+ (substring str 0 (match-beginning 0)))
(defun rst-get-stripped-line ()
"Return the line at cursor, stripped from whitespace."
@@ -1487,8 +1596,7 @@ Conceptually, the nil nodes--i.e. those which have no title--are
to be considered as being the same line as their first non-nil
child. This has advantages later in processing the graph."
- (let* (thelist
- (hier (rst-get-hierarchy alldecos))
+ (let* ((hier (rst-get-hierarchy alldecos))
(levels (make-hash-table :test 'equal :size 10))
lines)
@@ -1672,8 +1780,7 @@ align."
;; Note: we do child numbering from the parent, so we start number the
;; children one level before we print them.
(let ((do-print (> level 0))
- (count 1)
- b)
+ (count 1))
(when do-print
(insert indent)
(let ((b (point)))
@@ -1695,7 +1802,7 @@ align."
(setq indent
(cond
((eq rst-toc-insert-style 'plain)
- (concat indent rst-toc-indent))
+ (concat indent (make-string rst-toc-indent ? )))
((eq rst-toc-insert-style 'fixed)
(concat indent (make-string rst-toc-indent ? )))
@@ -1776,18 +1883,33 @@ Delete that region. Return t if found and the cursor is left after the comment.
t
)))
-(defun rst-toc-insert-update ()
+(defun rst-toc-update ()
"Automatically find the contents section of a document and update.
Updates the inserted TOC if present. You can use this in your
file-write hook to always make it up-to-date automatically."
(interactive)
- (save-excursion
- (if (rst-toc-insert-find-delete-contents)
- (progn (insert "\n ")
- (rst-toc-insert))) )
+ (let ((p (point)))
+ (save-excursion
+ (when (rst-toc-insert-find-delete-contents)
+ (insert "\n ")
+ (rst-toc-insert)
+ ))
+ ;; Somehow save-excursion does not really work well.
+ (goto-char p))
;; Note: always return nil, because this may be used as a hook.
)
+;; Note: we cannot bind the TOC update on file write because it messes with
+;; undo. If we disable undo, since it adds and removes characters, the
+;; positions in the undo list are not making sense anymore. Dunno what to do
+;; with this, it would be nice to update when saving.
+;;
+;; (add-hook 'write-contents-hooks 'rst-toc-update-fun)
+;; (defun rst-toc-update-fun ()
+;; ;; Disable undo for the write file hook.
+;; (let ((buffer-undo-list t)) (rst-toc-update) ))
+
+(defalias 'rst-toc-insert-update 'rst-toc-update) ;; backwards compat.
;;------------------------------------------------------------------------------
@@ -1948,12 +2070,12 @@ EVENT is the input event."
(put 'rst-toc-mode 'mode-class 'special)
(defun rst-toc-mode ()
- "Major mode for output from \\[rst-toc]."
+ "Major mode for output from \\[rst-toc], the table-of-contents for the document."
(interactive)
(kill-all-local-variables)
(use-local-map rst-toc-mode-map)
(setq major-mode 'rst-toc-mode)
- (setq mode-name "Rst-TOC")
+ (setq mode-name "ReST-TOC")
(setq buffer-read-only t)
)
@@ -1982,7 +2104,6 @@ EVENT is the input event."
(cur alldecos)
(idx 0)
- line
)
;; Find the index of the "next" decoration w.r.t. to the current line.
@@ -2002,11 +2123,12 @@ EVENT is the input event."
;; boundaries.
(if (and cur (>= idx 0))
(goto-line (car cur))
- (if (> offset 0) (end-of-buffer) (beginning-of-buffer)))
+ (if (> offset 0) (goto-char (point-max)) (goto-char (point-min))))
))
(defun rst-backward-section ()
- "Like rst-forward-section, except move back one title."
+ "Like rst-forward-section, except move back one title.
+With a prefix argument, move backward by a page."
(interactive)
(rst-forward-section -1))
@@ -2039,6 +2161,7 @@ EVENT is the input event."
;; Functions to work on item lists (e.g. indent/dedent, enumerate), which are
;; always 2 or 3 characters apart horizontally with rest.
+;; (FIXME: there is currently a bug that makes the region go away when we do that.)
(defvar rst-shift-fill-region nil
"Set to true if you want to automatically re-fill the region that is being
shifted.")
@@ -2295,7 +2418,7 @@ do all lines instead of just paragraphs."
(insert (make-string last-insert-len ?\ ))
)))
-(defun rst-listify-region (beg end)
+(defun rst-bullet-list-region (beg end)
"Add bullets to all the leftmost paragraphs in the given region.
The region is specified between BEG and END. With prefix argument,
do all lines instead of just paragraphs."
@@ -2308,19 +2431,22 @@ do all lines instead of just paragraphs."
(defmacro rst-iterate-leftmost-paragraphs
(beg end first-only body-consequent body-alternative)
- "Call FUN at the beginning of each line, with an argument that
+ "FIXME This definition is old and deprecated / we need to move
+to the newer version below:
+
+Call FUN at the beginning of each line, with an argument that
specifies whether we are at the first line of a paragraph that
starts at the leftmost column of the given region BEG and END.
Set FIRST-ONLY to true if you want to callback on the first line
of each paragraph only."
`(save-excursion
- (let ((leftcol (rst-find-leftmost-column beg end))
- (endm (set-marker (make-marker) end))
+ (let ((leftcol (rst-find-leftmost-column ,beg ,end))
+ (endm (set-marker (make-marker) ,end))
,(when first-only '(in-par nil))
)
(do* (;; Iterate lines
- (l (progn (goto-char beg) (back-to-indentation))
+ (l (progn (goto-char ,beg) (back-to-indentation))
(progn (forward-line 1) (back-to-indentation)))
(previous nil valid)
@@ -2344,6 +2470,45 @@ of each paragraph only."
))))
+(defmacro rst-iterate-leftmost-paragraphs-2 (spec &rest body)
+ "Evaluate BODY for each line in region defined by BEG END.
+LEFTMOST is set to true if the line is one of the leftmost of the
+entire paragraph. PARABEGIN is set to true if the line is the
+first of a paragraph."
+ (destructuring-bind
+ (beg end parabegin leftmost isleftmost isempty) spec
+
+ `(save-excursion
+ (let ((,leftmost (rst-find-leftmost-column ,beg ,end))
+ (endm (set-marker (make-marker) ,end))
+ (in-par nil)
+ )
+
+ (do* (;; Iterate lines
+ (l (progn (goto-char ,beg) (back-to-indentation))
+ (progn (forward-line 1) (back-to-indentation)))
+
+ (empty-line-previous nil ,isempty)
+
+ (,isempty (looking-at "[ \t]*$")
+ (looking-at "[ \t]*$"))
+
+ (,parabegin (not ,isempty)
+ (and empty-line-previous
+ (not ,isempty)))
+
+ (,isleftmost (and (not ,isempty)
+ (= (current-column) ,leftmost))
+ (and (not ,isempty)
+ (= (current-column) ,leftmost)))
+ )
+ ((>= (point-marker) endm))
+
+ (progn ,@body)
+
+ )))))
+
+
;; FIXME: there are some problems left with the following function
;; implementation:
;;
@@ -2380,113 +2545,30 @@ of each paragraph only."
;;------------------------------------------------------------------------------
(defun rst-line-block-region (rbeg rend &optional pfxarg)
- "Toggle line block prefixes for a region."
+ "Toggle line block prefixes for a region. With prefix argument
+set the empty lines too."
(interactive "r\nP")
(let ((comment-start "| ")
(comment-end "")
(comment-start-skip "| ")
(comment-style 'indent)
- (comment-multi-line nil))
- (funcall (if pfxarg 'uncomment-region 'comment-region)
- rbeg rend)))
-
-;; FIXME todo: we need to provide the option of adding the line block chars for
-;; empty lines as well. Sometimes this has to be decided by the user, but in
-;; certain cases it could be detected automatically, e.g.
-;;
-;; Foo
-;;
-;; Bar
-;;
-;; Foo2
-;;
-
+ (force current-prefix-arg))
+ (rst-iterate-leftmost-paragraphs-2
+ (rbeg rend parbegin leftmost isleft isempty)
+ (if force
+ (progn
+ (move-to-column leftmost t)
+ (delete-region (point) (+ (point) (- (current-indentation) leftmost)))
+ (insert "| "))
+ (when (not isempty)
+ (move-to-column leftmost)
+ (delete-region (point) (+ (point) (- (current-indentation) leftmost)))
+ (insert "| ")))
+ )))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; rst-mode.el --- Mode for viewing and editing reStructuredText-documents.
-;;
-;; Copyright 2003 Stefan Merten <smerten@oekonux.de>
-;;
-;; Note: this is an update from version 0.2.9 of rst-mode.el
-;;
-;; DESCRIPTION
-;;
-;; This package provides support for documents marked up using the
-;; reStructuredText format. Support includes font locking as well as some
-;; convenience functions for editing. It does this by defining a Emacs major
-;; mode.
-;;
-;; The package is based on text-mode and inherits some things from it.
-;; Particularly text-mode-hook is run before rst-mode-hook.
-;;
-;; OPTIONS
-;;
-;; There are a number of things which can be customized using the standard
-;; Emacs customization features. There are two customization groups for this
-;; mode.
-;;
-;; Customization
-;; =============
-;;
-;; rst
-;; ---
-;; This group contains some general customizable features.
-;;
-;; The group is contained in the wp group.
-;;
-;; rst-faces
-;; ---------
-;; This group contains all necessary for customizing fonts. The default
-;; settings use standard font-lock-*-face's so if you set these to your
-;; liking they are probably good in rst-mode also.
-;;
-;; The group is contained in the faces group as well as in the rst group.
-;;
-;; rst-faces-defaults
-;; ------------------
-;; This group contains all necessary for customizing the default fonts used for
-;; section title faces.
-;;
-;; The general idea for section title faces is to have a non-default background
-;; but do not change the background. The section level is shown by the
-;; lightness of the background color. If you like this general idea of
-;; generating faces for section titles but do not like the details this group
-;; is the point where you can customize the details. If you do not like the
-;; general idea, however, you should customize the faces used in
-;; rst-adornment-faces-alist.
-;;
-;; Note: If you are using a dark background please make sure the variable
-;; frame-background-mode is set to the symbol dark. This triggers
-;; some default values which are probably right for you.
-;;
-;; The group is contained in the rst-faces group.
-;;
-;; All customizable features have a comment explaining their meaning. Refer to
-;; the customization of your Emacs (try ``M-x customize``).
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Customization:
-
-(defcustom rst-mode-hook nil
- "Hook run when Rst Mode is turned on. The hook for Text Mode is run before
- this one."
- :group 'rst
- :type '(hook))
-
-(defcustom rst-mode-lazy t
- "*If non-nil Rst Mode font-locks comment, literal blocks, and section titles
-correctly. Because this is really slow it switches on Lazy Lock Mode
-automatically. You may increase Lazy Lock Defer Time for reasonable results.
-
-If nil comments and literal blocks are font-locked only on the line they start.
-
-The value of this variable is used when Rst Mode is turned on."
- :group 'rst
- :type '(boolean))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'font-lock)
@@ -2661,125 +2743,20 @@ details check the Rst Faces Defaults group."
:value-type (face))
:set-after '(rst-level-face-max))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; FIXME: Code from `restructuredtext.el' should be integrated
-
-(defvar rst-mode-syntax-table nil
- "Syntax table used while in rst mode.")
-
-(unless rst-mode-syntax-table
- (setq rst-mode-syntax-table (make-syntax-table text-mode-syntax-table))
- (modify-syntax-entry ?$ "." rst-mode-syntax-table)
- (modify-syntax-entry ?% "." rst-mode-syntax-table)
- (modify-syntax-entry ?& "." rst-mode-syntax-table)
- (modify-syntax-entry ?' "." rst-mode-syntax-table)
- (modify-syntax-entry ?* "." rst-mode-syntax-table)
- (modify-syntax-entry ?+ "." rst-mode-syntax-table)
- (modify-syntax-entry ?. "_" rst-mode-syntax-table)
- (modify-syntax-entry ?/ "." rst-mode-syntax-table)
- (modify-syntax-entry ?< "." rst-mode-syntax-table)
- (modify-syntax-entry ?= "." rst-mode-syntax-table)
- (modify-syntax-entry ?> "." rst-mode-syntax-table)
- (modify-syntax-entry ?\\ "\\" rst-mode-syntax-table)
- (modify-syntax-entry ?| "." rst-mode-syntax-table)
- (modify-syntax-entry ?_ "." rst-mode-syntax-table)
- )
-
-(defvar rst-mode-abbrev-table nil
- "Abbrev table used while in rst mode.")
-(define-abbrev-table 'rst-mode-abbrev-table ())
-
-;; FIXME: Movement keys to skip forward / backward over or mark an indented
-;; block could be defined; keys to markup section titles based on
-;; `rst-adornment-level-alist' would be useful
-(defvar rst-mode-map nil
- "Keymap for rst mode. This inherits from Text mode.")
-
-(unless rst-mode-map
- (setq rst-mode-map (copy-keymap text-mode-map)))
-
-(defun rst-mode ()
- "Major mode for editing reStructuredText documents.
-
-You may customize `rst-mode-lazy' to switch font-locking of blocks.
-
-\\{rst-mode-map}
-Turning on `rst-mode' calls the normal hooks `text-mode-hook' and
-`rst-mode-hook'."
- (interactive)
- (kill-all-local-variables)
-
- ;; Maps and tables
- (use-local-map rst-mode-map)
- (setq local-abbrev-table rst-mode-abbrev-table)
- (set-syntax-table rst-mode-syntax-table)
-
- ;; For editing text
- ;;
- ;; FIXME: It would be better if this matches more exactly the start of a reST
- ;; paragraph; however, this not always possible with a simple regex because
- ;; paragraphs are determined by indentation of the following line
- (set (make-local-variable 'paragraph-start)
- (concat page-delimiter "\\|[ \t]*$"))
- (if (eq ?^ (aref paragraph-start 0))
- (setq paragraph-start (substring paragraph-start 1)))
- (set (make-local-variable 'paragraph-separate) paragraph-start)
- (set (make-local-variable 'indent-line-function) 'indent-relative-maybe)
- (set (make-local-variable 'adaptive-fill-mode) t)
- (set (make-local-variable 'comment-start) ".. ")
-
- ;; Special variables
- (make-local-variable 'rst-adornment-level-alist)
-
- ;; Font lock
- (set (make-local-variable 'font-lock-defaults)
- '(rst-font-lock-keywords-function
- t nil nil nil
- (font-lock-multiline . t)
- (font-lock-mark-block-function . mark-paragraph)))
- (when (boundp 'font-lock-support-mode)
- ;; rst-mode has its own mind about font-lock-support-mode
- (make-local-variable 'font-lock-support-mode)
- ;; jit-lock-mode replaced lazy-lock-mode in GNU Emacs 22
- (let ((jit-or-lazy-lock-mode
- (cond
- ((fboundp 'jit-lock-mode) 'jit-lock-mode)
- ((fboundp 'lazy-lock-mode) 'lazy-lock-mode)
- ;; if neither lazy-lock nor jit-lock is supported,
- ;; tell user and disable rst-mode-lazy
- (t (when rst-mode-lazy
- (message "Disabled lazy fontification, because no known support mode found.")
- (setq rst-mode-lazy nil))))))
- (cond
- ((and (not rst-mode-lazy) (not font-lock-support-mode)))
- ;; No support mode set and none required - leave it alone
- ((or (not font-lock-support-mode) ;; No support mode set (but required)
- (symbolp font-lock-support-mode)) ;; or a fixed mode for all
- (setq font-lock-support-mode
- (list (cons 'rst-mode (and rst-mode-lazy 'jit-or-lazy-lock-mode))
- (cons t font-lock-support-mode))))
- ((and (listp font-lock-support-mode)
- (not (assoc 'rst-mode font-lock-support-mode)))
- ;; A list of modes missing rst-mode
- (setq font-lock-support-mode
- (append '((cons 'rst-mode (and rst-mode-lazy 'jit-or-lazy-lock-mode)))
- font-lock-support-mode))))))
-
- ;; Names and hooks
- (setq mode-name "reST")
- (setq major-mode 'rst-mode)
- (run-hooks 'text-mode-hook)
- (run-hooks 'rst-mode-hook))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Font lock
-(defun rst-font-lock-keywords-function ()
- "Returns keywords to highlight in rst mode according to current settings."
+(defconst rst-use-char-classes
+ (string-match "[[:alpha:]]" "b")
+ "Non-nil if we can use the character classes in our regexps.")
+
+(defvar rst-font-lock-keywords
;; The reST-links in the comments below all relate to sections in
;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html
- (let* ( ;; This gets big - so let's define some abbreviations
+ (let* ( ;; This gets big - so let's define some abbreviations; the trailing
+ ;; numbers in the names give the number of regex groups contained
;; horizontal white space
(re-hws "[\t ]")
;; beginning of line with possible indentation
@@ -2791,9 +2768,17 @@ Turning on `rst-mode' calls the normal hooks `text-mode-hook' and
;; explicit markup start
(re-ems (concat re-emt re-hws "+"))
;; inline markup prefix
- (re-imp1 (concat "\\(^\\|" re-hws "\\|[-'\"([{</:]\\)"))
+ (re-imp1 (concat "\\(^\\|" re-hws "\\|[-'\"([{<"
+ (if rst-use-unicode
+ "\u2018\u201c\u00ab\u2019"
+ "")
+ "/:]\\)"))
;; inline markup suffix
- (re-ims1 (concat "\\(" re-hws "\\|[]-'\")}>/:.,;!?\\]\\|$\\)"))
+ (re-ims1 (concat "\\(" re-hws "\\|[]-'\")}>"
+ (if rst-use-unicode
+ "\u2019\u201d\u00bb"
+ "")
+ "/:.,;!?\\]\\|$\\)"))
;; symbol character
(re-sym1 "\\(\\sw\\|\\s_\\)")
;; inline markup content begin
@@ -2820,12 +2805,9 @@ Turning on `rst-mode' calls the normal hooks `text-mode-hook' and
;; characters because otherwise explicit markup start would be
;; recognized
(re-ado2 (concat "^\\(\\(["
- (if (or
- (< emacs-major-version 21)
- (save-match-data
- (string-match "XEmacs\\|Lucid" emacs-version)))
- "^\\w \t\x00-\x1F"
- "^[:word:][:space:][:cntrl:]")
+ (if rst-use-char-classes
+ "^[:word:][:space:][:cntrl:]"
+ "^\\w \t\x00-\x1F")
"]\\)\\2\\2+\\)" re-hws "*$"))
)
(list
@@ -2926,67 +2908,53 @@ Turning on `rst-mode' calls the normal hooks `text-mode-hook' and
;; Do all block fontification as late as possible so 'append works
;; Sections_ / Transitions_
- (append
- (list
- re-ado2)
- (if (not rst-mode-lazy)
- (list 1 rst-block-face)
- (list
- (list 'rst-font-lock-handle-adornment
- '(progn
- (setq rst-font-lock-adornment-point (match-end 1))
- (point-max))
- nil
- (list 1 '(cdr (assoc nil rst-adornment-faces-alist))
- 'append t)
- (list 2 '(cdr (assoc rst-font-lock-level
- rst-adornment-faces-alist))
- 'append t)
- (list 3 '(cdr (assoc nil rst-adornment-faces-alist))
- 'append t)))))
+ (list
+ re-ado2
+ (list 'rst-font-lock-handle-adornment-match
+ '(rst-font-lock-handle-adornment-limit
+ (match-string-no-properties 1) (match-end 1))
+ nil
+ (list 1 '(cdr (assoc nil rst-adornment-faces-alist))
+ 'append t)
+ (list 2 '(cdr (assoc rst-font-lock-adornment-level
+ rst-adornment-faces-alist))
+ 'append t)
+ (list 3 '(cdr (assoc nil rst-adornment-faces-alist))
+ 'append t)))
;; `Comments`_
- (append
- (list
- (concat re-bol "\\(" re-ems "\\)\[^[|_]\\([^:\n]\\|:\\([^:\n]\\|$\\)\\)*$")
-
- (list 1 rst-comment-face))
- (if rst-mode-lazy
- (list
- (list 'rst-font-lock-find-unindented-line
- '(progn
- (setq rst-font-lock-indentation-point (match-end 1))
- (point-max))
- nil
- (list 0 rst-comment-face 'append)))))
- (append
- (list
- (concat re-bol "\\(" re-emt "\\)\\(\\s *\\)$")
- (list 1 rst-comment-face)
- (list 2 rst-comment-face))
- (if rst-mode-lazy
- (list
- (list 'rst-font-lock-find-unindented-line
- '(progn
- (setq rst-font-lock-indentation-point 'next)
- (point-max))
- nil
- (list 0 rst-comment-face 'append)))))
+ (list
+ (concat re-bol "\\(" re-ems "\\)\[^[|_]\\([^:\n]\\|:\\([^:\n]\\|$\\)\\)*$")
+ (list 1 rst-comment-face)
+ (list 'rst-font-lock-find-unindented-line-match
+ '(rst-font-lock-find-unindented-line-limit (match-end 1))
+ nil
+ (list 0 rst-comment-face 'append)))
+ (list
+ (concat re-bol "\\(" re-emt "\\)\\(\\s *\\)$")
+ (list 1 rst-comment-face)
+ (list 2 rst-comment-face)
+ (list 'rst-font-lock-find-unindented-line-match
+ '(rst-font-lock-find-unindented-line-limit 'next)
+ nil
+ (list 0 rst-comment-face 'append)))
;; `Literal Blocks`_
- (append
- (list
- (concat re-bol "\\(\\([^.\n]\\|\\.[^.\n]\\).*\\)?\\(::\\)$")
- (list 3 rst-block-face))
- (if rst-mode-lazy
- (list
- (list 'rst-font-lock-find-unindented-line
- '(progn
- (setq rst-font-lock-indentation-point t)
- (point-max))
- nil
- (list 0 rst-literal-face 'append)))))
- )))
+ (list
+ (concat re-bol "\\(\\([^.\n]\\|\\.[^.\n]\\).*\\)?\\(::\\)$")
+ (list 3 rst-block-face)
+ (list 'rst-font-lock-find-unindented-line-match
+ '(rst-font-lock-find-unindented-line-limit t)
+ nil
+ (list 0 rst-literal-face 'append)))
+
+ ;; `Doctest Blocks`_
+ (list
+ (concat re-bol "\\(>>>\\|\\.\\.\\.\\)\\(.+\\)")
+ (list 1 rst-block-face)
+ (list 2 rst-literal-face))
+ ))
+ "Returns keywords to highlight in rst mode according to current settings.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Indented blocks
@@ -3021,54 +2989,70 @@ point is not moved."
(goto-char (or fnd start))
fnd))
-;; Stores the point where the current indentation ends if a number. If `next'
-;; indicates `rst-font-lock-find-unindented-line' shall take the indentation
-;; from the next line if this is not empty. If non-nil indicates
-;; `rst-font-lock-find-unindented-line' shall take the indentation from the
-;; next non-empty line. Also used as a trigger for
-;; `rst-font-lock-find-unindented-line'.
-(defvar rst-font-lock-indentation-point nil)
-
-(defun rst-font-lock-find-unindented-line (limit)
- (let* ((ind-pnt rst-font-lock-indentation-point)
- (beg-pnt ind-pnt))
- ;; May run only once - enforce this
- (setq rst-font-lock-indentation-point nil)
- (when (and ind-pnt (not (numberp ind-pnt)))
- ;; Find indentation point in next line if any
- (setq ind-pnt
- (save-excursion
- (save-match-data
- (if (eq ind-pnt 'next)
- (when (and (zerop (forward-line 1)) (< (point) limit))
- (setq beg-pnt (point))
- (when (not (looking-at "\\s *$"))
+;; Beginning of the match if `rst-font-lock-find-unindented-line-end'.
+(defvar rst-font-lock-find-unindented-line-begin nil)
+
+;; End of the match as determined by
+;; `rst-font-lock-find-unindented-line-limit'. Also used as a trigger for
+;; `rst-font-lock-find-unindented-line-match'.
+(defvar rst-font-lock-find-unindented-line-end nil)
+
+;; Finds the next unindented line relative to indenation at IND-PNT and returns
+;; this point, the end of the buffer or nil if nothing found. If IND-PNT is
+;; `next' takes the indentation from the next line if this is not empty. If
+;; IND-PNT is non-nil but not a number takes the indentation from the next
+;; non-empty line.
+(defun rst-font-lock-find-unindented-line-limit (ind-pnt)
+ (setq rst-font-lock-find-unindented-line-begin ind-pnt)
+ (setq rst-font-lock-find-unindented-line-end
+ (save-excursion
+ (when (not (numberp ind-pnt))
+ ;; Find indentation point in next line if any
+ (setq ind-pnt
+ ;; FIXME: Should be refactored to two different functions
+ ;; giving their result to this function, may be
+ ;; integrated in caller
+ (save-match-data
+ (if (eq ind-pnt 'next)
+ (when (and (zerop (forward-line 1))
+ (< (point) (point-max)))
+ ;; Not at EOF
+ (setq rst-font-lock-find-unindented-line-begin (point))
+ (when (not (looking-at "\\s *$"))
+ ;; Use end of indentation if non-empty line
+ (looking-at "\\s *")
+ (match-end 0)))
+ ;; Skip until non-empty line or EOF
+ (while (and (zerop (forward-line 1))
+ (< (point) (point-max))
+ (looking-at "\\s *$")))
+ (when (< (point) (point-max))
+ ;; Not at EOF
+ (setq rst-font-lock-find-unindented-line-begin (point))
(looking-at "\\s *")
- (match-end 0)))
- (while (and (zerop (forward-line 1)) (< (point) limit)
- (looking-at "\\s *$")))
- (when (< (point) limit)
- (setq beg-pnt (point))
- (looking-at "\\s *")
- (match-end 0)))))))
- (when ind-pnt
- (goto-char ind-pnt)
- ;; Always succeeds because the limit set by PRE-MATCH-FORM is the
- ;; ultimate point to find
- (goto-char (or (rst-forward-indented-block nil limit) limit))
- (set-match-data (list beg-pnt (point)))
- t)))
+ (match-end 0))))))
+ (when ind-pnt
+ (goto-char ind-pnt)
+ (or (rst-forward-indented-block nil (point-max))
+ (point-max))))))
+
+;; Sets the match found by `rst-font-lock-find-unindented-line-limit' the first
+;; time called or nil.
+(defun rst-font-lock-find-unindented-line-match (limit)
+ (when rst-font-lock-find-unindented-line-end
+ (set-match-data
+ (list rst-font-lock-find-unindented-line-begin
+ rst-font-lock-find-unindented-line-end))
+ ;; Make sure this is called only once
+ (setq rst-font-lock-find-unindented-line-end nil)
+ t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Adornments
-;; Stores the point where the current adornment ends. Also used as a trigger
-;; for `rst-font-lock-handle-adornment'.
-(defvar rst-font-lock-adornment-point nil)
-
-;; Here `rst-font-lock-handle-adornment' stores the section level of the
+;; Here `rst-font-lock-handle-adornment-match' stores the section level of the
;; current adornment or t for a transition.
-(defvar rst-font-lock-level nil)
+(defvar rst-font-lock-adornment-level nil)
;; FIXME: It would be good if this could be used to markup section titles of
;; given level with a special key; it would be even better to be able to
@@ -3147,8 +3131,8 @@ entered.")
(setq end-ovr end-pnt)
(forward-line 1)
(setq beg-txt (point))
- (while (and (< (point) limit) (not end-txt))
- (if (looking-at "\\s *$")
+ (while (and (<= (point) limit) (not end-txt))
+ (if (or (= (point) limit) (looking-at "\\s *$"))
;; No underline found
(setq end-txt (1- (point)))
(when (looking-at (concat "\\(" ado-re "\\)\\s *$"))
@@ -3163,34 +3147,46 @@ entered.")
(setq end-und end-pnt)
(setq end-txt (1- beg-und))
(setq beg-txt (progn
- (if (re-search-backward "^\\s *$" 1 'move)
- (forward-line 1))
- (point)))))
+ (goto-char end-txt)
+ (forward-line 0)
+ (point)))
+ (when (and (zerop (forward-line -1))
+ (looking-at (concat "\\(" ado-re "\\)\\s *$")))
+ ;; There is a matching overline
+ (setq key (concat (list ado-ch) "o"))
+ (setq beg-ovr (point))
+ (setq end-ovr (match-end 1)))))
(list key
(or beg-ovr beg-txt beg-und)
(or end-und end-txt end-und)
beg-ovr end-ovr beg-txt end-txt beg-und end-und)))))
-;; Handles adornments for font-locking section titles and transitions. Returns
-;; three match groups. First and last match group matched pure overline /
-;; underline adornment while second group matched section title text. Each
-;; group may not exist.
-(defun rst-font-lock-handle-adornment (limit)
- (let ((ado-pnt rst-font-lock-adornment-point))
+;; Stores the result of `rst-classify-adornment'. Also used as a trigger
+;; for `rst-font-lock-handle-adornment-match'.
+(defvar rst-font-lock-adornment-data nil)
+
+;; Determines limit for adornments for font-locking section titles and
+;; transitions. In fact it determines all things necessary and puts the result
+;; to `rst-font-lock-adornment-data'. ADO is the complete adornment matched.
+;; ADO-END is the point where ADO ends. Returns the point where the whole
+;; adorned construct ends.
+(defun rst-font-lock-handle-adornment-limit (ado ado-end)
+ (let ((ado-data (rst-classify-adornment ado ado-end (point-max))))
+ (setq rst-font-lock-adornment-level (rst-adornment-level (car ado-data) t))
+ (setq rst-font-lock-adornment-data (cdr ado-data))
+ (goto-char (nth 1 ado-data))
+ (nth 2 ado-data)))
+
+;; Sets the match found by `rst-font-lock-handle-adornment-limit' the first
+;; time called or nil.
+(defun rst-font-lock-handle-adornment-match (limit)
+ (let ((ado-data rst-font-lock-adornment-data))
;; May run only once - enforce this
- (setq rst-font-lock-adornment-point nil)
- (if ado-pnt
- (let* ((ado (rst-classify-adornment (match-string-no-properties 1)
- ado-pnt limit))
- (key (car ado))
- (mtc (cdr ado)))
- (setq rst-font-lock-level (rst-adornment-level key t))
- (goto-char (nth 1 mtc))
- (set-match-data mtc)
- t))))
-
-;;; rst-mode.el ends here
-
+ (setq rst-font-lock-adornment-data nil)
+ (when ado-data
+ (goto-char (nth 1 ado-data))
+ (set-match-data ado-data)
+ t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3233,7 +3229,7 @@ string)) to be used for converting the document.")
(let* ((dir (file-name-directory buffer-file))
(prevdir nil))
(while (and (or (not (string= dir prevdir))
- (setq dir nil)
+ (setq dir nil)
nil)
(not (file-exists-p (concat dir file-name))))
;; Move up to the parent dir and try again.
@@ -3323,7 +3319,7 @@ of the entire buffer, if the region is not selected."
"Convert the document to an S5 slide presentation and launch a preview program."
(interactive)
(let* ((tmp-filename "/tmp/slides.html")
- (command (format "rst2s5.py %s %s && %s %s"
+ (command (format "rst2s5.py %s %s && %s %s"
buffer-file-name tmp-filename
rst-slides-program tmp-filename)))
(start-process-shell-command "rst-slides-preview" nil command)
@@ -3331,13 +3327,14 @@ of the entire buffer, if the region is not selected."
;; output.
))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Generic text functions that are more convenient than the defaults.
;;
-(defun replace-lines (fromchar tochar)
+(defun rst-replace-lines (fromchar tochar)
"Replace flush-left lines, consisting of multiple FROMCHAR characters,
with equal-length lines of TOCHAR."
(interactive "\
@@ -3355,30 +3352,29 @@ cand replace with char: ")
(setq p (1+ (point)))
(beginning-of-line)
(setq l (- p (point)))
- (rst-delete-line)
+ (rst-delete-entire-line)
(insert-char tochar l))
(search-failed
(message (format "%d lines replaced." found)))))))
-(defun join-paragraph ()
+(defun rst-join-paragraph ()
"Join lines in current paragraph into one line, removing end-of-lines."
(interactive)
(let ((fill-column 65000)) ; some big number
(call-interactively 'fill-paragraph)))
-;; FIXME: can we remove this?
-(defun force-fill-paragraph ()
+(defun rst-force-fill-paragraph ()
"Fill paragraph at point, first joining the paragraph's lines into one.
This is useful for filling list item paragraphs."
(interactive)
- (join-paragraph)
+ (rst-join-paragraph)
(fill-paragraph nil))
;; Generic character repeater function.
;; For sections, better to use the specialized function above, but this can
;; be useful for creating separators.
-(defun repeat-last-character (&optional tofill)
+(defun rst-repeat-last-character (&optional tofill)
"Fills the current line up to the length of the preceding line (if not
empty), using the last character on the current line. If the preceding line is
empty, we use the fill-column.
@@ -3406,7 +3402,7 @@ column is used (fill-column vs. end of previous/next line)."
(if (= cc 0) fill-column cc)))))
(rightmost-column
(cond (tofill fill-column)
- ((equal last-command 'repeat-last-character)
+ ((equal last-command 'rst-repeat-last-character)
(if (= curcol fill-column) prevcol fill-column))
(t (save-excursion
(if (= prevcol 0) fill-column prevcol)))
@@ -3424,13 +3420,10 @@ column is used (fill-column vs. end of previous/next line)."
(defun rst-portable-mark-active-p ()
- "A portable (GNU, Xemacs) function that returns true if the
-mark is active."
- (or
- (and (fboundp 'region-active-p)
- (region-active-p) (region-exists-p))
- (and (boundp 'transient-mark-mode)
- transient-mark-mode mark-active)))
+ "A portable function that returns non-nil if the mark is active."
+ (cond
+ ((fboundp 'region-active-p) (region-active-p))
+ ((boundp 'transient-mark-mode) transient-mark-mode mark-active)))
diff --git a/tools/editors/emacs/tests/Makefile b/tools/editors/emacs/tests/Makefile
index ea024e3fd..a7a05a759 100644
--- a/tools/editors/emacs/tests/Makefile
+++ b/tools/editors/emacs/tests/Makefile
@@ -1,9 +1,12 @@
+#!/usr/bin/env make
+
+EMACS=/usr/bin/emacs-23-unicode
runtests:
- emacs-21 --batch -l tests-basic.el
- emacs-21 --batch -l tests-adjust-section.el
+ $(EMACS) --batch -l tests-basic.el
+ $(EMACS) --batch -l tests-adjust-section.el
runtests-emacs-cvs:
- emacs --script tests-basic.el
- emacs --script tests-adjust-section.el
+ $(EMACS) --script tests-basic.el
+ $(EMACS) --script tests-adjust-section.el
diff --git a/tools/quicktest.py b/tools/quicktest.py
index 3d5674003..bb3a8aa7a 100755
--- a/tools/quicktest.py
+++ b/tools/quicktest.py
@@ -21,7 +21,9 @@ from docutils.parsers.rst import Parser
usage_header = """\
-quicktest.py: quickly test the restructuredtext parser.
+quicktest.py: Quickly test the reStructuredText parser. This is not an
+interface to the full functionality of Docutils. Use one of the ``rst2*.py``
+front-end tools instead.
Usage::