|
From: <mi...@us...> - 2020-02-06 12:47:36
|
Revision: 8488
http://sourceforge.net/p/docutils/code/8488
Author: milde
Date: 2020-02-06 12:47:34 +0000 (Thu, 06 Feb 2020)
Log Message:
-----------
Documentation update.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-02-06 12:47:25 UTC (rev 8487)
+++ trunk/docutils/HISTORY.txt 2020-02-06 12:47:34 UTC (rev 8488)
@@ -13,7 +13,6 @@
.. contents::
-2019-07-23 : Branch: branches/rel-0.15 created to investigate import problems: bugs#366
Changes Since 0.16
==================
@@ -22,6 +21,9 @@
- Fix [ 385 ]: Import of language modules.
- Use importlib.import_module() to programmatically import modules.
+ - Remove legacy LaTeX stylesheet ``docutils-05-compat.sty``.
+ - Installing with ``setup.py`` now requires ``setuptools``.
+ Alternatively, install with `pip`_.
* docutils/MANIFEST.in
@@ -56,14 +58,13 @@
- Remove backwards compatibility code for the deprecated
`styling command`__ prefix ``\docutilsrole``.
-
+
__ docs/user/latex.html#classes
-* docutils/writers/latex2e/docutils-05-compat.sty:
+.. _pip: https://pypi.org/project/pip/
+.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
- - Remove this legacy stylesheet.
-
Release 0.16
============
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-02-06 12:47:25 UTC (rev 8487)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-02-06 12:47:34 UTC (rev 8488)
@@ -13,17 +13,13 @@
This document summarizes the major changes in recent and upcoming releases.
-For a more detailed list of changes, please see the `Docutils History`_.
+For a more detailed list of changes, please see the Docutils `HISTORY`_.
-.. _Docutils History: HISTORY.html
-
.. contents::
Future changes
==============
-* Installing with ``setup.py`` will require setuptools_ in versions > 0.16.
-
* LaTeX writer:
The default for the configuration setting `legacy_class_functions`_ will
change to "False". Adapt stylesheets modifying ``\DUadmonition``
@@ -56,18 +52,19 @@
generated HTML code, e.g. because you use a custom style sheet or
post-processing that may break otherwise.
-.. _setuptools: https://setuptools.readthedocs.io/en/latest/
.. _id_prefix: docs/user/config.html#id-prefix
.. _auto_id_prefix: docs/user/config.html#auto-id-prefix
.. _rst2html.py: docs/user/tools.html#rst2html-py
.. _reference name: docs/ref/rst/restructuredtext.html#reference-names
.. _identifier normalization: directives.html#identifier-normalization
-.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Release 0.17
============
+* Installing with ``setup.py`` now requires setuptools_.
+ Alternatively, install with pip_.
+
* HTML5 writer:
- Use the new semantic tags <main>, <section>, <header>,
@@ -90,6 +87,11 @@
__ docs/user/latex.html#classes
+.. _setuptools: https://pypi.org/project/setuptools/
+.. _pip: https://pypi.org/project/pip/
+.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
+
+
Release 0.16 (2020-01-12)
=========================
@@ -158,9 +160,7 @@
* languages: Added Korean localisation (ko).
-* Bugfixes (see HISTORY_).
-
Release 0.14 (2017-08-03)
=========================
@@ -271,7 +271,7 @@
- Avoid repeated class declarations in html4css1 writer
(modified version of patch [ 104 ]).
-.. _math-output: docs/user/config.html#math-output
+ .. _math-output: docs/user/config.html#math-output
* docutils/writers/latex2e/__init__.py
@@ -282,7 +282,7 @@
where stylesheets are found. Used by `stylesheet_path` when expanding
relative path arguments.
-.. _SmartQuotes: docs/user/config.html#smart-quotes
+ .. _SmartQuotes: docs/user/config.html#smart-quotes
* docutils/writers/manpage.py
@@ -319,8 +319,6 @@
- FileInput/FileOutput: no system-exit on IOError.
The `handle_io_errors` option is ignored.
-.. _Python 3 compatibility: README.html#python-3-compatibility
-
* docutils/writers/html4css1/__init__.py
- Use ``<code>`` tag for inline "code",
@@ -783,3 +781,4 @@
__ docs/ref/rst/directives.html#csv-table
.. _HISTORY: HISTORY.html
+.. _Python 3 compatibility: README.html#python-3-compatibility
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-02-06 12:47:46
|
Revision: 8489
http://sourceforge.net/p/docutils/code/8489
Author: milde
Date: 2020-02-06 12:47:44 +0000 (Thu, 06 Feb 2020)
Log Message:
-----------
Documentation update.
Document the use of "setuptools" in "setup.py" and possible
alternatives.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/README.txt
trunk/docutils/docs/dev/distributing.txt
trunk/docutils/docs/dev/policies.txt
trunk/docutils/docs/dev/release.txt
trunk/docutils/docs/dev/repository.txt
trunk/docutils/setup.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/HISTORY.txt 2020-02-06 12:47:44 UTC (rev 8489)
@@ -23,7 +23,7 @@
- Use importlib.import_module() to programmatically import modules.
- Remove legacy LaTeX stylesheet ``docutils-05-compat.sty``.
- Installing with ``setup.py`` now requires ``setuptools``.
- Alternatively, install with `pip`_.
+ Alternatively, install with `pip`_ (or "manually").
* docutils/MANIFEST.in
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/README.txt 2020-02-06 12:47:44 UTC (rev 8489)
@@ -17,26 +17,18 @@
This is for those who want to get up & running quickly.
1. Docutils requires Python, available from
+ http://www.python.org/.
- http://www.python.org/
-
See Requirements_ below for details.
-2. Use the latest Docutils code. Get the code from the `Subversion
- repository`_ or from the snapshot:
+2. Install the latest release from PyPi with pip_::
- https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
+ python -m pip install docutils
- See `Releases & Snapshots`_ below for details.
+ To install a `development version`_, follow
+ the instructions in section `Installation`_ below.
-3. Unpack the tarball in a temporary directory (**not** directly in
- Python's ``site-packages``), go to the directory created by expanding
- the archive, and run ``setup.py install``. On
- Windows systems it may be sufficient to double-click ``install.py``.
-
- See Installation_ below for details.
-
-4. Use the front-end scripts to convert reStructuredText documents.
+3. Use the front-end scripts to convert reStructuredText documents.
Try for example::
rst2html.py FAQ.txt FAQ.html (Unix)
@@ -44,7 +36,9 @@
See Usage_ below for details.
+.. _pip: https://pypi.org/project/pip/
+
Purpose
=======
@@ -75,37 +69,17 @@
http://www.python.org/peps/pep-0012.html
-Releases & Snapshots
-====================
-
-While we are trying to follow a "release early & often" policy,
-features are added frequently. Since the code in the Subversion
-repository is usually in a bug-free state, we recommend that you use
-a current snapshot.
-
-To get a snapshot, go to the code page and click the download snapshot
-button:
-
-* Docutils code, documentation, front-end tools, and tests:
- https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
-
-* Sandbox (experimental, contributed code):
- https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/sandbox/
-
-To keep up to date on the latest developments, download fresh copies of
-the snapshots regularly or use a working copy of the
-`Subversion repository`_.
-
-.. _Subversion repository: docs/dev/repository.html
-
-
Requirements
============
To run the code, Python_ must be installed.
-Docutils is compatible with Python versions 2.7, and
-3.5 to 3.7 (cf. `Python 3 compatibility`_).
+Docutils is compatible with Python versions 2.7 and 3.5 to 3.7.
+Starting with Docutils 0.16, the code base supports both Python 2.7
+and 3.5+ natively. [#]_
+.. [#] Up to version 0.15, the Docutils codebase was translated "on-demand"
+ using the 2to3 tool.
+
Docutils uses the following packages for enhanced functionality,
if they are installed:
@@ -117,85 +91,69 @@
.. _Python: http://www.python.org/.
.. _Python Imaging Library: http://www.pythonware.com/products/pil/
-.. _Pygments: http://pygments.org/
+.. _Pygments: https://pypi.org/project/Pygments/
+.. _setuptools: https://pypi.org/project/setuptools/
-Python 3 compatibility
-----------------------
+Development version
+===================
-Up to version 0.15, the Docutils codebase was translated "on-demand" using
-the 2to3 tool. Starting with Docutils 0.16, the code base supports both
-Python 2.7 and 3.5+ natively.
+While we are trying to follow a "release early & often" policy,
+features are added frequently. Since the code in the repository_
+is usually in a bug-free state, we recommend using a current snapshot
+or a working copy.
+To get a _`snapshot`, go to the code page and click the download snapshot
+button:
-Project Files & Directories
-===========================
+* Docutils code, documentation, front-end tools, and tests:
+ https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
-* README.txt: You're reading it.
+* Sandbox (experimental, contributed code):
+ https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/sandbox/
-* COPYING.txt: Public Domain Dedication and copyright details for
- non-public-domain files (most are PD).
+To keep up to date on the latest developments, download fresh copies of the
+snapshots regularly or use a `working copy of the Docutils code repository`__.
-* FAQ.txt: Frequently Asked Questions (with answers!).
+Continue with the `Installation`_ instructions below.
-* RELEASE-NOTES.txt: Summary of the major changes in recent releases.
+.. _repository: docs/dev/repository.html
+__ docs/dev/repository.html#checking-out-the-repository
-* HISTORY.txt: A detailed change log, for the current and all previous
- project releases.
+Installation
+============
-* BUGS.txt: Known bugs, and how to report a bug.
+Steps to install Docutils from source:
-* THANKS.txt: List of contributors.
+* Go to the directory containing the file ``setup.py``.
-* setup.py: Installation script. See "Installation" below.
+ A snapshot_ must be unpacked in a temporary directory (**not** directly in
+ Python's ``site-packages``) first.
-* install.py: Quick & dirty installation script. Just run it. For
- any kind of customization or help though, setup.py must be used.
+* Run ``setup.py install``. [#setup-requires-setuptools]_
+ On Windows systems it may be sufficient to double-click ``install.py``.
-* docutils: The project source directory, installed as a Python
- package.
+.. [#setup-requires-setuptools] ``setup.py`` requires the `setuptools`_
+ package. For a manual install see the options in `Setting up for Docutils
+ development`__.
+
+ __ docs/dev/policies.html#setting-up-for-docutils-development
+
+Optional steps:
-* docs: The project documentation directory. Read ``docs/index.txt``
- for an overview.
+* `running the test suite`_
-* docs/user: The project user documentation directory. Contains the
- following documents, among others:
+* `converting the documentation`_
- - docs/user/tools.txt: Docutils Front-End Tools
- - docs/user/latex.txt: Docutils LaTeX Writer
- - docs/user/rst/quickstart.txt: A ReStructuredText Primer
- - docs/user/rst/quickref.html: Quick reStructuredText (HTML only)
+OS-specific installation instructions follow.
-* docs/ref: The project reference directory.
- ``docs/ref/rst/restructuredtext.txt`` is the reStructuredText
- reference.
-* licenses: Directory containing copies of license files for
- non-public-domain files.
-
-* tools: Directory for Docutils front-end tools. See
- ``docs/user/tools.txt`` for documentation.
-
-* test: Unit tests. Not required to use the software, but very useful
- if you're planning to modify it. See `Running the Test Suite`_
- below.
-
-
-Installation
-============
-
-The first step is to expand the ``.tgz`` archive in a temporary
-directory (**not** directly in Python's ``site-packages``). It
-contains a distutils setup file "setup.py". OS-specific installation
-instructions follow.
-
-
GNU/Linux, BSDs, Unix, Mac OS X, etc.
-------------------------------------
1. Open a shell.
-2. Go to the directory created by expanding the archive::
+2. Go to the directory containing ``setup.py``::
cd <archive_directory_path>
@@ -243,13 +201,7 @@
To install for different Python versions, repeat step 3 for every
required version.
-Optional steps:
-* `running the test suite`_
-
-* `converting the documentation`_
-
-
Usage
=====
@@ -268,6 +220,59 @@
Contributions are welcome!
+Project Files & Directories
+===========================
+
+* README.txt: You're reading it.
+
+* COPYING.txt: Public Domain Dedication and copyright details for
+ non-public-domain files (most are PD).
+
+* FAQ.txt: Frequently Asked Questions (with answers!).
+
+* RELEASE-NOTES.txt: Summary of the major changes in recent releases.
+
+* HISTORY.txt: A detailed change log, for the current and all previous
+ project releases.
+
+* BUGS.txt: Known bugs, and how to report a bug.
+
+* THANKS.txt: List of contributors.
+
+* setup.py: Installation script. See "Installation" below.
+
+* install.py: Quick & dirty installation script. Just run it. For
+ any kind of customization or help though, setup.py must be used.
+
+* docutils: The project source directory, installed as a Python
+ package.
+
+* docs: The project documentation directory. Read ``docs/index.txt``
+ for an overview.
+
+* docs/user: The project user documentation directory. Contains the
+ following documents, among others:
+
+ - docs/user/tools.txt: Docutils Front-End Tools
+ - docs/user/latex.txt: Docutils LaTeX Writer
+ - docs/user/rst/quickstart.txt: A ReStructuredText Primer
+ - docs/user/rst/quickref.html: Quick reStructuredText (HTML only)
+
+* docs/ref: The project reference directory.
+ ``docs/ref/rst/restructuredtext.txt`` is the reStructuredText
+ reference.
+
+* licenses: Directory containing copies of license files for
+ non-public-domain files.
+
+* tools: Directory for Docutils front-end tools. See
+ ``docs/user/tools.txt`` for documentation.
+
+* test: Unit tests. Not required to use the software, but very useful
+ if you're planning to modify it. See `Running the Test Suite`_
+ below.
+
+
Converting the documentation
============================
Modified: trunk/docutils/docs/dev/distributing.txt
===================================================================
--- trunk/docutils/docs/dev/distributing.txt 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/docs/dev/distributing.txt 2020-02-06 12:47:44 UTC (rev 8489)
@@ -65,10 +65,9 @@
The executable front-end tools are located in the ``tools/`` directory
of the Docutils tarball.
-The ``rst2*.py`` tools (except ``rst2newlatex.py``) are intended for
-end-users. You should install them to ``/usr/bin/``. You do not need
-to change the names (e.g. to ``docutils-rst2html.py``) because the
-``rst2`` prefix is unique.
+The ``rst2*.py`` tools are intended for end-users. You should install them
+to ``/usr/bin/``. You do not need to change the names (e.g. to
+``docutils-rst2html.py``) because the ``rst2`` prefix is unique.
Documentation
Modified: trunk/docutils/docs/dev/policies.txt
===================================================================
--- trunk/docutils/docs/dev/policies.txt 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/docs/dev/policies.txt 2020-02-06 12:47:44 UTC (rev 8489)
@@ -622,35 +622,58 @@
When making changes to the code, testing is a must. The code should
be run to verify that it produces the expected results, and the entire
test suite should be run too. The modified Docutils code has to be
-accessible to Python for the tests to have any meaning. There are two
+accessible to Python for the tests to have any meaning. There are several
ways to keep the Docutils code accessible during development:
1. Update your ``PYTHONPATH`` environment variable so that Python
- picks up your local working copy of the code. This is the
- recommended method.
+ picks up your local working copy of the code.
- We'll assume that the Docutils trunk is checked out under your
- ~/projects/ directory as follows::
+ We'll assume that the `Docutils trunk`__ is checked out under your
+ ``~/projects/`` directory.
- svn co https://<user>@docutils.svn.sourceforge.net/svnroot/docutils/trunk \
- docutils
-
For the bash shell, add this to your ``~/.profile``::
PYTHONPATH=$HOME/projects/docutils/docutils
- PYTHONPATH=$PYTHONPATH:$HOME/projects/docutils/docutils/extras
+ PYTHONPATH=$PYTHONPATH:$HOME/projects/docutils/docutils
export PYTHONPATH
The first line points to the directory containing the ``docutils``
package. The second line adds the directory containing the
third-party modules Docutils depends on. The third line exports
- this environment variable. You may also wish to add the ``tools``
- directory to your ``PATH``::
+ this environment variable.
+ You many also want to add the ``tools`` directory to your binary ``PATH``::
+
PATH=$PATH:$HOME/projects/docutils/docutils/tools
export PATH
-2. Before you run anything, every time you make a change, reinstall
+ __ repository.html
+
+2. Create a symlink to the docutils package directory somewhere in the
+ module serach path (``sys.path``), e.g., ::
+
+ ln -s ~/projects/docutils/docutils \
+ /usr/local/lib/python2.7/site-packages/
+
+ Alternatively, use a `path configuration file`__.
+
+ __ https://docs.python.org/library/site.html
+
+ You may also want to copy or link the front-end tools in
+ ``docutils/tools`` to a suitable place in your binary PATH, e.g., ::
+
+ ln -s ~/projects/docutils/docutils/tools/rst2html.py \
+ /usr/local/bin/rst2html
+
+3. Do an `editable install`__ with pip.
+
+ __ https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs
+
+4. Install in `development mode`__ with setuptools.
+
+ __ https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
+
+5. Before you run anything, every time you make a change, reinstall
Docutils::
python setup.py install
@@ -670,7 +693,7 @@
containing the following lines::
# source this file
- export PYTHONPATH=$PWD:$PWD/extras
+ export PYTHONPATH=$PWD:$PWD
export PATH=$PWD/tools:$PATH
Open a shell for this branch, ``cd`` to the ``docutils`` top-level
@@ -738,9 +761,8 @@
...
tools/ # For front ends etc.
...
- setup.py # Use Distutils to install the component
- # code and tools/ files into the right
- # places in Docutils.
+ setup.py # Install the component code and tools/ files
+ # into the right places.
userid/ # For *temporary* personal space.
Some sandbox projects are destined to move to the Docutils core once
Modified: trunk/docutils/docs/dev/release.txt
===================================================================
--- trunk/docutils/docs/dev/release.txt 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/docs/dev/release.txt 2020-02-06 12:47:44 UTC (rev 8489)
@@ -126,7 +126,7 @@
or via the [Download Snapshot] button at
http://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
- (c) Use Distutils to create the release tarball::
+ (c) Use `setuptools` to create the release tarball::
cd docutils
python setup.py sdist
Modified: trunk/docutils/docs/dev/repository.txt
===================================================================
--- trunk/docutils/docs/dev/repository.txt 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/docs/dev/repository.txt 2020-02-06 12:47:44 UTC (rev 8489)
@@ -107,6 +107,14 @@
svn update
+Switching the Repository Root
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you changed your mind and want to use a different repository root,
+``cd`` into your working copy and type::
+
+ svn switch --relocate OLDROOT NEWROOT
+
Creating a local git clone
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -118,14 +126,7 @@
.. _git documentation: http://git-scm.com/documentation
-Switching the Repository Root
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you changed your mind and want to use a different repository root,
-``cd`` into your working copy and type::
-
- svn switch --relocate OLDROOT NEWROOT
-
.. _developer access:
Information for Developers
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2020-02-06 12:47:34 UTC (rev 8488)
+++ trunk/docutils/setup.py 2020-02-06 12:47:44 UTC (rev 8489)
@@ -12,9 +12,13 @@
from setuptools import setup
except ImportError:
print('Error: The "setuptools" module, which is required for the')
- print('installation of Docutils, could not be found. You may need to ')
- print('install a package called "python-setuptools" (or similar) on your ')
- print('system using your package manager.')
+ print(' installation of Docutils, could not be found.\n')
+ print(' You may install it with `python -m pip install setuptools`')
+ print(' or from a package called "python-setuptools" (or similar)')
+ print(' using your system\'s package manager.\n')
+ print(' Alternatively, install a release from PyPi with')
+ print(' `python -m pip install docutils`.')
+
sys.exit(1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-03-14 17:03:54
|
Revision: 8501
http://sourceforge.net/p/docutils/code/8501
Author: milde
Date: 2020-03-14 17:03:52 +0000 (Sat, 14 Mar 2020)
Log Message:
-----------
Apply patch #165: Fix error when copying `system_message` node.
Thanks to Takeshi KOMIYA.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-03-03 20:53:38 UTC (rev 8500)
+++ trunk/docutils/HISTORY.txt 2020-03-14 17:03:52 UTC (rev 8501)
@@ -33,6 +33,10 @@
- VersionInfo: ValueError for invalid values, fix comparison to tuples.
+* docutils/nodes.py
+
+ - Apply patch #165: Fix error when copying `system_message` node.
+
* docutils/utils/smartquotes.py
- Fix [ 383 ]: Smart quotes around opening and separator characters.
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-03-03 20:53:38 UTC (rev 8500)
+++ trunk/docutils/docutils/nodes.py 2020-03-14 17:03:52 UTC (rev 8501)
@@ -1775,7 +1775,7 @@
"""
def __init__(self, message=None, *children, **attributes):
- rawsource = attributes.get('rawsource', '')
+ rawsource = attributes.pop('rawsource', '')
if message:
p = paragraph('', message)
children = (p,) + children
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2020-03-03 20:53:38 UTC (rev 8500)
+++ trunk/docutils/test/test_nodes.py 2020-03-14 17:03:52 UTC (rev 8501)
@@ -607,14 +607,14 @@
return x not in self.testlist
def test_copy(self):
- grandchild = nodes.Text('mytext')
- child = nodes.emphasis('mytext', grandchild, att='child')
- e = nodes.Element('mytext', child, att='e')
+ grandchild = nodes.Text('grandchild text')
+ child = nodes.emphasis('childtext', grandchild, att='child')
+ e = nodes.Element('raw text', child, att='e')
# Shallow copy:
e_copy = e.copy()
self.assertTrue(e is not e_copy)
# Internal attributes (like `rawsource`) are also copied.
- self.assertEqual(e.rawsource, 'mytext')
+ self.assertEqual(e.rawsource, 'raw text')
self.assertEqual(e_copy.rawsource, e.rawsource)
self.assertEqual(e_copy['att'], 'e')
self.assertEqual(e_copy.document, e.document)
@@ -631,7 +631,17 @@
self.assertTrue(e_deepcopy[0][0] is not grandchild)
self.assertEqual(e_deepcopy[0]['att'], 'child')
+ def test_system_message_copy(self):
+ e = nodes.system_message('mytext', att='e', rawsource='raw text')
+ # Shallow copy:
+ e_copy = e.copy()
+ self.assertTrue(e is not e_copy)
+ # Internal attributes (like `rawsource`) are also copied.
+ self.assertEqual(e.rawsource, 'raw text')
+ self.assertEqual(e_copy.rawsource, e.rawsource)
+ self.assertEqual(e_copy['att'], 'e')
+
class TreeCopyVisitorTests(unittest.TestCase):
def setUp(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-04-03 16:57:38
|
Revision: 8510
http://sourceforge.net/p/docutils/code/8510
Author: milde
Date: 2020-04-03 16:57:36 +0000 (Fri, 03 Apr 2020)
Log Message:
-----------
html5 writer: wrap image elements in <p> unless inline or in figure.
In HTML, <img> is by default an inline element.
The rST "image" directive generates block-level elements
(unless used in a "substitution" directive).
Wrapping in a container enables more advanced CSS styling.
A paragraph as wrapper fits well with Docutils wrapping
inline content in paragraphs by default.
No change for the "html4css1" writer (ensure backwards compatibility).
Modified Paths:
--------------
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2020-03-31 10:30:02 UTC (rev 8509)
+++ trunk/docutils/docutils/writers/_html_base.py 2020-04-03 16:57:36 UTC (rev 8510)
@@ -957,13 +957,13 @@
del atts[att_name]
if style:
atts['style'] = ' '.join(style)
- if (isinstance(node.parent, nodes.TextElement) or
- (isinstance(node.parent, nodes.reference) and
- not isinstance(node.parent.parent, nodes.TextElement))):
- # Inline context or surrounded by <a>...</a>.
+ if isinstance(node.parent, (nodes.figure, nodes.compound)):
+ suffix = '\n'
+ elif not isinstance(node.parent, (nodes.TextElement, nodes.reference)):
+ self.body.append('<p class="image-wrapper">')
+ suffix = '</p>\n'
+ else:
suffix = ''
- else:
- suffix = '\n'
if 'align' in node:
atts['class'] = 'align-%s' % node['align']
if ext in self.object_image_types:
@@ -1325,6 +1325,8 @@
atts['class'] += ' internal'
if not isinstance(node.parent, nodes.TextElement):
assert len(node) == 1 and isinstance(node[0], nodes.image)
+ if not isinstance(node.parent, (nodes.figure, nodes.compound)):
+ self.body.append('<p class="image-wrapper">')
atts['class'] += ' image-reference'
self.body.append(self.starttag(node, 'a', '', **atts))
@@ -1331,6 +1333,8 @@
def depart_reference(self, node):
self.body.append('</a>')
if not isinstance(node.parent, nodes.TextElement):
+ if not isinstance(node.parent, (nodes.figure, nodes.compound)):
+ self.body.append('</p>')
self.body.append('\n')
self.in_mailto = False
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2020-03-31 10:30:02 UTC (rev 8509)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2020-04-03 16:57:36 UTC (rev 8510)
@@ -15,10 +15,14 @@
__docformat__ = 'reStructuredText'
import os.path
+import re
+import sys
+
import docutils
from docutils import frontend, nodes, writers, io
from docutils.transforms import writer_aux
from docutils.writers import _html_base
+from docutils.writers._html_base import PIL, url2pathname
class Writer(writers._html_base.Writer):
@@ -531,6 +535,75 @@
object_image_types = {'.svg': 'image/svg+xml',
'.swf': 'application/x-shockwave-flash'}
+ # do not wrap block-level images in <p></p> (for backwards compatibility)
+ def visit_image(self, node):
+ atts = {}
+ uri = node['uri']
+ ext = os.path.splitext(uri)[1].lower()
+ if ext in self.object_image_types:
+ atts['data'] = uri
+ atts['type'] = self.object_image_types[ext]
+ else:
+ atts['src'] = uri
+ atts['alt'] = node.get('alt', uri)
+ # image size
+ if 'width' in node:
+ atts['width'] = node['width']
+ if 'height' in node:
+ atts['height'] = node['height']
+ if 'scale' in node:
+ if (PIL and not ('width' in node and 'height' in node)
+ and self.settings.file_insertion_enabled):
+ imagepath = url2pathname(uri)
+ try:
+ img = PIL.Image.open(
+ imagepath.encode(sys.getfilesystemencoding()))
+ except (IOError, UnicodeEncodeError):
+ pass # TODO: warn?
+ else:
+ self.settings.record_dependencies.add(
+ imagepath.replace('\\', '/'))
+ if 'width' not in atts:
+ atts['width'] = '%dpx' % img.size[0]
+ if 'height' not in atts:
+ atts['height'] = '%dpx' % img.size[1]
+ del img
+ for att_name in 'width', 'height':
+ if att_name in atts:
+ match = re.match(r'([0-9.]+)(\S*)$', atts[att_name])
+ assert match
+ atts[att_name] = '%s%s' % (
+ float(match.group(1)) * (float(node['scale']) / 100),
+ match.group(2))
+ style = []
+ for att_name in 'width', 'height':
+ if att_name in atts:
+ if re.match(r'^[0-9.]+$', atts[att_name]):
+ # Interpret unitless values as pixels.
+ atts[att_name] += 'px'
+ style.append('%s: %s;' % (att_name, atts[att_name]))
+ del atts[att_name]
+ if style:
+ atts['style'] = ' '.join(style)
+ if (isinstance(node.parent, nodes.TextElement) or
+ (isinstance(node.parent, nodes.reference) and
+ not isinstance(node.parent.parent, nodes.TextElement))):
+ # Inline context or surrounded by <a>...</a>.
+ suffix = ''
+ else:
+ suffix = '\n'
+ if 'align' in node:
+ atts['class'] = 'align-%s' % node['align']
+ if ext in self.object_image_types:
+ # do NOT use an empty tag: incorrect rendering in browsers
+ self.body.append(self.starttag(node, 'object', suffix, **atts) +
+ node.get('alt', uri) + '</object>' + suffix)
+ else:
+ self.body.append(self.emptytag(node, 'img', suffix, **atts))
+
+ def depart_image(self, node):
+ pass
+
# use table for footnote text,
# context added in footnote_backrefs.
def visit_label(self, node):
@@ -665,6 +738,32 @@
def depart_paragraph(self, node):
self.body.append(self.context.pop())
+ # do not wrap images in paragraphs (for backwards compatibility)
+ def visit_reference(self, node):
+ atts = {'class': 'reference'}
+ if 'refuri' in node:
+ atts['href'] = node['refuri']
+ if ( self.settings.cloak_email_addresses
+ and atts['href'].startswith('mailto:')):
+ atts['href'] = self.cloak_mailto(atts['href'])
+ self.in_mailto = True
+ atts['class'] += ' external'
+ else:
+ assert 'refid' in node, \
+ 'References must have "refuri" or "refid" attribute.'
+ 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'
+ self.body.append(self.starttag(node, 'a', '', **atts))
+
+ def depart_reference(self, node):
+ self.body.append('</a>')
+ if not isinstance(node.parent, nodes.TextElement):
+ self.body.append('\n')
+ self.in_mailto = False
+
# ersatz for first/last pseudo-classes
def visit_sidebar(self, node):
self.body.append(
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-03-31 10:30:02 UTC (rev 8509)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:57:36 UTC (rev 8510)
@@ -567,18 +567,18 @@
<section id="images-and-figures">
<h3><a class="toc-backref" href="#toc-entry-54"><span class="sectnum">2.14.2</span> Images and Figures</a></h3>
<p>An image directive (also clickable -- a hyperlink reference):</p>
-<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 class="image-wrapper"><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>
<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 class="image-wrapper"><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>
<p>A centered image:</p>
-<img alt="../../../docs/user/rst/images/biohazard.png" class="align-center" src="../../../docs/user/rst/images/biohazard.png" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" class="align-center" src="../../../docs/user/rst/images/biohazard.png" /></p>
<p>A left-aligned image:</p>
-<img alt="../../../docs/user/rst/images/biohazard.png" class="align-left" src="../../../docs/user/rst/images/biohazard.png" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" class="align-left" src="../../../docs/user/rst/images/biohazard.png" /></p>
<p>This paragraph might flow around the image.
The specific behavior depends upon the style sheet and
the browser or rendering software used.</p>
<p>A right-aligned image:</p>
-<img alt="../../../docs/user/rst/images/biohazard.png" class="align-right" src="../../../docs/user/rst/images/biohazard.png" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" class="align-right" src="../../../docs/user/rst/images/biohazard.png" /></p>
<p>This paragraph might flow around the image.
The specific behavior depends upon the style sheet and
the browser or rendering software used.</p>
@@ -585,13 +585,13 @@
<p>For inline images see <a class="reference internal" href="#substitution-definitions">Substitution Definitions</a>.</p>
<p>Image size:</p>
<p>An image 2 em wide:</p>
-<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em;" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em;" /></p>
<p>An image 2 em wide and 15 pixel high:</p>
-<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em; height: 15px;" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em; height: 15px;" /></p>
<p>An image occupying 50% of the line width:</p>
-<img alt="../../../docs/user/rst/images/title.png" src="../../../docs/user/rst/images/title.png" style="width: 50%;" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/title.png" src="../../../docs/user/rst/images/title.png" style="width: 50%;" /></p>
<p>An image 2 cm high:</p>
-<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="height: 2cm;" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="height: 2cm;" /></p>
<p>A <em>figure</em> is an image with a caption and/or a legend. With page-based output
media, figures might float to a different position if this helps the page
layout.</p>
@@ -1238,7 +1238,7 @@
<h1><a class="toc-backref" href="#toc-entry-41"><span class="sectnum">3</span> HTML specific</a></h1>
<section id="svg-images">
<h2><a class="toc-backref" href="#toc-entry-42"><span class="sectnum">3.1</span> SVG Images</a></h2>
-<img alt="../../../docs/user/rst/images/biohazard.svg" class="align-left" src="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" />
+<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.svg" class="align-left" src="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" /></p>
<p>Scalable vector graphics (SVG) images are the only standards-compliable way
to include vector graphics in HTML documents. However, they are not
supported by all backends/output formats. (E.g., LaTeX supports the
@@ -1273,30 +1273,30 @@
SVG image is scaled or clipped/padded. Images wrapped in <span class="docutils literal"><img></span> are
always scaled.</p>
<ul>
-<li><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" /></p>
<p>A scaling image (scales with the browser window), occupying 50% of the line
width. The <span class="docutils literal">viewBox</span> setting in the image file enables auto-scaling also in
<span class="docutils literal"><object></span> tags and embedded SVG (if width and hight are set to 100% in the
SVG <image> tag).</p>
</li>
-<li><img alt="../../../docs/user/rst/images/title.svg" class="align-right" src="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/title.svg" class="align-right" src="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" /></p>
<p>A fixed-size image in a box 50% wide and 15 pixles high. This image is
scaled, if wrapped in an <span class="docutils literal"><img></span> tag but clipped in an <span class="docutils literal"><object></span> tag
or within SVG.</p>
</li>
-<li><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.5em;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.5em;" /></p>
<p>A right aligned, scaling image 50% wide and 1.5 em high. (This SVG image
keeps the aspect ratio.)</p>
</li>
<li><p>An inline image <img alt="inline-svg" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 0.8em;" /> scaled to a height of 0.8 em.</p>
</li>
-<li><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" /></p>
<p>A scaling image 1 em high, right aligned:</p>
</li>
<li><p>A scaling image 5 mm x 5 mm, centered, with hyperlink reference:</p>
-<a class="reference internal image-reference" href="#svg-images"><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-center" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm; height: 5mm;" /></a>
+<p class="image-wrapper"><a class="reference internal image-reference" href="#svg-images"><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-center" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm; height: 5mm;" /></a></p>
</li>
-<li><img alt="../../../docs/user/rst/images/biohazard.svg" class="align-right" src="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.svg" class="align-right" src="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" /></p>
<p>A fixed-size image in a 4 cm x 2 em box.</p>
</li>
</ul>
@@ -1304,12 +1304,12 @@
konqueror) support the <span class="docutils literal"><img></span> tag but don't display contained bitmap
images in this case.</p>
<ul>
-<li><img alt="../../../docs/user/rst/images/biohazard-bitmap.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap.svg" style="width: 3em;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard-bitmap.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap.svg" style="width: 3em;" /></p>
<p>A small, fixed-size SVG image with embedded bitmap, The <span class="docutils literal">:width:</span> is
set to 3 em in the rST source. Does not scale if wrapped in <span class="docutils literal"><object></span>
tags.</p>
</li>
-<li><img alt="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" style="width: 3em;" />
+<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" style="width: 3em;" /></p>
<p>A scaling SVG image with embedded bitmap, 3 em wide.</p>
</li>
</ul>
@@ -1330,8 +1330,8 @@
concerns.</p>
<p>Images with extension <span class="docutils literal">.swf</span> are placed inside <object> elements.
For complete control over display options use raw HTML.</p>
-<object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash">
-[biohazard.swf]</object>
+<p class="image-wrapper"><object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash"></p>
+[biohazard.swf]</object></p>
<p>An SWF image in a 4 cm x 2 em box, left aligned.</p>
<p>An inline SWF image <object data="../../../docs/user/rst/images/biohazard.swf" style="width: 0.8em; height: 0.8em;" type="application/x-shockwave-flash">inline-swf</object> scaled to 0.8 em x 0.8 em.</p>
</section>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-04-03 16:57:48
|
Revision: 8511
http://sourceforge.net/p/docutils/code/8511
Author: milde
Date: 2020-04-03 16:57:47 +0000 (Fri, 03 Apr 2020)
Log Message:
-----------
html5 writer: classify image references also for inline images.
Add "inmage-reference" to the class arguments for all references
that contain only one image node.
Allows CSS styling to underline text links but not image links.
Modified Paths:
--------------
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2020-04-03 16:57:36 UTC (rev 8510)
+++ trunk/docutils/docutils/writers/_html_base.py 2020-04-03 16:57:47 UTC (rev 8511)
@@ -1323,11 +1323,12 @@
'References must have "refuri" or "refid" attribute.'
atts['href'] = '#' + node['refid']
atts['class'] += ' internal'
+ if len(node) == 1 and isinstance(node[0], nodes.image):
+ atts['class'] += ' image-reference'
if not isinstance(node.parent, nodes.TextElement):
assert len(node) == 1 and isinstance(node[0], nodes.image)
if not isinstance(node.parent, (nodes.figure, nodes.compound)):
self.body.append('<p class="image-wrapper">')
- atts['class'] += ' image-reference'
self.body.append(self.starttag(node, 'a', '', **atts))
def depart_reference(self, node):
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:57:36 UTC (rev 8510)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:57:47 UTC (rev 8511)
@@ -1833,7 +1833,7 @@
</main>
<footer>
<p>Document footer</p>
-<p><a class="reference external" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
+<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
</footer>
</body>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-04-03 16:58:20
|
Revision: 8513
http://sourceforge.net/p/docutils/code/8513
Author: milde
Date: 2020-04-03 16:58:18 +0000 (Fri, 03 Apr 2020)
Log Message:
-----------
html writer: Drop spurious suffix after <object> starttag.
Also backported to html4css1 to fix possible spurious
whitespace after inline images.
Modified Paths:
--------------
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/input/data/svg_images.txt
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2020-04-03 16:58:00 UTC (rev 8512)
+++ trunk/docutils/docutils/writers/_html_base.py 2020-04-03 16:58:18 UTC (rev 8513)
@@ -968,7 +968,7 @@
atts['class'] = 'align-%s' % node['align']
if ext in self.object_image_types:
# do NOT use an empty tag: incorrect rendering in browsers
- self.body.append(self.starttag(node, 'object', suffix, **atts) +
+ self.body.append(self.starttag(node, 'object', '', **atts) +
node.get('alt', uri) + '</object>' + suffix)
else:
self.body.append(self.emptytag(node, 'img', suffix, **atts))
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2020-04-03 16:58:00 UTC (rev 8512)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2020-04-03 16:58:18 UTC (rev 8513)
@@ -596,7 +596,7 @@
atts['class'] = 'align-%s' % node['align']
if ext in self.object_image_types:
# do NOT use an empty tag: incorrect rendering in browsers
- self.body.append(self.starttag(node, 'object', suffix, **atts) +
+ self.body.append(self.starttag(node, 'object', '', **atts) +
node.get('alt', uri) + '</object>' + suffix)
else:
self.body.append(self.emptytag(node, 'img', suffix, **atts))
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2020-04-03 16:58:00 UTC (rev 8512)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2020-04-03 16:58:18 UTC (rev 8513)
@@ -1247,8 +1247,7 @@
</div>
<div class="section" id="svg-images">
<h2><a class="toc-backref" href="#toc-entry-41">2.24 SVG Images</a></h2>
-<object class="align-left" data="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" type="image/svg+xml">
-../../../docs/user/rst/images/biohazard.svg</object>
+<object class="align-left" data="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" type="image/svg+xml">../../../docs/user/rst/images/biohazard.svg</object>
<p>Scalable vector graphics (SVG) images are the only standards-compliable way
to include vector graphics in HTML documents. However, they are not
supported by all backends/output formats. (E.g., LaTeX supports the
@@ -1285,35 +1284,30 @@
SVG image is scaled or clipped/padded. Images wrapped in <tt class="docutils literal"><img></tt> are
always scaled.</p>
<ul>
-<li><object class="first align-right" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" type="image/svg+xml">
-../../../docs/user/rst/images/title-scaling.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" type="image/svg+xml">../../../docs/user/rst/images/title-scaling.svg</object>
<p>A scaling image (scales with the browser window), occupying 50% of the line
width. The <tt class="docutils literal">viewBox</tt> setting in the image file enables auto-scaling also in
<tt class="docutils literal"><object></tt> tags and embedded SVG (if width and hight are set to 100% in the
SVG <image> tag).</p>
</li>
-<li><object class="first align-right" data="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" type="image/svg+xml">
-../../../docs/user/rst/images/title.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" type="image/svg+xml">../../../docs/user/rst/images/title.svg</object>
<p>A fixed-size image in a box 50% wide and 15 pixles high. This image is
scaled, if wrapped in an <tt class="docutils literal"><img></tt> tag but clipped in an <tt class="docutils literal"><object></tt> tag
or within SVG.</p>
</li>
-<li><object class="first align-right" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.5em;" type="image/svg+xml">
-../../../docs/user/rst/images/title-scaling.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.5em;" type="image/svg+xml">../../../docs/user/rst/images/title-scaling.svg</object>
<p>A right aligned, scaling image 50% wide and 1.5 em high. (This SVG image
keeps the aspect ratio.)</p>
</li>
<li><p class="first">An inline image <object data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 0.8em;" type="image/svg+xml">inline-svg</object> scaled to a height of 0.8 em.</p>
</li>
-<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" type="image/svg+xml">
-../../../docs/user/rst/images/biohazard-scaling.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" type="image/svg+xml">../../../docs/user/rst/images/biohazard-scaling.svg</object>
<p>A scaling image 1 em high, right aligned:</p>
</li>
<li><p class="first">A scaling image 5 mm x 5 mm, centered, with hyperlink reference:</p>
<a class="reference internal image-reference" href="#svg-images"><object class="align-center" data="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm; height: 5mm;" type="image/svg+xml">../../../docs/user/rst/images/biohazard-scaling.svg</object></a>
</li>
-<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" type="image/svg+xml">
-../../../docs/user/rst/images/biohazard.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" type="image/svg+xml">../../../docs/user/rst/images/biohazard.svg</object>
<p>A fixed-size image in a 4 cm x 2 em box.</p>
</li>
</ul>
@@ -1321,14 +1315,12 @@
konqueror) support the <tt class="docutils literal"><img></tt> tag but don't display contained bitmap
images in this case.</p>
<ul>
-<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard-bitmap.svg" style="width: 3em;" type="image/svg+xml">
-../../../docs/user/rst/images/biohazard-bitmap.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard-bitmap.svg" style="width: 3em;" type="image/svg+xml">../../../docs/user/rst/images/biohazard-bitmap.svg</object>
<p>A small, fixed-size SVG image with embedded bitmap, The <tt class="docutils literal">:width:</tt> is
set to 3 em in the rST source. Does not scale if wrapped in <tt class="docutils literal"><object></tt>
tags.</p>
</li>
-<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" style="width: 3em;" type="image/svg+xml">
-../../../docs/user/rst/images/biohazard-bitmap-scaling.svg</object>
+<li><object class="first align-right" data="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" style="width: 3em;" type="image/svg+xml">../../../docs/user/rst/images/biohazard-bitmap-scaling.svg</object>
<p>A scaling SVG image with embedded bitmap, 3 em wide.</p>
</li>
</ul>
@@ -1335,9 +1327,8 @@
<p>SVG images can also be put in figures:</p>
<blockquote>
<div class="figure align-center">
-<object data="../../../docs/user/rst/images/title.svg" style="width: 290px; height: 28px;" type="image/svg+xml">
-reStructuredText, the markup syntax</object>
-<p class="caption"><strong>Figure:</strong> SVG image in a figure.</p>
+<object data="../../../docs/user/rst/images/title.svg" style="width: 290px; height: 28px;" type="image/svg+xml">reStructuredText, the markup syntax</object>
+<p class="caption">SVG image in a figure.</p>
</div>
</blockquote>
</div>
@@ -1348,8 +1339,7 @@
concerns.</p>
<p>Images with extension <tt class="docutils literal">.swf</tt> are placed inside <object> elements.
For complete control over display options use raw HTML.</p>
-<object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash">
-[biohazard.swf]</object>
+<object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash">[biohazard.swf]</object>
<p>An SWF image in a 4 cm x 2 em box, left aligned.</p>
<p>An inline SWF image <object data="../../../docs/user/rst/images/biohazard.swf" style="width: 0.8em; height: 0.8em;" type="application/x-shockwave-flash">inline-swf</object> scaled to 0.8 em x 0.8 em.</p>
</div>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:58:00 UTC (rev 8512)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:58:18 UTC (rev 8513)
@@ -1318,7 +1318,7 @@
<figure class="align-center">
<img alt="reStructuredText, the markup syntax" src="../../../docs/user/rst/images/title.svg" style="width: 290px; height: 28px;" />
<figcaption>
-<p><strong>Figure:</strong> SVG image in a figure.</p>
+<p>SVG image in a figure.</p>
</figcaption>
</figure>
</blockquote>
@@ -1330,8 +1330,7 @@
concerns.</p>
<p>Images with extension <span class="docutils literal">.swf</span> are placed inside <object> elements.
For complete control over display options use raw HTML.</p>
-<p class="image-wrapper"><object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash"></p>
-[biohazard.swf]</object></p>
+<p class="image-wrapper"><object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash">[biohazard.swf]</object></p>
<p>An SWF image in a 4 cm x 2 em box, left aligned.</p>
<p>An inline SWF image <object data="../../../docs/user/rst/images/biohazard.swf" style="width: 0.8em; height: 0.8em;" type="application/x-shockwave-flash">inline-swf</object> scaled to 0.8 em x 0.8 em.</p>
</section>
Modified: trunk/docutils/test/functional/input/data/svg_images.txt
===================================================================
--- trunk/docutils/test/functional/input/data/svg_images.txt 2020-04-03 16:58:00 UTC (rev 8512)
+++ trunk/docutils/test/functional/input/data/svg_images.txt 2020-04-03 16:58:18 UTC (rev 8513)
@@ -124,4 +124,4 @@
:height: 28 px
:align: center
- **Figure:** SVG image in a figure.
+ SVG image in a figure.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-04-03 16:58:55
|
Revision: 8515
http://sourceforge.net/p/docutils/code/8515
Author: milde
Date: 2020-04-03 16:58:53 +0000 (Fri, 03 Apr 2020)
Log Message:
-----------
html5: support numbered figures (with CSS styling, analogue to tables).
Modified Paths:
--------------
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
trunk/docutils/docutils/writers/html5_polyglot/plain.css
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/input/standalone_rst_html5.txt
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2020-04-03 16:58:35 UTC (rev 8514)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2020-04-03 16:58:53 UTC (rev 8515)
@@ -201,8 +201,6 @@
table.align-right {
margin-left: auto;
}
-.figure.align-center, .figure.align-right,
-figure.align-center, figure.align-right,
img.align-center, img.align-right,
object.align-center, object.align-right {
display: block;
Modified: trunk/docutils/docutils/writers/html5_polyglot/plain.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/plain.css 2020-04-03 16:58:35 UTC (rev 8514)
+++ trunk/docutils/docutils/writers/html5_polyglot/plain.css 2020-04-03 16:58:53 UTC (rev 8515)
@@ -28,11 +28,11 @@
div.document,
main {
line-height:1.3;
- counter-reset: table;
- /* counter-reset: figure; */
+ counter-reset: table figure;
/* avoid long lines --> better reading */
+ /* optimum is 45…75 characters/line <http://webtypography.net/2.1.2> */
/* OTOH: lines should not be too short because of missing hyphenation, */
- max-width: 50em;
+ max-width: 50em;
padding: 1px 2%; /* 1px on top avoids grey bar above title (mozilla) */
margin: auto;
background-color: white;
@@ -222,6 +222,14 @@
/* Stop floating sidebars, images and figures at section level 1,2,3 */
h1, h2, h3 { clear: both; }
+/* Numbered figures */
+figure.numbered > figcaption > p:before {
+ counter-increment: figure;
+ content: "Figure " counter(figure) ": ";
+ font-weight: bold;
+}
+
+
/* Admonitions and System Messages */
div.admonition,
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:58:35 UTC (rev 8514)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-04-03 16:58:53 UTC (rev 8515)
@@ -156,11 +156,12 @@
<li><p><a class="reference internal" href="#description-lists" id="toc-entry-50"><span class="sectnum">4.2.1</span> Description lists</a></p></li>
<li><p><a class="reference internal" href="#field-list-variants" id="toc-entry-51"><span class="sectnum">4.2.2</span> Field list variants</a></p></li>
<li><p><a class="reference internal" href="#table-variants" id="toc-entry-52"><span class="sectnum">4.2.3</span> Table variants</a></p></li>
+<li><p><a class="reference internal" href="#numbered-figures" id="toc-entry-53"><span class="sectnum">4.2.4</span> Numbered Figures</a></p></li>
</ul>
</li>
</ul>
</li>
-<li><p><a class="reference internal" href="#error-handling" id="toc-entry-53"><span class="sectnum">5</span> Error Handling</a></p></li>
+<li><p><a class="reference internal" href="#error-handling" id="toc-entry-54"><span class="sectnum">5</span> Error Handling</a></p></li>
</ul>
</div>
<section id="structural-elements">
@@ -545,16 +546,16 @@
<h2><a class="toc-backref" href="#toc-entry-22"><span class="sectnum">2.14</span> Directives</a></h2>
<div class="contents local topic" id="contents">
<ul class="auto-toc simple">
-<li><p><a class="reference internal" href="#document-parts" id="toc-entry-54"><span class="sectnum">2.14.1</span> Document Parts</a></p></li>
-<li><p><a class="reference internal" href="#images-and-figures" id="toc-entry-55"><span class="sectnum">2.14.2</span> Images and Figures</a></p></li>
-<li><p><a class="reference internal" href="#tables" id="toc-entry-56"><span class="sectnum">2.14.3</span> Tables</a></p></li>
-<li><p><a class="reference internal" href="#admonitions" id="toc-entry-57"><span class="sectnum">2.14.4</span> Admonitions</a></p></li>
-<li><p><a class="reference internal" href="#topics-sidebars-and-rubrics" id="toc-entry-58"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></p></li>
-<li><p><a class="reference internal" href="#target-footnotes" id="toc-entry-59"><span class="sectnum">2.14.6</span> Target Footnotes</a></p></li>
-<li><p><a class="reference internal" href="#replacement-text" id="toc-entry-60"><span class="sectnum">2.14.7</span> Replacement Text</a></p></li>
-<li><p><a class="reference internal" href="#compound-paragraph" id="toc-entry-61"><span class="sectnum">2.14.8</span> Compound Paragraph</a></p></li>
-<li><p><a class="reference internal" href="#parsed-literal-blocks" id="toc-entry-62"><span class="sectnum">2.14.9</span> Parsed Literal Blocks</a></p></li>
-<li><p><a class="reference internal" href="#code" id="toc-entry-63"><span class="sectnum">2.14.10</span> Code</a></p></li>
+<li><p><a class="reference internal" href="#document-parts" id="toc-entry-55"><span class="sectnum">2.14.1</span> Document Parts</a></p></li>
+<li><p><a class="reference internal" href="#images-and-figures" id="toc-entry-56"><span class="sectnum">2.14.2</span> Images and Figures</a></p></li>
+<li><p><a class="reference internal" href="#tables" id="toc-entry-57"><span class="sectnum">2.14.3</span> Tables</a></p></li>
+<li><p><a class="reference internal" href="#admonitions" id="toc-entry-58"><span class="sectnum">2.14.4</span> Admonitions</a></p></li>
+<li><p><a class="reference internal" href="#topics-sidebars-and-rubrics" id="toc-entry-59"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></p></li>
+<li><p><a class="reference internal" href="#target-footnotes" id="toc-entry-60"><span class="sectnum">2.14.6</span> Target Footnotes</a></p></li>
+<li><p><a class="reference internal" href="#replacement-text" id="toc-entry-61"><span class="sectnum">2.14.7</span> Replacement Text</a></p></li>
+<li><p><a class="reference internal" href="#compound-paragraph" id="toc-entry-62"><span class="sectnum">2.14.8</span> Compound Paragraph</a></p></li>
+<li><p><a class="reference internal" href="#parsed-literal-blocks" id="toc-entry-63"><span class="sectnum">2.14.9</span> Parsed Literal Blocks</a></p></li>
+<li><p><a class="reference internal" href="#code" id="toc-entry-64"><span class="sectnum">2.14.10</span> Code</a></p></li>
</ul>
</div>
<p>These are just a sample of the many reStructuredText Directives. For
@@ -561,13 +562,13 @@
others, please see
<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>
<section id="document-parts">
-<h3><a class="toc-backref" href="#toc-entry-54"><span class="sectnum">2.14.1</span> Document Parts</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-55"><span class="sectnum">2.14.1</span> Document Parts</a></h3>
<p>An example of the "contents" directive can be seen above this section
(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>
</section>
<section id="images-and-figures">
-<h3><a class="toc-backref" href="#toc-entry-55"><span class="sectnum">2.14.2</span> Images and Figures</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-56"><span class="sectnum">2.14.2</span> Images and Figures</a></h3>
<p>An image directive (also clickable -- a hyperlink reference):</p>
<p class="image-wrapper"><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>
<p>Image with multiple IDs:</p>
@@ -666,7 +667,7 @@
upon the style sheet and the browser or rendering software used.</p>
</section>
<section id="tables">
-<h3><a class="toc-backref" href="#toc-entry-56"><span class="sectnum">2.14.3</span> Tables</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-57"><span class="sectnum">2.14.3</span> Tables</a></h3>
<p>Tables may be given titles and additional arguments with the <em>table</em>
directive:</p>
<table class="align-left">
@@ -760,7 +761,7 @@
</table>
</section>
<section id="admonitions">
-<h3><a class="toc-backref" href="#toc-entry-57"><span class="sectnum">2.14.4</span> Admonitions</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-58"><span class="sectnum">2.14.4</span> Admonitions</a></h3>
<div class="admonition attention">
<p class="admonition-title">Attention!</p>
<p>Directives at large.</p>
@@ -809,7 +810,7 @@
</div>
</section>
<section id="topics-sidebars-and-rubrics">
-<h3><a class="toc-backref" href="#toc-entry-58"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-59"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></h3>
<p><em>Sidebars</em> are like miniature, parallel documents.</p>
<aside class="sidebar">
<p class="sidebar-title">Sidebar Title</p>
@@ -833,7 +834,7 @@
allowed (e.g. inside a directive).</p>
</section>
<section id="target-footnotes">
-<h3><a class="toc-backref" href="#toc-entry-59"><span class="sectnum">2.14.6</span> Target Footnotes</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-60"><span class="sectnum">2.14.6</span> Target Footnotes</a></h3>
<dl class="footnote brackets">
<dt class="label" id="footnote-7"><span class="brackets">7</span><span class="fn-backref">(<a href="#footnote-reference-18">1</a>,<a href="#footnote-reference-19">2</a>,<a href="#footnote-reference-20">3</a>,<a href="#footnote-reference-25">4</a>)</span></dt>
<dd><p><a class="reference external" href="http://www.python.org/">http://www.python.org/</a></p>
@@ -862,11 +863,11 @@
</dl>
</section>
<section id="replacement-text">
-<h3><a class="toc-backref" href="#toc-entry-60"><span class="sectnum">2.14.7</span> Replacement Text</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-61"><span class="sectnum">2.14.7</span> 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 brackets" href="#footnote-7" id="footnote-reference-20">7</a>.</p>
</section>
<section id="compound-paragraph">
-<h3><a class="toc-backref" href="#toc-entry-61"><span class="sectnum">2.14.8</span> Compound Paragraph</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-62"><span class="sectnum">2.14.8</span> Compound Paragraph</a></h3>
<p>The <em>compound</em> directive is used to create a "compound paragraph", which
is a single logical paragraph containing multiple physical body
elements. For example:</p>
@@ -977,7 +978,7 @@
</div>
</section>
<section id="parsed-literal-blocks">
-<h3><a class="toc-backref" href="#toc-entry-62"><span class="sectnum">2.14.9</span> Parsed Literal Blocks</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-63"><span class="sectnum">2.14.9</span> Parsed Literal Blocks</a></h3>
<pre class="literal-block">This is a parsed literal block.
This line is indented. The next line is blank.
@@ -987,7 +988,7 @@
footnotes <a class="footnote-reference brackets" href="#footnote-1" id="footnote-reference-9">1</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
</section>
<section id="code">
-<h3><a class="toc-backref" href="#toc-entry-63"><span class="sectnum">2.14.10</span> Code</a></h3>
+<h3><a class="toc-backref" href="#toc-entry-64"><span class="sectnum">2.14.10</span> Code</a></h3>
<p>Blocks of source code can be set with the <cite>code</cite> directive. If the code
language is specified, the content is parsed and tagged by the <a class="reference external" href="http://pygments.org/">Pygments</a> <a class="footnote-reference brackets" href="#footnote-8" id="footnote-reference-21">8</a>
syntax highlighter and can be formatted with a style sheet. (Code parsing
@@ -1802,10 +1803,22 @@
</table>
</blockquote>
</section>
+<section id="numbered-figures">
+<h3><a class="toc-backref" href="#toc-entry-53"><span class="sectnum">4.2.4</span> Numbered Figures</a></h3>
+<p>Numbered figures can be achieved with the "numbered" <span class="docutils literal">:figclass:</span> option:</p>
+<blockquote>
+<figure class="numbered">
+<img alt="reStructuredText, the markup syntax" src="../../../docs/user/rst/images/title.svg" />
+<figcaption>
+<p>SVG image in a numbered figure.</p>
+</figcaption>
+</figure>
+</blockquote>
</section>
</section>
+</section>
<section id="error-handling">
-<h1><a class="toc-backref" href="#toc-entry-53"><span class="sectnum">5</span> Error Handling</a></h1>
+<h1><a class="toc-backref" href="#toc-entry-54"><span class="sectnum">5</span> 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, "Docutils System Messages":</p>
Modified: trunk/docutils/test/functional/input/standalone_rst_html5.txt
===================================================================
--- trunk/docutils/test/functional/input/standalone_rst_html5.txt 2020-04-03 16:58:35 UTC (rev 8514)
+++ trunk/docutils/test/functional/input/standalone_rst_html5.txt 2020-04-03 16:58:53 UTC (rev 8515)
@@ -189,6 +189,18 @@
True True True
======= ======= ==========
+Numbered Figures
+````````````````
+
+Numbered figures can be achieved with the "numbered" ``:figclass:`` option:
+
+ .. figure:: ../../../docs/user/rst/images/title.svg
+ :alt: reStructuredText, the markup syntax
+ :figclass: numbered
+
+ SVG image in a numbered figure.
+
+
.. include:: data/errors.txt
.. footer:: |HTML 5| |validator| |valid-CSS2|
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-05-20 05:39:53
|
Revision: 8516
http://sourceforge.net/p/docutils/code/8516
Author: milde
Date: 2020-05-20 05:39:50 +0000 (Wed, 20 May 2020)
Log Message:
-----------
Minor documentation updates/fixes.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-04-03 16:58:53 UTC (rev 8515)
+++ trunk/docutils/HISTORY.txt 2020-05-20 05:39:50 UTC (rev 8516)
@@ -40,7 +40,7 @@
* docutils/utils/smartquotes.py
- Fix [ 383 ]: Smart quotes around opening and separator characters.
-
+
* docutils/writers/html5_polyglot/
- Use the new semantic tags <main>, <section>, <header>,
@@ -50,10 +50,13 @@
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
<i>, <b>, <u>, <mark>, and <bdi> if a matching class value
is found in `inline` and `literal` elements.
-
- - Use HTML tags <ins> and <del> if a matching class value
+ Use <ins> and <del> if a matching class value
is found in `inline`, `literal`, or `container` elements.
+ - Wrap block-level image elements in <p> (except for figures).
+ Move non-essential styling from ``minimal.css`` to ``plain.css``.
+ Support numbered figures in ``plain.css``.
+
* docutils/writers/latex2e/__init__.py:
- Use LaTeX environments for admonitions and "class wrappers" for styling
@@ -69,7 +72,7 @@
- [ Fix #126 ] manpage title with spaces.
- [ Fix #380 ] commandline option problem in sphinx.
-
+
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-04-03 16:58:53 UTC (rev 8515)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-05-20 05:39:50 UTC (rev 8516)
@@ -25,6 +25,12 @@
change to "False". Adapt stylesheets modifying ``\DUadmonition``
and/or ``\DUtitle`` or set to "True".
+* HTML5 writer:
+ Do not use <h1> for section headings when it is used for the document
+ title. https://www.w3.org/wiki/HTML/Usage/Headings/h1only
+
+ Use <blockquote> instead of <div> tags for topics and admonitions.
+
* ``Node.traverse()`` will return an iterator instead of a list.
* Remove ``utils.unique_combinations``
@@ -78,10 +84,14 @@
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
<i>, <b>, <u>, <mark>, and <bdi> if a matching class value
is found in `inline` and `literal` elements.
-
- - Use HTML tags <ins> and <del> if a matching class value
+ Use <ins> and <del> if a matching class value
is found in `inline`, `literal`, or `container` elements.
+ - Wrap block-level image elements in <p> (except for figures).
+ Move non-essential styling from ``minimal.css`` to ``plain.css``.
+ Support numbered figures in ``plain.css``.
+
+
* LaTeX writer:
- New configuration setting `legacy_class_functions`_.
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2020-04-03 16:58:53 UTC (rev 8515)
+++ trunk/docutils/docs/user/config.txt 2020-05-20 05:39:50 UTC (rev 8516)
@@ -1506,9 +1506,9 @@
Default: no stylesheet (""). Option: ``--stylesheet``.
+__ `stylesheet [html writers]`_
__ `stylesheet_path [latex writers]`_
__ `embed_stylesheet [latex writers]`_
-__ `stylesheet [html writers]`_
.. _TeX input path:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=what-TDS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2020-06-30 20:34:16
|
Revision: 8519
http://sourceforge.net/p/docutils/code/8519
Author: grubert
Date: 2020-06-30 20:34:14 +0000 (Tue, 30 Jun 2020)
Log Message:
-----------
Apply Patch 168 manpage crashing on empty citation
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_writers/test_manpage.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-06-15 08:48:46 UTC (rev 8518)
+++ trunk/docutils/HISTORY.txt 2020-06-30 20:34:14 UTC (rev 8519)
@@ -70,8 +70,9 @@
* docutils/writers/manpage.py
- - [ Fix #126 ] manpage title with spaces.
- - [ Fix #380 ] commandline option problem in sphinx.
+ - Patch [ #168 ] fix crashing on empty citation (by Takeshi KOMIYA).
+ - Fix [ #126 ] manpage title with spaces.
+ - Fix [ #380 ] commandline option problem in sphinx.
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2020-06-15 08:48:46 UTC (rev 8518)
+++ trunk/docutils/docutils/writers/manpage.py 2020-06-30 20:34:14 UTC (rev 8519)
@@ -476,7 +476,7 @@
depart_caution = depart_admonition
def visit_citation(self, node):
- num, text = node.astext().split(None, 1)
+ num = node.astext().split(None, 1)[0]
num = num.strip()
self.body.append('.IP [%s] 5\n' % num)
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py 2020-06-15 08:48:46 UTC (rev 8518)
+++ trunk/docutils/test/test_writers/test_manpage.py 2020-06-30 20:34:14 UTC (rev 8519)
@@ -396,7 +396,25 @@
"""],
]
+totest['citation'] = [
+ [""".. [docutils] blah blah blah
+.. [empty_citation]
+""",
+ r""".\" Man page generated from reStructuredText.
+.
+.TH "" "" "" ""
+.SH NAME
+ \-
+"""+indend_macros+
+r""".IP [docutils] 5
+blah blah blah
+.IP [empty_citation] 5
+.\" Generated by docutils manpage writer.
+.
+"""],
+ ]
+
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-07-09 08:38:51
|
Revision: 8522
http://sourceforge.net/p/docutils/code/8522
Author: milde
Date: 2020-07-09 08:38:48 +0000 (Thu, 09 Jul 2020)
Log Message:
-----------
Apply version of patch #167 by Takeshi KOMIYA.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-07-05 16:08:53 UTC (rev 8521)
+++ trunk/docutils/HISTORY.txt 2020-07-09 08:38:48 UTC (rev 8522)
@@ -35,7 +35,10 @@
* docutils/nodes.py
- - Apply patch #165: Fix error when copying `system_message` node.
+ - Apply patch #165: Fix error when copying `system_message` node
+ (by Takeshi KOMIYA).
+ - Apply version of patch #167: Let document.set_id() register all
+ existing IDs (thanks to Takeshi KOMIYA).
* docutils/utils/smartquotes.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-07-05 16:08:53 UTC (rev 8521)
+++ trunk/docutils/docutils/nodes.py 2020-07-09 08:38:48 UTC (rev 8522)
@@ -1361,39 +1361,43 @@
return domroot
def set_id(self, node, msgnode=None, suggested_prefix=''):
- for id in node['ids']:
- 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']:
- id_prefix = self.settings.id_prefix
- auto_id_prefix = self.settings.auto_id_prefix
- base_id = ''
- id = ''
- for name in node['names']:
- base_id = make_id(name)
- id = id_prefix + base_id
- # TODO: allow names starting with numbers if `id_prefix`
- # is non-empty: id = make_id(id_prefix + name)
- if base_id and id not in self.ids:
+ if node['ids']:
+ # register and check for duplicates
+ for id in node['ids']:
+ self.ids.setdefault(id, node)
+ if self.ids[id] is not node:
+ msg = self.reporter.severe('Duplicate ID: "%s".' % id)
+ if msgnode != None:
+ msgnode += msg
+ return id
+ # generate and set id
+ id_prefix = self.settings.id_prefix
+ auto_id_prefix = self.settings.auto_id_prefix
+ base_id = ''
+ id = ''
+ for name in node['names']:
+ base_id = make_id(name)
+ id = id_prefix + base_id
+ # TODO: allow names starting with numbers if `id_prefix`
+ # is non-empty: id = make_id(id_prefix + name)
+ if base_id and id not in self.ids:
+ break
+ else:
+ if base_id and auto_id_prefix.endswith('%'):
+ # disambiguate name-derived ID
+ # TODO: remove second condition after announcing change
+ prefix = id + '-'
+ else:
+ prefix = id_prefix + auto_id_prefix
+ if prefix.endswith('%'):
+ prefix = '%s%s-' % (prefix[:-1], suggested_prefix
+ or make_id(node.tagname))
+ while True:
+ self.id_counter[prefix] += 1
+ id = '%s%d' % (prefix, self.id_counter[prefix])
+ if id not in self.ids:
break
- else:
- if base_id and auto_id_prefix.endswith('%'):
- # disambiguate name-derived ID
- # TODO: remove second condition after announcing change
- prefix = id + '-'
- else:
- prefix = id_prefix + auto_id_prefix
- if prefix.endswith('%'):
- prefix = '%s%s-' % (prefix[:-1], suggested_prefix
- or make_id(node.tagname))
- while True:
- self.id_counter[prefix] += 1
- id = '%s%d' % (prefix, self.id_counter[prefix])
- if id not in self.ids:
- break
- node['ids'].append(id)
+ node['ids'].append(id)
self.ids[id] = node
return id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-07-10 09:26:25
|
Revision: 8523
http://sourceforge.net/p/docutils/code/8523
Author: milde
Date: 2020-07-10 09:26:22 +0000 (Fri, 10 Jul 2020)
Log Message:
-----------
Support the `memoir` LaTeX document class.
Fixes #390, #391, and #392.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/latex.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Added Paths:
-----------
trunk/docutils/docutils/writers/latex2e/titlingpage.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/tests/latex_memoir.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-07-09 08:38:48 UTC (rev 8522)
+++ trunk/docutils/HISTORY.txt 2020-07-10 09:26:22 UTC (rev 8523)
@@ -19,7 +19,7 @@
* General
- - Fix [ 385 ]: Import of language modules.
+ - Fix #385: Import of language modules.
- Use importlib.import_module() to programmatically import modules.
- Remove legacy LaTeX stylesheet ``docutils-05-compat.sty``.
- Installing with ``setup.py`` now requires ``setuptools``.
@@ -42,7 +42,7 @@
* docutils/utils/smartquotes.py
- - Fix [ 383 ]: Smart quotes around opening and separator characters.
+ - Fix #383: Smart quotes around opening and separator characters.
* docutils/writers/html5_polyglot/
@@ -70,13 +70,16 @@
`styling command`__ prefix ``\docutilsrole``.
__ docs/user/latex.html#classes
+
+ - Support the `memoir` LaTeX document class.
+ Fixes #390, #391, and #392.
* docutils/writers/manpage.py
- - Fix [ 394 ] fix missing new line after rubric.
- - Patch [ #168 ] fix crashing on empty citation (by Takeshi KOMIYA).
- - Fix [ #126 ] manpage title with spaces.
- - Fix [ #380 ] commandline option problem in sphinx.
+ - Fix #394 fix missing new line after rubric.
+ - Patch #168 fix crashing on empty citation (by Takeshi KOMIYA).
+ - Fix #126 manpage title with spaces.
+ - Fix #380 commandline option problem in sphinx.
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Modified: trunk/docutils/docs/user/latex.txt
===================================================================
--- trunk/docutils/docs/user/latex.txt 2020-07-09 08:38:48 UTC (rev 8522)
+++ trunk/docutils/docs/user/latex.txt 2020-07-10 09:26:22 UTC (rev 8523)
@@ -375,7 +375,9 @@
template_
In addition to the 'default.tex' template, the latex writer directory
-contains the alternative 'titlepage.tex'.
+contains the alternatives 'titlepage.tex' (separete title page) and
+'titlinpage.tex'" (separate title page with the `memoir`_
+`document class`_).
Example:
Print a title page including docinfo, dedication, and abstract::
@@ -385,7 +387,6 @@
.. _publisher documentation: ../api/publisher.html
.. _template: config.html#template-latex2e-writer
-
Raw LaTeX
`````````
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-07-09 08:38:48 UTC (rev 8522)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-07-10 09:26:22 UTC (rev 8523)
@@ -653,7 +653,7 @@
PreambleCmds.optionlist = r"""
% optionlist environment
-\providecommand*{\DUoptionlistlabel}[1]{\bf #1 \hfill}
+\providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
\DUprovidelength{\DUoptionlistindent}{3cm}
\ifthenelse{\isundefined{\DUoptionlist}}{
\newenvironment{DUoptionlist}{%
@@ -1635,12 +1635,15 @@
self.out.append('%\n'.join(['\\raisebox{1em}{\\hypertarget{%s}{}}' %
id for id in node['ids']]))
- def ids_to_labels(self, node, set_anchor=True):
+ def ids_to_labels(self, node, set_anchor=True, protect=False):
"""Return list of label definitions for all ids of `node`
If `set_anchor` is True, an anchor is set with \\phantomsection.
+ If `protect` is True, the \label cmd is made robust.
"""
labels = ['\\label{%s}' % id for id in node.get('ids', [])]
+ if protect:
+ labels = ['\\protect'+label for label in labels]
if set_anchor and labels:
labels.insert(0, '\\phantomsection')
return labels
@@ -2023,7 +2026,9 @@
# titled document?
if (self.use_latex_docinfo or len(node) and
isinstance(node[0], nodes.title)):
- self.title_labels += self.ids_to_labels(node, set_anchor=False)
+ protect = (self.settings.documentclass == 'memoir')
+ self.title_labels += self.ids_to_labels(node, set_anchor=False,
+ protect=protect)
def depart_document(self, node):
# Complete header with information gained from walkabout
@@ -2937,7 +2942,9 @@
if isinstance(node.parent, nodes.document):
self.push_output_collector(self.subtitle)
self.fallbacks['documentsubtitle'] = PreambleCmds.documentsubtitle
- self.subtitle_labels += self.ids_to_labels(node, set_anchor=False)
+ protect = (self.settings.documentclass == 'memoir')
+ self.subtitle_labels += self.ids_to_labels(node, set_anchor=False,
+ protect=protect)
# section subtitle: "starred" (no number, not in ToC)
elif isinstance(node.parent, nodes.section):
self.out.append(r'\%s*{' %
@@ -3188,7 +3195,8 @@
self.out.append('\n')
self.out += self.ids_to_labels(node)
# add contents to PDF bookmarks sidebar
- if isinstance(node.next_node(), nodes.title):
+ if (isinstance(node.next_node(), nodes.title)
+ and self.settings.documentclass != 'memoir'):
self.out.append('\n\\pdfbookmark[%d]{%s}{%s}' %
(self.section_level+1,
node.next_node().astext(),
Added: trunk/docutils/docutils/writers/latex2e/titlingpage.tex
===================================================================
--- trunk/docutils/docutils/writers/latex2e/titlingpage.tex (rev 0)
+++ trunk/docutils/docutils/writers/latex2e/titlingpage.tex 2020-07-10 09:26:22 UTC (rev 8523)
@@ -0,0 +1,18 @@
+% generated by Docutils <http://docutils.sourceforge.net/>
+$head_prefix
+$requirements
+%%% Custom LaTeX preamble
+$latex_preamble
+%%% User specified packages and stylesheets
+$stylesheet
+%%% Fallback definitions for Docutils-specific commands
+$fallbacks$pdfsetup
+$titledata
+%%% Body
+\begin{document}
+\begin{titlingpage}
+\thispagestyle{empty}
+$body_pre_docinfo$docinfo$dedication$abstract
+\end{titlingpage}
+$body
+\end{document}
Property changes on: trunk/docutils/docutils/writers/latex2e/titlingpage.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Copied: trunk/docutils/test/functional/expected/latex_memoir.tex (from rev 8522, trunk/docutils/test/functional/expected/standalone_rst_latex.tex)
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex (rev 0)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2020-07-10 09:26:22 UTC (rev 8523)
@@ -0,0 +1,2921 @@
+% generated by Docutils <http://docutils.sourceforge.net/>
+\documentclass[a4paper]{memoir}
+
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\DeclareUnicodeCharacter{21D4}{\ensuremath{\Leftrightarrow}}
+\DeclareUnicodeCharacter{2660}{\ensuremath{\spadesuit}}
+\DeclareUnicodeCharacter{2663}{\ensuremath{\clubsuit}}
+\usepackage{alltt}
+\usepackage{amsmath}
+\usepackage[british,french,ngerman,english]{babel}
+% Prevent side-effects if French hyphenation patterns are not loaded:
+\frenchbsetup{StandardLayout}
+\AtBeginDocument{\selectlanguage{english}\noextrasfrench}
+\usepackage{color}
+\usepackage{float} % float configuration
+\floatplacement{figure}{H} % place figures here definitely
+\usepackage{graphicx}
+\usepackage{multirow}
+\usepackage{pifont}
+\setcounter{secnumdepth}{0}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+\usepackage{tabularx}
+\usepackage{textcomp} % text symbol macros
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+
+% providelength (provide a length variable and set default, if it is new)
+\providecommand*{\DUprovidelength}[2]{
+ \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+}
+
+% abstract title
+\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
+
+% admonition (specially marked topic)
+\providecommand{\DUadmonition}[2][class-arg]{%
+ % try \DUadmonition#1{#2}:
+ \ifcsname DUadmonition#1\endcsname%
+ \csname DUadmonition#1\endcsname{#2}%
+ \else
+ \begin{center}
+ \fbox{\parbox{0.9\linewidth}{#2}}
+ \end{center}
+ \fi
+}
+% basic code highlight:
+\providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+\providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+\providecommand*\DUrolekeyword[1]{\textbf{#1}}
+\providecommand*\DUrolestring[1]{\textit{#1}}
+
+% dedication topic
+\providecommand*{\DUCLASSdedication}{%
+ \renewenvironment{quote}{\begin{center}}{\end{center}}%
+}
+
+% docinfo (width of docinfo table)
+\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
+
+% subtitle (in document title)
+\providecommand*{\DUdocumentsubtitle}[1]{{\large #1}}
+\newcounter{enumv}
+
+% error admonition title
+\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}
+
+% fieldlist environment
+\ifthenelse{\isundefined{\DUfieldlist}}{
+ \newenvironment{DUfieldlist}%
+ {\quote\description}
+ {\enddescription\endquote}
+}{}
+% numeric or symbol footnotes with hyperlinks
+\providecommand*{\DUfootnotemark}[3]{%
+ \raisebox{1em}{\hypertarget{#1}{}}%
+ \hyperlink{#2}{\textsuperscript{#3}}%
+}
+\providecommand{\DUfootnotetext}[4]{%
+ \begingroup%
+ \renewcommand{\thefootnote}{%
+ \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
+ \protect\hyperlink{#2}{#3}}%
+ \footnotetext{#4}%
+ \endgroup%
+}
+
+% inline markup (custom roles)
+% \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
+}
+
+% legend environment
+\ifthenelse{\isundefined{\DUlegend}}{
+ \newenvironment{DUlegend}{\small}{}
+}{}
+
+% lineblock environment
+\DUprovidelength{\DUlineblockindent}{2.5em}
+\ifthenelse{\isundefined{\DUlineblock}}{
+ \newenvironment{DUlineblock}[1]{%
+ \list{}{\setlength{\partopsep}{\parskip}
+ \addtolength{\partopsep}{\baselineskip}
+ \setlength{\topsep}{0pt}
+ \setlength{\itemsep}{0.15\baselineskip}
+ \setlength{\parsep}{0pt}
+ \setlength{\leftmargin}{#1}}
+ \raggedright
+ }
+ {\endlist}
+}{}
+
+% optionlist environment
+\providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
+\DUprovidelength{\DUoptionlistindent}{3cm}
+\ifthenelse{\isundefined{\DUoptionlist}}{
+ \newenvironment{DUoptionlist}{%
+ \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
+ \setlength{\rightmargin}{1cm}
+ \setlength{\leftmargin}{\rightmargin}
+ \addtolength{\leftmargin}{\labelwidth}
+ \addtolength{\leftmargin}{\labelsep}
+ \renewcommand{\makelabel}{\DUoptionlistlabel}}
+ }
+ {\endlist}
+}{}
+
+% rubric (informal heading)
+\providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
+
+% sidebar (text outside the main text flow)
+\providecommand{\DUsidebar}[1]{%
+ \begin{center}
+ \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#1}}
+ \end{center}
+}
+
+% subtitle (for sidebar)
+\providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip}
+
+% text mode subscript
+\ifx\textsubscript\undefined
+ \usepackage{fixltx2e} % since 2015 loaded by default
+\fi
+
+% title for topics, admonitions, unsupported section levels, and sidebar
+\providecommand*{\DUtitle}[2][class-arg]{%
+ % call \DUtitle#1{#2} if it exists:
+ \ifcsname DUtitle#1\endcsname%
+ \csname DUtitle#1\endcsname{#2}%
+ \else
+ \smallskip\noindent\textbf{#2}\smallskip%
+ \fi
+}
+
+% titlereference role
+\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
+
+% transition (break, fancybreak, anonymous section)
+\providecommand*{\DUtransition}{%
+ \hspace*{\fill}\hrulefill\hspace*{\fill}
+ \vskip 0.5\baselineskip
+}
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage{bookmark}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+\hypersetup{
+ pdftitle={reStructuredText Test Document},
+ pdfauthor={David Goodger;Me;Myself;I}
+}
+
+\title{reStructuredText Test Document%
+ \protect\label{restructuredtext-test-document}%
+ \protect\label{doctitle}%
+ \\%
+ \DUdocumentsubtitle{Examples of Syntax Constructs}%
+ \protect\label{examples-of-syntax-constructs}%
+ \protect\label{subtitle}}
+\author{David Goodger\\
+123 Example Street\\
+Example, EX Canada\\
+A1B 2C3\\
+go...@py... \and
+Me \and
+Myself \and
+I\\
+humankind}
+\date{Now, or yesterday. Or maybe even before yesterday.}
+
+%%% Body
+\begin{document}
+\begin{titlingpage}
+\thispagestyle{empty}
+\maketitle
+
+% Docinfo
+\begin{center}
+\begin{tabularx}{\DUdocinfowidth}{lX}
+\textbf{Status}: &
+ This is a \textquotedbl{}work in progress\textquotedbl{} \\
+\textbf{Revision}: &
+ is managed by a version control system. \\
+\textbf{Version}: &
+ 1 \\
+\textbf{Copyright}: &
+ This document has been placed in the public domain. You
+may do with it as you wish. You may copy, modify,
+redistribute, reattribute, sell, buy, rent, lease,
+destroy, or improve it, quote it at length, excerpt,
+incorporate, collate, fold, staple, or mutilate it, or do
+anything else to it that your or anyone else's heart
+desires. \\
+\textbf{field name}: &
+This is a \textquotedbl{}generic bibliographic field\textquotedbl{}.
+\\
+\textbf{field name \textquotedbl{}2\textquotedbl{}}: &
+Generic bibliographic fields may contain multiple body elements.
+
+Like this.
+\\
+\end{tabularx}
+\end{center}
+
+\begin{DUclass}{dedication}
+\begin{quote}
+\DUtitle[dedication]{Dedication}
+
+For Docutils users \& co-developers.
+\end{quote}
+\end{DUclass}
+
+\begin{DUclass}{abstract}
+\begin{quote}
+\DUtitle[abstract]{Abstract}
+
+This is a test document, containing at least one example of each
+reStructuredText construct.
+\end{quote}
+\end{DUclass}
+
+\end{titlingpage}
+
+% This is a comment. Note how any initial comments are moved by
+% transforms to after the document title, subtitle, and docinfo.
+
+% Above is the document title, and below is the subtitle.
+% They are transformed from section titles after parsing.
+
+% bibliographic fields (which also require a transform):
+
+\pagebreak[4] % start ToC on new page
+
+\phantomsection\label{table-of-contents}
+\renewcommand{\contentsname}{Table of Contents}
+\tableofcontents
+
+
+\chapter{1 Structural Elements%
+ \label{structural-elements}%
+}
+
+
+\section{1.1 Section Title%
+ \label{section-title}%
+}
+
+
+\subsection{1.1.1 Section Subtitle%
+ \label{section-subtitle}%
+}
+
+Lone subsections are converted to a section subtitle by a transform
+activated with the \texttt{-{}-section-subtitles} command line option or the
+\texttt{sectsubtitle-xform} configuration value.
+
+
+\section{1.2 Empty Section%
+ \label{empty-section}%
+}
+
+
+\section{1.3 Transitions%
+ \label{transitions}%
+}
+
+Here's a transition:
+
+%___________________________________________________________________________
+\DUtransition
+
+It divides the section. Transitions may also occur between sections:
+
+%___________________________________________________________________________
+\DUtransition
+
+
+\chapter{2 Body Elements%
+ \label{body-elements}%
+}
+
+
+\section{2.1 Paragraphs%
+ \label{paragraphs}%
+}
+
+A paragraph.
+
+
+\subsection{2.1.1 Inline Markup%
+ \label{inline-markup}%
+}
+
+Paragraphs contain text and may contain inline markup: \emph{emphasis},
+\textbf{strong emphasis}, \texttt{inline literals}, standalone hyperlinks
+(\url{http://www.python.org}), external hyperlinks (\href{http://www.python.org/}{Python}\DUfootnotemark{footnote-reference-10}{footnote-6}{5}), internal
+cross-references (\hyperref[example]{example}), external hyperlinks with embedded URIs
+(\href{http://www.python.org}{Python web site}), \href{http://www.python.org/}{anonymous hyperlink
+references}\DUfootnotemark{footnote-reference-16}{footnote-6}{5} (\href{http://docutils.sourceforge.net/}{a second reference}\DUfootnotemark{footnote-reference-17}{footnote-9}{8}), footnote references (manually
+numbered\DUfootnotemark{footnote-reference-1}{footnote-1}{1}, anonymous auto-numbered\DUfootnotemark{footnote-reference-2}{footnote-2}{3}, labeled auto-numbered\DUfootnotemark{footnote-reference-3}{label}{2}, or symbolic\DUfootnotemark{footnote-reference-4}{footnote-3}{*}), citation references (\hyperlink{cit2002}{[CIT2002]}),
+substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png} \&
+a \emph{trimmed heart} \texttt{(U+2665):}\ding{170}), and %
+\phantomsection\label{inline-hyperlink-targets}inline hyperlink targets
+(see \hyperref[targets]{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 %
+\raisebox{1em}{\hypertarget{problematic-1}{}}\hyperlink{system-message-1}{\textbf{\color{red}|problematic|}} text
+(generated by processing errors; this one is intentional). Here is a
+reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subtitle}.
+
+The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
+some explicit interpreted text roles: a PEP reference (\href{http://www.python.org/dev/peps/pep-0287}{PEP 287}); an
+RFC reference (\href{http://tools.ietf.org/html/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
+(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
+a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}'
+\emph{standard} \textbf{inline} \texttt{markup}.
+
+% DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
+
+Let's test wrapping and whitespace significance in inline literals:
+\texttt{This is an example of -{}-inline-literal -{}-text, -{}-including some-{}-
+strangely-{}-hyphenated-words. ~Adjust-the-width-of-your-browser-window
+to see how the text is wrapped. ~-{}- -{}-{}-{}- -{}-{}-{}-{}-{}-{}-{}- ~Now note ~ ~the
+spacing ~ ~between the ~ ~words of ~ ~this sentence ~ ~(words
+should ~ ~be grouped ~ ~in pairs).}
+
+If the \texttt{-{}-pep-references} option was supplied, there should be a
+live link to PEP 258 here.
+
+
+\section{2.2 Bullet Lists%
+ \label{bullet-lists}%
+}
+
+\begin{itemize}
+\item A bullet list
+
+\begin{itemize}
+\item Nested bullet list.
+
+\item Nested item 2.
+\end{itemize}
+
+\item Item 2.
+
+Paragraph 2 of item 2.
+
+\begin{itemize}
+\item Nested bullet list.
+
+\item Nested item 2.
+
+\begin{itemize}
+\item Third level.
+
+\item Item 2.
+\end{itemize}
+
+\item Nested item 3.
+
+\item This nested list should be compacted by the HTML writer.
+%
+\phantomsection\label{target}
+% Even if this item contains a target and a comment.
+\end{itemize}
+\end{itemize}
+
+
+\section{2.3 Enumerated Lists%
+ \label{enumerated-lists}%
+}
+
+\begin{enumerate}
+\item Arabic numerals.
+
+\begin{enumerate}
+\renewcommand{\labelenumii}{\alph{enumii})}
+\item lower alpha)
+
+\begin{enumerate}
+\renewcommand{\labelenumiii}{(\roman{enumiii})}
+\item (lower roman)
+
+\begin{enumerate}
+\item upper alpha.
+
+\begin{list}{\Roman{enumv})}{\usecounter{enumv}}
+\item upper roman)
+\end{list}
+\end{enumerate}
+\end{enumerate}
+\end{enumerate}
+
+\item Lists that don't start at 1:
+
+\begin{enumerate}
+\renewcommand{\labelenumii}{\arabic{enumii}.}
+\setcounter{enumii}{2}
+\item Three
+
+\item Four
+\end{enumerate}
+
+\begin{enumerate}
+\renewcommand{\labelenumii}{\Alph{enumii}.}
+\setcounter{enumii}{2}
+\item C
+
+\item D
+\end{enumerate}
+
+\begin{enumerate}
+\renewcommand{\labelenumii}{\roman{enumii}.}
+\setcounter{enumii}{2}
+\item iii
+
+\item iv
+\end{enumerate}
+\end{enumerate}
+
+
+\section{2.4 Definition Lists%
+ \label{definition-lists}%
+}
+
+\begin{description}
+\item[{Term}] \leavevmode
+Definition
+
+\item[{Term}] \leavevmode (\textbf{classifier})
+Definition paragraph 1.
+
+Definition paragraph 2.
+
+\item[{Term}] \leavevmode
+Definition
+
+\item[{Term}] \leavevmode (\textbf{classifier one})(\textbf{classifier two})
+Definition
+
+\end{description}
+
+
+\section{2.5 Field Lists%
+ \label{field-lists}%
+}
+
+\begin{DUfieldlist}
+\item[{what:}]
+Field lists map field names to field bodies, like database
+records. They are often part of an extension syntax. They are
+an unambiguous variant of RFC 2822 fields.
+
+\item[{how arg1 arg2:}]
+The field marker is a colon, the field name, and a colon.
+
+The field body may contain one or more body elements, indented
+relative to the field marker.
+
+\item[{credits:}]
+\DUrole{credits}{This paragraph has the \DUroletitlereference{credits} class set. (This is actually not
+about credits but just for ensuring that the class attribute
+doesn't get stripped away.)}
+\end{DUfieldlist}
+
+
+\section{2.6 Option Lists%
+ \label{option-lists}%
+}
+
+For listing command-line options:
+
+\begin{DUoptionlist}
+\item[-a] command-line option \textquotedbl{}a\textquotedbl{}
+
+\item[-b file] options can have arguments
+and long descriptions
+
+\item[-{}-long] options can be long also
+
+\item[-{}-input=file] long options can also have
+arguments
+
+\item[-{}-very-long-option] The description can also start on the next line.
+
+The description may contain multiple body elements,
+regardless of where it starts.
+
+\item[-x, -y, -z] Multiple options are an \textquotedbl{}option group\textquotedbl{}.
+
+\item[-v, -{}-verbose] Commonly-seen: short \& long options.
+
+\item[-1 file, -{}-one=file, -{}-two file] Multiple options with arguments.
+
+\item[/V] DOS/VMS-style options too
+\end{DUoptionlist}
+
+There must be at least two spaces between the option and the
+description.
+
+
+\section{2.7 Literal Blocks%
+ \label{literal-blocks}%
+}
+
+Literal blocks are indicated with a double-colon (\textquotedbl{}::\textquotedbl{}) at the end of
+the preceding paragraph (over there \texttt{-{}->}). They can be indented:
+
+\begin{quote}
+\begin{alltt}
+if literal_block:
+ text = 'is left as-is'
+ spaces_and_linebreaks = 'are preserved'
+ markup_processing = None
+\end{alltt}
+\end{quote}
+
+Or they can be quoted without indentation:
+
+\begin{quote}
+\begin{alltt}
+>> Great idea!
+>
+> Why didn't I think of that?
+\end{alltt}
+\end{quote}
+
+
+\section{2.8 Line Blocks%
+ \label{line-blocks}%
+}
+
+This section tests line blocks. Line blocks are body elements which
+consist of lines and other line blocks. Nested line blocks cause
+indentation.
+
+\begin{DUlineblock}{0em}
+\item[] This is a line block. It ends with a blank line.
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] New lines begin with a vertical bar (\textquotedbl{}|\textquotedbl{}).
+\item[] Line breaks and initial indent are significant, and preserved.
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] Continuation lines are also possible. A long line that is intended
+to wrap should begin with a space in place of the vertical bar.
+\end{DUlineblock}
+\item[] The left edge of a continuation line need not be aligned with
+the left edge of the text above it.
+\end{DUlineblock}
+\end{DUlineblock}
+
+\begin{DUlineblock}{0em}
+\item[] This is a second line block.
+\item[]
+\item[] Blank lines are permitted internally, but they must begin with a \textquotedbl{}|\textquotedbl{}.
+\end{DUlineblock}
+
+Another line block, surrounded by paragraphs:
+
+\begin{DUlineblock}{0em}
+\item[] And it's no good waiting by the window
+\item[] It's no good waiting for the sun
+\item[] Please believe me, the things you dream of
+\item[] They don't fall in the lap of no-one
+\end{DUlineblock}
+
+Take it away, Eric the Orchestra Leader!
+
+\begin{quote}
+\begin{DUlineblock}{0em}
+\item[] A one, two, a one two three four
+\item[]
+\item[] Half a bee, philosophically,
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] must, \emph{ipso facto}, half not be.
+\end{DUlineblock}
+\item[] But half the bee has got to be,
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] \emph{vis a vis} its entity. D'you see?
+\item[]
+\end{DUlineblock}
+\item[] But can a bee be said to be
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] or not to be an entire bee,
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] when half the bee is not a bee,
+\item[]
+\begin{DUlineblock}{\DUlineblockindent}
+\item[] due to some ancient injury?
+\item[]
+\end{DUlineblock}
+\end{DUlineblock}
+\end{DUlineblock}
+\item[] Singing...
+\end{DUlineblock}
+\end{quote}
+
+A line block, like the following poem by Christian Morgenstern, can
+also be centre-aligned:
+
+\begin{selectlanguage}{ngerman}
+\begin{DUlineblock}{0em}
+\centering
+\item[] \textbf{Die Trichter}
+\item[]
+\item[] Zwei Trichter wandeln durch die Nacht.
+\item[] Durch ihres Rumpfs verengten Schacht
+\item[] fließt weißes Mondlicht
+\item[] still und heiter
+\item[] auf ihren
+\item[] Waldweg
+\item[] u. s.
+\item[] w.
+\item[]
+\end{DUlineblock}
+\end{selectlanguage}
+
+
+\section{2.9 Block Quotes%
+ \label{block-quotes}%
+}
+
+Block quotes consist of indented body elements:
+
+\begin{quote}
+My theory by A. Elk. Brackets Miss, brackets. This theory goes
+as follows and begins now. All brontosauruses are thin at one
+end, much much thicker in the middle and then thin again at the
+far end. That is my theory, it is mine, and belongs to me and I
+own it, and what it is too.
+\nopagebreak
+
+\raggedleft —Anne Elk (Miss)
+\end{quote}
+
+The language of a quote (like any other object) can be specified by
+a class attribute:
+
+%
+
+\begin{selectlanguage}{french}
+\begin{quote}
+ReStructuredText est un langage de balisage léger utilisé
+notamment dans la documentation du langage Python.
+\end{quote}
+\end{selectlanguage}
+
+
+\section{2.10 Doctest Blocks%
+ \label{doctest-blocks}%
+}
+
+\begin{quote}
+\begin{alltt}
+>>> print 'Python-specific usage examples; begun with ">>>"'
+Python-specific usage examples; begun with ">>>"
+>>> print '(cut and pasted from interactive Python sessions)'
+(cut and pasted from interactive Python sessions)
+\end{alltt}
+\end{quote}
+
+
+\section{2.11 Footnotes%
+ \label{footnotes}%
+}
+%
+\DUfootnotetext{footnote-1}{footnote-reference-1}{1}{%
+A footnote contains body elements, consistently indented by at
+least 3 spaces.
+
+This is the footnote's second paragraph.
+}
+%
+\DUfootnotetext{label}{footnote-reference-3}{2}{\phantomsection\label{label}%
+Footnotes may be numbered, either manually (as in\DUfootnotemark{footnote-reference-5}{footnote-1}{1}) or
+automatically using a \textquotedbl{}\#\textquotedbl{}-prefixed label. This footnote has a
+label so it can be referred to from multiple places, both as a
+footnote reference (\DUfootnotemark{footnote-reference-6}{label}{2}) and as a \hyperref[label]{hyperlink reference}.
+}
+%
+\DUfootnotetext{footnote-2}{footnote-reference-2}{3}{%
+This footnote is numbered automatically and anonymously using a
+label of \textquotedbl{}\#\textquotedbl{} only.
+
+This is the second paragraph.
+
+And this is the third paragraph.
+}
+%
+\DUfootnotetext{footnote-3}{footnote-reference-4}{*}{%
+Footnotes may also use symbols, specified with a \textquotedbl{}*\textquotedbl{} label.
+Here's a reference to the next footnote:\DUfootnotemark{footnote-reference-7}{footnote-4}{†}.
+}
+%
+\DUfootnotetext{footnote-4}{footnote-reference-7}{†}{%
+This footnote shows the next symbol in the sequence.
+}
+%
+\DUfootnotetext{footnote-5}{footnote-5}{4}{%
+Here's an unreferenced footnote, with a reference to a
+nonexistent footnote:%
+\raisebox{1em}{\hypertarget{footnote-reference-8}{}}\hyperlink{system-message-2}{\textbf{\color{red}{[}5{]}\_}}.
+}
+
+
+\section{2.12 Citations%
+ \label{citations}%
+}
+\begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
+Citations are text-labeled footnotes. They may be
+rendered separately and differently from footnotes.
+\end{figure}
+
+Here's a reference to the above, \hyperlink{cit2002}{[CIT2002]}, and a %
+\raisebox{1em}{\hypertarget{citation-reference-3}{}}\hyperlink{system-message-3}{\textbf{\color{red}{[}nonexistent{]}\_}}
+citation.
+
+
+\section{2.13 Targets%
+ \label{targets}%
+ \label{another-target}%
+}
+
+\phantomsection\label{example}
+This paragraph is pointed to by the explicit \textquotedbl{}example\textquotedbl{} target. A
+reference can be found under \hyperref[inline-markup]{Inline Markup}, above. \hyperref[inli...
[truncated message content] |
|
From: <mi...@us...> - 2020-07-10 10:08:17
|
Revision: 8524
http://sourceforge.net/p/docutils/code/8524
Author: milde
Date: 2020-07-10 10:08:14 +0000 (Fri, 10 Jul 2020)
Log Message:
-----------
Make the sidebar's "title" argument optional.
Feature request #69.
The analogous DocBook "sidebar" element's title is optional. too
(https://tdg.docbook.org/tdg/5.2/sidebar.html).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/doctree.txt
trunk/docutils/docs/ref/docutils.dtd
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/user/rst/demo.txt
trunk/docutils/docutils/parsers/rst/directives/body.py
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/data/standard.txt
trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/HISTORY.txt 2020-07-10 10:08:14 UTC (rev 8524)
@@ -40,6 +40,10 @@
- Apply version of patch #167: Let document.set_id() register all
existing IDs (thanks to Takeshi KOMIYA).
+* docutils/parsers/rst/directives/body.py:
+
+ - Make the sidebar's "title" argument optional (feature request #69).
+
* docutils/utils/smartquotes.py
- Fix #383: Smart quotes around opening and separator characters.
Modified: trunk/docutils/docs/ref/doctree.txt
===================================================================
--- trunk/docutils/docs/ref/doctree.txt 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/docs/ref/doctree.txt 2020-07-10 10:08:14 UTC (rev 8524)
@@ -3765,7 +3765,7 @@
section_
:Children:
- ``sidebar`` elements begin with a title_ and an optional subtitle_
+ ``sidebar`` elements begin with optional title_ and subtitle_
and contain `body elements`_ and topic_ elements.
:Analogues:
@@ -3801,7 +3801,7 @@
The `"sidebar" directive`_ is used to create a ``sidebar`` element.
reStructuredText_ source::
- .. sidebar:: Title
+ .. sidebar:: Optional Title
:subtitle: If Desired
Body.
@@ -3810,7 +3810,7 @@
<sidebar>
<title>
- Title
+ Optional Title
<subtitle>
If Desired
<paragraph>
Modified: trunk/docutils/docs/ref/docutils.dtd
===================================================================
--- trunk/docutils/docs/ref/docutils.dtd 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/docs/ref/docutils.dtd 2020-07-10 10:08:14 UTC (rev 8524)
@@ -350,7 +350,7 @@
<!ELEMENT topic (title?, (%body.elements;)+)>
<!ATTLIST topic %basic.atts;>
-<!ELEMENT sidebar (title, subtitle?, (%body.elements; | topic)+)>
+<!ELEMENT sidebar (title?, subtitle?, (%body.elements; | topic)+)>
<!ATTLIST sidebar %basic.atts;>
<!ELEMENT transition EMPTY>
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/docs/ref/rst/directives.txt 2020-07-10 10:08:14 UTC (rev 8524)
@@ -373,7 +373,7 @@
:Directive Type: "sidebar"
:Doctree Element: sidebar_
-:Directive Arguments: One, required (sidebar title).
+:Directive Arguments: One, optional (sidebar title).
:Directive Options: Possible (see below).
:Directive Content: Interpreted as the sidebar body.
@@ -392,7 +392,7 @@
must be blank. All subsequent lines make up the sidebar body,
interpreted as body elements. For example::
- .. sidebar:: Sidebar Title
+ .. sidebar:: Optional Sidebar Title
:subtitle: Optional Sidebar Subtitle
Subsequent indented lines comprise
Modified: trunk/docutils/docs/user/rst/demo.txt
===================================================================
--- trunk/docutils/docs/user/rst/demo.txt 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/docs/user/rst/demo.txt 2020-07-10 10:08:14 UTC (rev 8524)
@@ -470,7 +470,7 @@
Topics, Sidebars, and Rubrics
`````````````````````````````
-.. sidebar:: Sidebar Title
+.. sidebar:: Optional Sidebar Title
:subtitle: Optional Subtitle
This is a sidebar. It is for text outside the flow of the main
Modified: trunk/docutils/docutils/parsers/rst/directives/body.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/body.py 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/docutils/parsers/rst/directives/body.py 2020-07-10 10:08:14 UTC (rev 8524)
@@ -36,16 +36,20 @@
raise self.error('The "%s" directive may not be used within '
'topics or body elements.' % self.name)
self.assert_has_content()
- title_text = self.arguments[0]
- textnodes, messages = self.state.inline_text(title_text, self.lineno)
- titles = [nodes.title(title_text, '', *textnodes)]
- # Sidebar uses this code.
- if 'subtitle' in self.options:
- textnodes, more_messages = self.state.inline_text(
- self.options['subtitle'], self.lineno)
- titles.append(nodes.subtitle(self.options['subtitle'], '',
- *textnodes))
- messages.extend(more_messages)
+ if self.arguments: # title (in sidebars optional)
+ title_text = self.arguments[0]
+ textnodes, messages = self.state.inline_text(title_text, self.lineno)
+ titles = [nodes.title(title_text, '', *textnodes)]
+ # Sidebar uses this code.
+ if 'subtitle' in self.options:
+ textnodes, more_messages = self.state.inline_text(
+ self.options['subtitle'], self.lineno)
+ titles.append(nodes.subtitle(self.options['subtitle'], '',
+ *textnodes))
+ messages.extend(more_messages)
+ else:
+ titles = []
+ messages = []
text = '\n'.join(self.content)
node = self.node_class(text, *(titles + messages))
node['classes'] += self.options.get('class', [])
@@ -64,6 +68,8 @@
node_class = nodes.sidebar
+ required_arguments = 0
+ optional_arguments = 1
option_spec = BasePseudoSection.option_spec.copy()
option_spec['subtitle'] = directives.unchanged_required
@@ -71,6 +77,10 @@
if isinstance(self.state_machine.node, nodes.sidebar):
raise self.error('The "%s" directive may not be used within a '
'sidebar element.' % self.name)
+ if 'subtitle' in self.options and not self.arguments:
+ raise self.error('The "subtitle" option may not be used '
+ 'without a title.')
+
return BasePseudoSection.run(self)
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2020-07-10 10:08:14 UTC (rev 8524)
@@ -1203,7 +1203,7 @@
\emph{Sidebars} are like miniature, parallel documents.
\DUsidebar{
-\DUtitle[sidebar]{Sidebar Title}
+\DUtitle[sidebar]{Optional Sidebar Title}
\DUsubtitle{Optional Subtitle}
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2020-07-10 10:08:14 UTC (rev 8524)
@@ -1138,7 +1138,7 @@
<title auto="1" refid="toc-entry-46"><generated classes="sectnum">2.14.5 </generated>Topics, Sidebars, and Rubrics</title>
<paragraph><emphasis>Sidebars</emphasis> are like miniature, parallel documents.</paragraph>
<sidebar>
- <title>Sidebar Title</title>
+ <title>Optional Sidebar Title</title>
<subtitle>Optional Subtitle</subtitle>
<paragraph>This is a sidebar. It is for text outside the flow of the main
text.</paragraph>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2020-07-10 10:08:14 UTC (rev 8524)
@@ -813,7 +813,7 @@
<h3><a class="toc-backref" href="#toc-entry-49">2.14.5 Topics, Sidebars, and Rubrics</a></h3>
<p><em>Sidebars</em> are like miniature, parallel documents.</p>
<div class="sidebar">
-<p class="first sidebar-title">Sidebar Title</p>
+<p class="first sidebar-title">Optional Sidebar Title</p>
<p class="sidebar-subtitle">Optional Subtitle</p>
<p>This is a sidebar. It is for text outside the flow of the main
text.</p>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-07-10 10:08:14 UTC (rev 8524)
@@ -813,7 +813,7 @@
<h3><a class="toc-backref" href="#toc-entry-59"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></h3>
<p><em>Sidebars</em> are like miniature, parallel documents.</p>
<aside class="sidebar">
-<p class="sidebar-title">Sidebar Title</p>
+<p class="sidebar-title">Optional Sidebar Title</p>
<p class="sidebar-subtitle">Optional Subtitle</p>
<p>This is a sidebar. It is for text outside the flow of the main
text.</p>
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-07-10 10:08:14 UTC (rev 8524)
@@ -1202,7 +1202,7 @@
\emph{Sidebars} are like miniature, parallel documents.
\DUsidebar{
-\DUtitle[sidebar]{Sidebar Title}
+\DUtitle[sidebar]{Optional Sidebar Title}
\DUsubtitle{Optional Subtitle}
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2020-07-10 10:08:14 UTC (rev 8524)
@@ -1603,7 +1603,7 @@
are like miniature, parallel documents.
<sidebar>
<title>
- Sidebar Title
+ Optional Sidebar Title
<subtitle>
Optional Subtitle
<paragraph>
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-07-10 10:08:14 UTC (rev 8524)
@@ -1204,7 +1204,7 @@
\emph{Sidebars} are like miniature, parallel documents.
\DUsidebar{
-\DUtitle[sidebar]{Sidebar Title}
+\DUtitle[sidebar]{Optional Sidebar Title}
\DUsubtitle{Optional Subtitle}
Modified: trunk/docutils/test/functional/input/data/standard.txt
===================================================================
--- trunk/docutils/test/functional/input/data/standard.txt 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/functional/input/data/standard.txt 2020-07-10 10:08:14 UTC (rev 8524)
@@ -693,7 +693,7 @@
*Sidebars* are like miniature, parallel documents.
-.. sidebar:: Sidebar Title
+.. sidebar:: Optional Sidebar Title
:subtitle: Optional Subtitle
This is a sidebar. It is for text outside the flow of the main
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py 2020-07-10 09:26:22 UTC (rev 8523)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py 2020-07-10 10:08:14 UTC (rev 8524)
@@ -61,6 +61,17 @@
Body.
"""],
["""\
+.. sidebar::
+
+ The title is optional.
+""",
+"""\
+<document source="test data">
+ <sidebar>
+ <paragraph>
+ The title is optional.
+"""],
+["""\
.. sidebar:: Outer
.. topic:: Topic
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-07-18 14:43:09
|
Revision: 8528
http://sourceforge.net/p/docutils/code/8528
Author: milde
Date: 2020-07-18 14:43:06 +0000 (Sat, 18 Jul 2020)
Log Message:
-----------
Fix #398: properly close link tag to "schema.dcterms".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-07-14 16:41:15 UTC (rev 8527)
+++ trunk/docutils/HISTORY.txt 2020-07-18 14:43:06 UTC (rev 8528)
@@ -63,6 +63,8 @@
- Wrap block-level image elements in <p> (except for figures).
Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
+
+ - Fix #398: properly close link tag to "schema.dcterms".
* docutils/writers/latex2e/__init__.py:
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-07-14 16:41:15 UTC (rev 8527)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-07-18 14:43:06 UTC (rev 8528)
@@ -235,7 +235,7 @@
self.head.insert(0, self.content_type % self.settings.output_encoding)
if 'name="dcterms.' in ''.join(self.meta):
self.head.append(
- '<link rel="schema.dcterms" href="http://purl.org/dc/terms/">')
+ '<link rel="schema.dcterms" href="http://purl.org/dc/terms/"/>')
if self.math_header:
if self.math_output == 'mathjax':
self.head.extend(self.math_header)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-07-18 14:51:37
|
Revision: 8530
http://sourceforge.net/p/docutils/code/8530
Author: milde
Date: 2020-07-18 14:51:34 +0000 (Sat, 18 Jul 2020)
Log Message:
-----------
Part 2 of the fix for #398.
Fix also fixhtml4 writer and tests.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-07-18 14:43:20 UTC (rev 8529)
+++ trunk/docutils/HISTORY.txt 2020-07-18 14:51:34 UTC (rev 8530)
@@ -19,7 +19,7 @@
* General
- - Fix #385: Import of language modules.
+ - Fix bug #385: Import of language modules.
- Use importlib.import_module() to programmatically import modules.
- Remove legacy LaTeX stylesheet ``docutils-05-compat.sty``.
- Installing with ``setup.py`` now requires ``setuptools``.
@@ -46,7 +46,7 @@
* docutils/utils/smartquotes.py
- - Fix #383: Smart quotes around opening and separator characters.
+ - Fix bug #383: Smart quotes around opening and separator characters.
* docutils/writers/html5_polyglot/
@@ -64,7 +64,7 @@
Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
- - Fix #398: properly close link tag to "schema.dcterms".
+ - Fix bug #398: properly close link tag to "schema.dcterms".
* docutils/writers/latex2e/__init__.py:
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2020-07-18 14:43:20 UTC (rev 8529)
+++ trunk/docutils/docutils/writers/_html_base.py 2020-07-18 14:51:34 UTC (rev 8530)
@@ -729,7 +729,7 @@
self.head.insert(0, self.content_type % self.settings.output_encoding)
if 'name="dcterms.' in ''.join(self.meta):
self.head.append(
- '<link rel="schema.dcterms" href="http://purl.org/dc/terms/">')
+ '<link rel="schema.dcterms" href="http://purl.org/dc/terms/"/>')
if self.math_header:
if self.math_output == 'mathjax':
self.head.extend(self.math_header)
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-07-18 14:43:20 UTC (rev 8529)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-07-18 14:51:34 UTC (rev 8530)
@@ -12,7 +12,7 @@
<meta name="dcterms.rights" content="This document has been placed in the public domain. You may do with it as you wish. You may copy, modify, redistribute, reattribute, sell, buy, rent, lease, destroy, or improve it, quote it at length, excerpt, incorporate, collate, fold, staple, or mutilate it, or do anything else to it that your or anyone else's heart desires." />
<meta content="reStructuredText, test, parser" name="keywords" />
<meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" xml:lang="en" />
-<link rel="schema.dcterms" href="http://purl.org/dc/terms/">
+<link rel="schema.dcterms" href="http://purl.org/dc/terms/"/>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/plain.css" type="text/css" />
<link rel="stylesheet" href="../input/data/math.css" type="text/css" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2020-07-27 07:28:46
|
Revision: 8531
http://sourceforge.net/p/docutils/code/8531
Author: grubert
Date: 2020-07-27 07:28:44 +0000 (Mon, 27 Jul 2020)
Log Message:
-----------
Run python3 test like python2 run against source not the build/-directory.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/test/DocutilsTestSupport.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-07-18 14:51:34 UTC (rev 8530)
+++ trunk/docutils/HISTORY.txt 2020-07-27 07:28:44 UTC (rev 8531)
@@ -24,6 +24,8 @@
- Remove legacy LaTeX stylesheet ``docutils-05-compat.sty``.
- Installing with ``setup.py`` now requires ``setuptools``.
Alternatively, install with `pip`_ (or "manually").
+ - Run python3 test like python2 run against source not the build/-directory
+ (test/DocutilsTestSupport.py #8531).
* docutils/MANIFEST.in
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2020-07-18 14:51:34 UTC (rev 8530)
+++ trunk/docutils/test/DocutilsTestSupport.py 2020-07-27 07:28:44 UTC (rev 8531)
@@ -51,14 +51,8 @@
testroot = os.path.abspath(os.path.dirname(__file__) or os.curdir)
os.chdir(testroot)
-if sys.version_info >= (3, 0):
- sys.path.insert(0, os.path.normpath(os.path.join(testroot,
- '..', 'build', 'lib')))
- sys.path.append(os.path.normpath(os.path.join(testroot, '..',
- 'build', 'lib', 'extras')))
-else:
- sys.path.insert(0, os.path.normpath(os.path.join(testroot, '..')))
- sys.path.append(os.path.normpath(os.path.join(testroot, '..', 'extras')))
+sys.path.insert(0, os.path.normpath(os.path.join(testroot, '..')))
+sys.path.append(os.path.normpath(os.path.join(testroot, '..', 'extras')))
sys.path.insert(0, testroot)
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-08-22 22:16:28
|
Revision: 8541
http://sourceforge.net/p/docutils/code/8541
Author: milde
Date: 2020-08-22 22:16:25 +0000 (Sat, 22 Aug 2020)
Log Message:
-----------
Apply patch for bug #399 Fixes in Korean translation by Shinjo Park.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/languages/ko.py
trunk/docutils/docutils/parsers/rst/languages/ko.py
trunk/docutils/docutils/utils/smartquotes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-08-22 10:21:17 UTC (rev 8540)
+++ trunk/docutils/HISTORY.txt 2020-08-22 22:16:25 UTC (rev 8541)
@@ -24,8 +24,7 @@
- Remove legacy LaTeX stylesheet ``docutils-05-compat.sty``.
- Installing with ``setup.py`` now requires ``setuptools``.
Alternatively, install with `pip`_ (or "manually").
- - Run python3 test like python2 run against source not the build/-directory
- (test/DocutilsTestSupport.py #8531).
+ - Apply patch for bug #399 Fixes in Korean translation.
* docutils/MANIFEST.in
@@ -89,6 +88,10 @@
- Fix #126 manpage title with spaces.
- Fix #380 commandline option problem in sphinx.
+* test/DocutilsTestSupport.py
+
+ - Run python3 test like python2 against source not the build/-directory
+
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Modified: trunk/docutils/docutils/languages/ko.py
===================================================================
--- trunk/docutils/docutils/languages/ko.py 2020-08-22 10:21:17 UTC (rev 8540)
+++ trunk/docutils/docutils/languages/ko.py 2020-08-22 22:16:25 UTC (rev 8541)
@@ -21,8 +21,8 @@
'organization': u'조직',
'address': u'주소',
'contact': u'연락처',
- 'version': 'Version',
- 'revision': 'Revision',
+ 'version': u'버전',
+ 'revision': u'리비전',
'status': u'상태',
'date': u'날짜',
'copyright': u'저작권',
@@ -47,8 +47,8 @@
u'조직': 'organization',
u'주소': 'address',
u'연락처': 'contact',
- u'version': 'version',
- u'revision': 'revision',
+ u'버전': 'version',
+ u'리비전': 'revision',
u'상태': 'status',
u'날짜': 'date',
u'저작권': 'copyright',
Modified: trunk/docutils/docutils/parsers/rst/languages/ko.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/ko.py 2020-08-22 10:21:17 UTC (rev 8540)
+++ trunk/docutils/docutils/parsers/rst/languages/ko.py 2020-08-22 22:16:25 UTC (rev 8541)
@@ -37,7 +37,7 @@
u'파싱된-리터럴': 'parsed-literal',
u'지시문': 'rubric',
u'제명': 'epigraph',
- u'하이라이': 'highlights',
+ u'하이라이트': 'highlights',
u'발췌문': 'pull-quote',
u'합성어': 'compound',
u'컨테이너': 'container',
@@ -55,9 +55,9 @@
u'포함': 'include',
'raw': 'raw',
u'대신하다': 'replace',
- 'unicode': 'unicode',
+ u'유니코드': 'unicode',
u'날짜': 'date',
- 'class': 'class',
+ u'클래스': 'class',
u'역할': 'role',
u'기본-역할': 'default-role',
u'제목': 'title',
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2020-08-22 10:21:17 UTC (rev 8540)
+++ trunk/docutils/docutils/utils/smartquotes.py 2020-08-22 22:16:25 UTC (rev 8541)
@@ -449,7 +449,7 @@
'it-x-altquot': u'“”‘’',
# 'it-x-altquot2': u'“„‘‚', # [7] in headlines
'ja': u'「」『』',
- 'ko': u'《》〈〉',
+ 'ko': u'“”‘’',
'lt': u'„“‚‘',
'lv': u'„“‚‘',
'mk': u'„“‚‘', # Macedonian, https://mk.wikipedia.org/wiki/Правопис_и_правоговор_на_македонскиот_јазик
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-08-28 20:07:43
|
Revision: 8545
http://sourceforge.net/p/docutils/code/8545
Author: milde
Date: 2020-08-28 20:07:40 +0000 (Fri, 28 Aug 2020)
Log Message:
-----------
LaTeX package/stylesheet for Docutils.
New LaTeX style file with required Docutils-specific definitions.
This file will also be published on CTAN.
When "docutils.sty" is not found in the "stylesheet" setting(s),
the LaTeX writer will insert required code into the
document preamble (like up to this commit).
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/cyrillic.tex
trunk/docutils/test/functional/expected/latex_cornercases.tex
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/expected/xetex-cyrillic.tex
trunk/docutils/test/functional/tests/latex_literal_block.py
trunk/docutils/test/functional/tests/latex_literal_block_fancyvrb.py
trunk/docutils/test/functional/tests/latex_literal_block_listings.py
trunk/docutils/test/functional/tests/latex_literal_block_verbatim.py
trunk/docutils/test/functional/tests/latex_literal_block_verbatimtab.py
trunk/docutils/test/functional/tests/standalone_rst_xetex.py
trunk/docutils/test/test_writers/test_latex2e.py
Added Paths:
-----------
trunk/docutils/docutils/writers/latex2e/docutils.sty
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-08-28 09:57:36 UTC (rev 8544)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-08-28 20:07:40 UTC (rev 8545)
@@ -192,8 +192,8 @@
'validator': frontend.validate_comma_separated_list,
'choices': table_style_values}),
('LaTeX graphicx package option. '
- 'Possible values are "dvips", "pdftex". "auto" includes LaTeX code '
- 'to use "pdftex" if processing with pdf(la)tex and dvips otherwise. '
+ 'Possible values are "dvipdfmx", "dvips", "dvisvgm", '
+ '"luatex", "pdftex", and "xetex".'
'Default: "".',
['--graphicx-option'],
{'default': ''}),
@@ -494,153 +494,13 @@
class PreambleCmds(object):
"""Building blocks for the latex preamble."""
-PreambleCmds.abstract_legacy = r"""
-% abstract title
-\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}"""
+# Requirements
-PreambleCmds.abstract = r"""
-\providecommand*{\DUCLASSabstract}{
- \renewcommand{\DUtitle}[1]{\centerline{\textbf{##1}}}
-}"""
-
-# deprecated, see https://sourceforge.net/p/docutils/bugs/339/
-PreambleCmds.admonition_legacy = r"""
-% admonition (specially marked topic)
-\providecommand{\DUadmonition}[2][class-arg]{%
- % try \DUadmonition#1{#2}:
- \ifcsname DUadmonition#1\endcsname%
- \csname DUadmonition#1\endcsname{#2}%
- \else
- \begin{center}
- \fbox{\parbox{0.9\linewidth}{#2}}
- \end{center}
- \fi
-}"""
-
-PreambleCmds.admonition = r"""
-% admonition (specially marked topic)
-\ifx\DUadmonition\undefined % poor man's "provideenvironment"
- \newbox{\DUadmonitionbox}
- \newenvironment{DUadmonition}%
- {\begin{center}
- \begin{lrbox}{\DUadmonitionbox}
- \begin{minipage}{0.9\linewidth}
- }%
- { \end{minipage}
- \end{lrbox}
- \fbox{\usebox{\DUadmonitionbox}}
- \end{center}
- }
-\fi"""
-
-## PreambleCmds.caption = r"""% configure caption layout
-## \usepackage{caption}
-## \captionsetup{singlelinecheck=false}% no exceptions for one-liners"""
-
PreambleCmds.color = r"""\usepackage{color}"""
-PreambleCmds.docinfo = r"""
-% docinfo (width of docinfo table)
-\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}"""
-# PreambleCmds.docinfo._depends = 'providelength'
-
-PreambleCmds.dedication = r"""
-% dedication topic
-\providecommand*{\DUCLASSdedication}{%
- \renewenvironment{quote}{\begin{center}}{\end{center}}%
-}"""
-# TODO: add \em to set dedication text in italics.
-
-PreambleCmds.duclass = r"""
-% class handling for environments (block-level elements)
-% \begin{DUclass}{spam} tries \DUCLASSspam and
-% \end{DUclass}{spam} tries \endDUCLASSspam
-\ifx\DUclass\undefined % poor man's "provideenvironment"
- \newenvironment{DUclass}[1]%
- {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
- \csname \DocutilsClassFunctionName \endcsname}%
- {\csname end\DocutilsClassFunctionName \endcsname}%
-\fi"""
-
-PreambleCmds.error_legacy = r"""
-% error admonition title
-\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}"""
-
-PreambleCmds.error = r"""
-\providecommand*{\DUCLASSerror}{\color{red}}"""
-
-PreambleCmds.fieldlist = r"""
-% fieldlist environment
-\ifthenelse{\isundefined{\DUfieldlist}}{
- \newenvironment{DUfieldlist}%
- {\quote\description}
- {\enddescription\endquote}
-}{}"""
-
-PreambleCmds.float_settings = r"""\usepackage{float} % float configuration
+PreambleCmds.float = r"""\usepackage{float} % extended float configuration
\floatplacement{figure}{H} % place figures here definitely"""
-PreambleCmds.footnotes = r"""% numeric or symbol footnotes with hyperlinks
-\providecommand*{\DUfootnotemark}[3]{%
- \raisebox{1em}{\hypertarget{#1}{}}%
- \hyperlink{#2}{\textsuperscript{#3}}%
-}
-\providecommand{\DUfootnotetext}[4]{%
- \begingroup%
- \renewcommand{\thefootnote}{%
- \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
- \protect\hyperlink{#2}{#3}}%
- \footnotetext{#4}%
- \endgroup%
-}"""
-
-PreambleCmds.graphicx_auto = r"""% Check output format
-\ifx\pdftexversion\undefined
- \usepackage{graphicx}
-\else
- \usepackage[pdftex]{graphicx}
-\fi"""
-
-PreambleCmds.highlight_rules = r"""% basic code highlight:
-\providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
-\providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
-\providecommand*\DUrolekeyword[1]{\textbf{#1}}
-\providecommand*\DUrolestring[1]{\textit{#1}}"""
-
-PreambleCmds.inline = r"""
-% inline markup (custom roles)
-% \DUrole{#1}{#2} tries \DUrole#1{#2}
-\providecommand*{\DUrole}[2]{%
- \ifcsname DUrole#1\endcsname%
- \csname DUrole#1\endcsname{#2}%
- \else%
- #2%
- \fi%
-}"""
-
-PreambleCmds.legend = r"""
-% legend environment
-\ifthenelse{\isundefined{\DUlegend}}{
- \newenvironment{DUlegend}{\small}{}
-}{}"""
-
-PreambleCmds.lineblock = r"""
-% lineblock environment
-\DUprovidelength{\DUlineblockindent}{2.5em}
-\ifthenelse{\isundefined{\DUlineblock}}{
- \newenvironment{DUlineblock}[1]{%
- \list{}{\setlength{\partopsep}{\parskip}
- \addtolength{\partopsep}{\baselineskip}
- \setlength{\topsep}{0pt}
- \setlength{\itemsep}{0.15\baselineskip}
- \setlength{\parsep}{0pt}
- \setlength{\leftmargin}{#1}}
- \raggedright
- }
- {\endlist}
-}{}"""
-# PreambleCmds.lineblock._depends = 'providelength'
-
PreambleCmds.linking = r"""%% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[%s]{hyperref}
@@ -651,68 +511,38 @@
PreambleCmds.minitoc = r"""%% local table of contents
\usepackage{minitoc}"""
-PreambleCmds.optionlist = r"""
-% optionlist environment
-\providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
-\DUprovidelength{\DUoptionlistindent}{3cm}
-\ifthenelse{\isundefined{\DUoptionlist}}{
- \newenvironment{DUoptionlist}{%
- \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
- \setlength{\rightmargin}{1cm}
- \setlength{\leftmargin}{\rightmargin}
- \addtolength{\leftmargin}{\labelwidth}
- \addtolength{\leftmargin}{\labelsep}
- \renewcommand{\makelabel}{\DUoptionlistlabel}}
- }
- {\endlist}
-}{}"""
-# PreambleCmds.optionlist._depends = 'providelength'
-
-PreambleCmds.providelength = r"""
-% providelength (provide a length variable and set default, if it is new)
-\providecommand*{\DUprovidelength}[2]{
- \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
-}"""
-
-PreambleCmds.rubric = r"""
-% rubric (informal heading)
-\providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}"""
-
-PreambleCmds.sidebar = r"""
-% sidebar (text outside the main text flow)
-\providecommand{\DUsidebar}[1]{%
- \begin{center}
- \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#1}}
- \end{center}
-}"""
-
-PreambleCmds.subtitle = r"""
-% subtitle (for sidebar)
-\providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip}"""
-
-PreambleCmds.documentsubtitle = r"""
-% subtitle (in document title)
-\providecommand*{\DUdocumentsubtitle}[1]{{\large #1}}"""
-
PreambleCmds.table = r"""\usepackage{longtable,ltcaption,array}
\setlength{\extrarowheight}{2pt}
\newlength{\DUtablewidth} % internal use in tables"""
-# Options [force,almostfull] prevent spurious error messages, see
-# de.comp.text.tex/2005-12/msg01855
-PreambleCmds.textcomp = """\
-\\usepackage{textcomp} % text symbol macros"""
+PreambleCmds.textcomp = r"""\usepackage{textcomp} % text symbol macros"""
+# TODO? Options [force,almostfull] prevent spurious error messages,
+# see de.comp.text.tex/2005-12/msg01855
-PreambleCmds.textsubscript = r"""
-% text mode subscript
-\ifx\textsubscript\undefined
- \usepackage{fixltx2e} % since 2015 loaded by default
-\fi"""
+# backwards compatibility definitions
-PreambleCmds.titlereference = r"""
-% titlereference role
-\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}"""
+PreambleCmds.abstract_legacy = r"""
+% abstract title
+\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}"""
+# see https://sourceforge.net/p/docutils/bugs/339/
+PreambleCmds.admonition_legacy = r"""
+% admonition (specially marked topic)
+\providecommand{\DUadmonition}[2][class-arg]{%
+ % try \DUadmonition#1{#2}:
+ \ifcsname DUadmonition#1\endcsname%
+ \csname DUadmonition#1\endcsname{#2}%
+ \else
+ \begin{center}
+ \fbox{\parbox{0.9\linewidth}{#2}}
+ \end{center}
+ \fi
+}"""
+
+PreambleCmds.error_legacy = r"""
+% error admonition title
+\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}"""
+
PreambleCmds.title_legacy = r"""
% title for topics, admonitions, unsupported section levels, and sidebar
\providecommand*{\DUtitle}[2][class-arg]{%
@@ -724,18 +554,39 @@
\fi
}"""
-PreambleCmds.title = r"""
-% title for topics, admonitions, unsupported section levels, and sidebar
-\providecommand*{\DUtitle}[1]{\subsubsection*{#1}}"""
+## PreambleCmds.caption = r"""% configure caption layout
+## \usepackage{caption}
+## \captionsetup{singlelinecheck=false}% no exceptions for one-liners"""
-PreambleCmds.transition = r"""
-% transition (break, fancybreak, anonymous section)
-\providecommand*{\DUtransition}{%
- \hspace*{\fill}\hrulefill\hspace*{\fill}
- \vskip 0.5\baselineskip
-}"""
+# Definitions from docutils.sty::
+def _read_block(fp):
+ block = [next(fp)] # first line (empty)
+ for line in fp:
+ if not line.strip():
+ break
+ block.append(line)
+ return ''.join(block).rstrip()
+
+_du_sty = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ 'docutils.sty')
+with open(_du_sty) as fp:
+ for line in fp:
+ line = line.strip('% \n')
+ if not line.endswith('::'):
+ continue
+ block_name = line.rstrip(':')
+ if not block_name:
+ continue
+ definitions = _read_block(fp)
+ if block_name in ('color', 'float', 'table', 'textcomp'):
+ definitions = definitions.strip()
+ # print('Block: `%s`'% block_name)
+ # print(definitions)
+ setattr(PreambleCmds, block_name, definitions)
+
+
# LaTeX encoding maps
# -------------------
# ::
@@ -1282,8 +1133,6 @@
# graphic package options:
if self.settings.graphicx_option == '':
self.graphicx_package = r'\usepackage{graphicx}'
- elif self.settings.graphicx_option.lower() == 'auto':
- self.graphicx_package = PreambleCmds.graphicx_auto
else:
self.graphicx_package = (r'\usepackage[%s]{graphicx}' %
self.settings.graphicx_option)
@@ -1388,9 +1237,18 @@
# Stylesheets
# (the name `self.stylesheet` is singular because only one
# stylesheet was supported before Docutils 0.6).
+ stylesheet_list = utils.get_stylesheet_list(settings)
+ self.fallback_stylesheet = [sheet for sheet in stylesheet_list
+ if sheet == 'docutils']
+ # docutils.sty is incompatible with legacy functions
+ if self.fallback_stylesheet and self.settings.legacy_class_functions:
+ self.fallback_stylesheet = []
+ stylesheet_list = [sheet for sheet in stylesheet_list
+ if sheet != 'docutils']
self.stylesheet = [self.stylesheet_call(path)
- for path in utils.get_stylesheet_list(settings)]
+ for path in stylesheet_list]
+
# PDF setup
if self.hyperlink_color in ('0', 'false', 'False', ''):
self.hyperref_options = ''
@@ -1574,7 +1432,7 @@
# Characters that require a feature/package to render
for ch in text:
cp = ord(ch)
- if cp in CharMaps.textcomp:
+ if cp in CharMaps.textcomp and not self.fallback_stylesheet:
self.requirements['textcomp'] = PreambleCmds.textcomp
elif cp in CharMaps.pifont:
self.requirements['pifont'] = '\\usepackage{pifont}'
@@ -1677,7 +1535,8 @@
self.babel.otherlanguages[language] = True
self.out.append('\\begin{selectlanguage}{%s}\n' % language)
else:
- self.fallbacks['DUclass'] = PreambleCmds.duclass
+ if not self.fallback_stylesheet:
+ self.fallbacks['DUclass'] = PreambleCmds.duclass
self.out.append('\\begin{DUclass}{%s}\n' % cls)
def duclass_close(self, node):
@@ -1688,7 +1547,8 @@
if language:
self.out.append('\\end{selectlanguage}\n')
else:
- self.fallbacks['DUclass'] = PreambleCmds.duclass
+ if not self.fallback_stylesheet:
+ self.fallbacks['DUclass'] = PreambleCmds.duclass
self.out.append('\\end{DUclass}\n')
def push_output_collector(self, new_out):
@@ -1737,8 +1597,9 @@
self.fallbacks['error'] = PreambleCmds.error_legacy
self.out.append('\n\\DUadmonition[%s]{' % ','.join(node['classes']))
return
- self.fallbacks['admonition'] = PreambleCmds.admonition
- if 'error' in node['classes']:
+ if not self.fallback_stylesheet:
+ self.fallbacks['admonition'] = PreambleCmds.admonition
+ if 'error' in node['classes'] and not self.fallback_stylesheet:
self.fallbacks['error'] = PreambleCmds.error
self.duclass_open(node)
self.out.append('\\begin{DUadmonition}')
@@ -1797,7 +1658,6 @@
self.out.append('}')
def visit_subscript(self, node):
- self.fallbacks['textsubscript'] = PreambleCmds.textsubscript
self.out.append(r'\textsubscript{')
if node['classes']:
self.visit_inline(node)
@@ -1814,7 +1674,8 @@
self.out.append('}\n')
def visit_title_reference(self, node):
- self.fallbacks['titlereference'] = PreambleCmds.titlereference
+ if not self.fallback_stylesheet:
+ self.fallbacks['titlereference'] = PreambleCmds.titlereference
self.out.append(r'\DUroletitlereference{')
if node['classes']:
self.visit_inline(node)
@@ -1975,8 +1836,9 @@
if self.docinfo:
# tabularx: automatic width of columns, no page breaks allowed.
self.requirements['tabularx'] = r'\usepackage{tabularx}'
- self.fallbacks['_providelength'] = PreambleCmds.providelength
- self.fallbacks['docinfo'] = PreambleCmds.docinfo
+ if not self.fallback_stylesheet:
+ self.fallbacks['_providelength'] = PreambleCmds.providelength
+ self.fallbacks['docinfo'] = PreambleCmds.docinfo
#
self.docinfo.insert(0, '\n% Docinfo\n'
'\\begin{center}\n'
@@ -2258,7 +2120,8 @@
def visit_field_list(self, node):
self.duclass_open(node)
if self.out is not self.docinfo:
- self.fallbacks['fieldlist'] = PreambleCmds.fieldlist
+ if not self.fallback_stylesheet:
+ self.fallbacks['fieldlist'] = PreambleCmds.fieldlist
self.out.append('\\begin{DUfieldlist}')
def depart_field_list(self, node):
@@ -2281,7 +2144,7 @@
self.out.append(':}]')
def visit_figure(self, node):
- self.requirements['float_settings'] = PreambleCmds.float_settings
+ self.requirements['float'] = PreambleCmds.float
self.duclass_open(node)
# The 'align' attribute sets the "outer alignment",
# for "inner alignment" use LaTeX default alignment (similar to HTML)
@@ -2315,7 +2178,8 @@
except IndexError:
backref = node['ids'][0] # no backref, use self-ref instead
if self.docutils_footnotes:
- self.fallbacks['footnotes'] = PreambleCmds.footnotes
+ if not self.fallback_stylesheet:
+ self.fallbacks['footnotes'] = PreambleCmds.footnotes
num = node[0].astext()
if self.settings.footnote_references == 'brackets':
num = '[%s]' % num
@@ -2353,7 +2217,8 @@
self.out.append('\\hyperlink{%s}{[' % href)
self.context.append(']}')
else:
- self.fallbacks['footnotes'] = PreambleCmds.footnotes
+ if not self.fallback_stylesheet:
+ self.fallbacks['footnotes'] = PreambleCmds.footnotes
self.out.append(r'\DUfootnotemark{%s}{%s}{' %
(node['ids'][0], href))
self.context.append('}')
@@ -2413,7 +2278,8 @@
# XeTeX does not know the length unit px.
# Use \pdfpxdimen, the macro to set the value of 1 px in pdftex.
# This way, configuring works the same for pdftex and xetex.
- self.fallbacks['_providelength'] = PreambleCmds.providelength
+ if not self.fallback_stylesheet:
+ self.fallbacks['_providelength'] = PreambleCmds.providelength
self.fallbacks['px'] = '\n\\DUprovidelength{\\pdfpxdimen}{1bp}\n'
length_str = r'%s\pdfpxdimen' % value
return length_str
@@ -2485,7 +2351,8 @@
self.babel.otherlanguages[language] = True
self.out.append(r'\foreignlanguage{%s}{' % language)
else:
- self.fallbacks['inline'] = PreambleCmds.inline
+ if not self.fallback_stylesheet:
+ self.fallbacks['inline'] = PreambleCmds.inline
self.out.append(r'\DUrole{%s}{' % cls)
def depart_inline(self, node):
@@ -2492,7 +2359,8 @@
self.out.append('}' * len(node['classes']))
def visit_legend(self, node):
- self.fallbacks['legend'] = PreambleCmds.legend
+ if not self.fallback_stylesheet:
+ self.fallbacks['legend'] = PreambleCmds.legend
self.out.append('\\begin{DUlegend}')
def depart_legend(self, node):
@@ -2505,8 +2373,9 @@
self.out.append('\n')
def visit_line_block(self, node):
- self.fallbacks['_providelength'] = PreambleCmds.providelength
- self.fallbacks['lineblock'] = PreambleCmds.lineblock
+ if not self.fallback_stylesheet:
+ self.fallbacks['_providelength'] = PreambleCmds.providelength
+ self.fallbacks['lineblock'] = PreambleCmds.lineblock
self.set_align_from_classes(node)
if isinstance(node.parent, nodes.line_block):
self.out.append('\\item[]\n'
@@ -2529,10 +2398,11 @@
def visit_literal(self, node):
self.literal = True
- if 'code' in node['classes'] and (
- self.settings.syntax_highlight != 'none'):
+ if ('code' in node['classes'] and
+ self.settings.syntax_highlight != 'none'):
self.requirements['color'] = PreambleCmds.color
- self.fallbacks['code'] = PreambleCmds.highlight_rules
+ if not self.fallback_stylesheet:
+ self.fallbacks['code'] = PreambleCmds.highlight_rules
self.out.append('\\texttt{')
if node['classes']:
self.visit_inline(node)
@@ -2590,10 +2460,12 @@
self.out += ['\n'] + self.ids_to_labels(node)
self.duclass_open(node)
# Highlight code?
- if (not _plaintext and 'code' in node['classes']
+ if (not _plaintext
+ and 'code' in node['classes']
and self.settings.syntax_highlight != 'none'):
self.requirements['color'] = PreambleCmds.color
- self.fallbacks['code'] = PreambleCmds.highlight_rules
+ if not self.fallback_stylesheet:
+ self.fallbacks['code'] = PreambleCmds.highlight_rules
# Wrap?
if _in_table and _use_env and not _autowidth_table:
# Wrap in minipage to prevent extra vertical space
@@ -2727,8 +2599,9 @@
self.out.append('] ')
def visit_option_list(self, node):
- self.fallbacks['_providelength'] = PreambleCmds.providelength
- self.fallbacks['optionlist'] = PreambleCmds.optionlist
+ if not self.fallback_stylesheet:
+ self.fallbacks['_providelength'] = PreambleCmds.providelength
+ self.fallbacks['optionlist'] = PreambleCmds.optionlist
self.duclass_open(node)
self.out.append('\\begin{DUoptionlist}')
@@ -2872,7 +2745,8 @@
self.depart_docinfo_item(node)
def visit_rubric(self, node):
- self.fallbacks['rubric'] = PreambleCmds.rubric
+ if not self.fallback_stylesheet:
+ self.fallbacks['rubric'] = PreambleCmds.rubric
# class wrapper would interfere with ``\section*"`` type commands
# (spacing/indent of first paragraph)
self.out.append('\n\\DUrubric{')
@@ -2895,7 +2769,8 @@
def visit_sidebar(self, node):
self.duclass_open(node)
self.requirements['color'] = PreambleCmds.color
- self.fallbacks['sidebar'] = PreambleCmds.sidebar
+ if not self.fallback_stylesheet:
+ self.fallbacks['sidebar'] = PreambleCmds.sidebar
self.out.append('\\DUsidebar{')
def depart_sidebar(self, node):
@@ -2941,7 +2816,8 @@
def visit_subtitle(self, node):
if isinstance(node.parent, nodes.document):
self.push_output_collector(self.subtitle)
- self.fallbacks['documentsubtitle'] = PreambleCmds.documentsubtitle
+ if not self.fallback_stylesheet:
+ self.fallbacks['documentsubtitle'] = PreambleCmds.documentsubtitle
protect = (self.settings.documentclass == 'memoir')
self.subtitle_labels += self.ids_to_labels(node, set_anchor=False,
protect=protect)
@@ -2950,7 +2826,8 @@
self.out.append(r'\%s*{' %
self.d_class.section(self.section_level + 1))
else:
- self.fallbacks['subtitle'] = PreambleCmds.subtitle
+ if not self.fallback_stylesheet:
+ self.fallbacks['subtitle'] = PreambleCmds.subtitle
self.out.append('\n\\DUsubtitle{')
def depart_subtitle(self, node):
@@ -2961,7 +2838,8 @@
def visit_system_message(self, node):
self.requirements['color'] = PreambleCmds.color
- self.fallbacks['title'] = PreambleCmds.title
+ if not self.fallback_stylesheet:
+ self.fallbacks['title'] = PreambleCmds.title
if self.settings.legacy_class_functions:
self.fallbacks['title'] = PreambleCmds.title_legacy
node['classes'] = ['system-message']
@@ -3109,7 +2987,8 @@
self.fallbacks['title'] = PreambleCmds.title_legacy
self.out.append('\n\\DUtitle[%s]{' % ','.join(classes))
else:
- self.fallbacks['title'] = PreambleCmds.title
+ if not self.fallback_stylesheet:
+ self.fallbacks['title'] = PreambleCmds.title
self.out.append('\n\\DUtitle{')
self.context.append('}\n')
# Table caption
@@ -3132,7 +3011,8 @@
self.out.append(r'\%s{' % section_name)
if self.section_level > len(self.d_class.sections):
# section level not supported by LaTeX
- self.fallbacks['title'] = PreambleCmds.title
+ if not self.fallback_stylesheet:
+ self.fallbacks['title'] = PreambleCmds.title
# self.out.append('\\phantomsection%\n ')
# label and ToC entry:
bookmark = ['']
@@ -3229,12 +3109,14 @@
else:
# special topics:
if 'abstract' in node['classes']:
- self.fallbacks['abstract'] = PreambleCmds.abstract
+ if not self.fallback_stylesheet:
+ self.fallbacks['abstract'] = PreambleCmds.abstract
if self.settings.legacy_class_functions:
self.fallbacks['abstract'] = PreambleCmds.abstract_legacy
self.push_output_collector(self.abstract)
elif 'dedication' in node['classes']:
- self.fallbacks['dedication'] = PreambleCmds.dedication
+ if not self.fallback_stylesheet:
+ self.fallbacks['dedication'] = PreambleCmds.dedication
self.push_output_collector(self.dedication)
else:
node['classes'].insert(0, 'topic')
@@ -3252,7 +3134,8 @@
self.pop_output_collector()
def visit_transition(self, node):
- self.fallbacks['transition'] = PreambleCmds.transition
+ if not self.fallback_stylesheet:
+ self.fallbacks['transition'] = PreambleCmds.transition
self.out.append('\n%' + '_' * 75 + '\n')
self.out.append('\\DUtransition\n')
Added: trunk/docutils/docutils/writers/latex2e/docutils.sty
===================================================================
--- trunk/docutils/docutils/writers/latex2e/docutils.sty (rev 0)
+++ trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-08-28 20:07:40 UTC (rev 8545)
@@ -0,0 +1,264 @@
+% docutils.sty
+% ************
+% Style file for docutils LaTeX output
+% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+%
+% :Copyright: © 2020 Günter Milde
+% :Licence: Released under the terms of the `2-Clause BSD license`_, in short:
+%
+% Copying and distribution of this file, with or without modification,
+% are permitted in any medium without royalty provided the copyright
+% notice and this notice are preserved.
+% This file is offered as-is, without any warranty.
+%
+% .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
+%
+%
+% :Abstract: Helper commands and element definitions for Docutils_ LaTeX output.
+%
+% :Identification:
+% ::
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{docutils}
+ [2020/08/28 v0.1 macros for Docutils LaTeX output]
+
+% Changelog:
+% .. class:: borderless
+%
+% ====== ========== =========================================================
+% 0.1 2020-08-28 initial version
+% ====== ========== =========================================================
+%
+%
+% Motivation
+% ==========
+%
+% Several elements of the `Docutils document tree`_ have no corresponding
+% LaTeX construct. Others lack configurability_.
+%
+% Authors may specify this package with the `"stylesheet"`_ configuration_
+% option. Alternatively, the `Docutils LaTeX writer`_ will extract required
+% definitions and insert them into the preamble of generated documents.
+
+% Helpers
+% =======
+%
+% duclass::
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {\def\DocutilsClassFunctionName{DUCLASS#1}% "#1" does not work in end-part of environment.
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+
+% providelength::
+
+% Provide a length variable and set default, if it is new
+\providecommand*{\DUprovidelength}[2]{
+ \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+}
+
+
+% Configuration defaults
+% ======================
+%
+% See `Docutils LaTeX Writer`_ for details.
+%
+% abstract::
+
+\providecommand*{\DUCLASSabstract}{
+ \renewcommand{\DUtitle}[1]{\centerline{\textbf{##1}}}
+}
+
+% dedication::
+
+% special topic for dedications
+\providecommand*{\DUCLASSdedication}{%
+ \renewenvironment{quote}{\begin{center}}{\end{center}}%
+}
+
+% TODO: add \em to set dedication text in italics?
+
+% docinfo::
+
+% width of docinfo table
+\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
+
+% error::
+
+\providecommand*{\DUCLASSerror}{\color{red}}
+
+% highlight_rules::
+
+% basic code highlight:
+\providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+\providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+\providecommand*\DUrolekeyword[1]{\textbf{#1}}
+\providecommand*\DUrolestring[1]{\textit{#1}}
+
+% Elements
+% ============
+%
...
[truncated message content] |
|
From: <mi...@us...> - 2020-08-30 13:07:59
|
Revision: 8549
http://sourceforge.net/p/docutils/code/8549
Author: milde
Date: 2020-08-30 13:07:56 +0000 (Sun, 30 Aug 2020)
Log Message:
-----------
Small documentation update.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-08-29 11:57:34 UTC (rev 8548)
+++ trunk/docutils/HISTORY.txt 2020-08-30 13:07:56 UTC (rev 8549)
@@ -72,15 +72,27 @@
- Use LaTeX environments for admonitions and "class wrappers" for styling
admonitions and titles if the new configuration setting
`legacy_class_functions`_ is False.
+
+ .. _legacy_class_functions: docs/user/config.html#legacy-class-functions
+
- Remove backwards compatibility code for the deprecated
`styling command`__ prefix ``\docutilsrole``.
- __ docs/user/latex.html#classes
+ __ docs/user/latex.html#custom-interpreted-text-roles
- Support the `memoir` LaTeX document class.
Fixes #390, #391, and #392.
+
+ - The special value "auto" for the `graphicx_option`_ setting
+ is no longer supported (it never worked for xetex/luatex).
+ .. _graphicx_option: docs/user/config.html#graphicx-option
+
+ - Most helper commands and element definitions are now defined in the
+ LaTeX package `docutils.sty` and no longer inserted in the document
+ preamble if the `stylesheet` setting lists "docutils".
+
* docutils/writers/manpage.py
- Fix #394 fix missing new line after rubric.
@@ -93,7 +105,6 @@
- Run python3 test like python2 against source not the build/-directory
.. _pip: https://pypi.org/project/pip/
-.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Release 0.16
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-08-29 11:57:34 UTC (rev 8548)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-08-30 13:07:56 UTC (rev 8549)
@@ -28,7 +28,7 @@
* HTML5 writer:
Do not use <h1> for section headings when it is used for the document
title. https://www.w3.org/wiki/HTML/Usage/Headings/h1only
-
+
Use <blockquote> instead of <div> tags for topics and admonitions.
* ``Node.traverse()`` will return an iterator instead of a list.
@@ -36,9 +36,9 @@
* Remove ``utils.unique_combinations``
(obsoleted by ``itertools.combinations``).
-* Eventually remove the "rawsource" attribute and argument from nodes.Text: we
- store the null-escaped text in Text nodes since 0.16 so there is no additional
- information in the rawsource.
+* Eventually remove the "rawsource" attribute and argument from nodes.Text:
+ we store the null-escaped text in Text nodes since 0.16 so there is no
+ additional information in the rawsource.
* If the id_prefix_ setting is non-empty, leading number and hyphen characters
will not be stripped from a `reference name`_ during `identifier
@@ -91,19 +91,29 @@
Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
-
* LaTeX writer:
- New configuration setting `legacy_class_functions`_.
+ - The special value "auto" for the `graphicx_option`_ setting
+ is no longer supported (it never worked for xetex/luatex).
+
- `Styling commands`__ using the legacy ``\docutilsrole`` prefix are
now ignored. Use ``\DUrole``.
__ docs/user/latex.html#classes
+ - Most helper commands and element definitions are now defined in the
+ LaTeX package `docutils.sty` and no longer inserted in the document
+ preamble if the stylesheet__ setting lists "docutils".
+
+ __ docs/user/config.html#stylesheet-latex-writers
+
.. _setuptools: https://pypi.org/project/setuptools/
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
+.. _graphicx_option: docs/user/config.html#graphicx-option
+.. docutils.sty: https://ctan.org/pkg/docutils (coming soon)
Release 0.16 (2020-01-12)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-09-01 21:49:50
|
Revision: 8550
http://sourceforge.net/p/docutils/code/8550
Author: milde
Date: 2020-09-01 21:49:48 +0000 (Tue, 01 Sep 2020)
Log Message:
-----------
Formatting (no change to functionality).
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/docutils.sty
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
Modified: trunk/docutils/docutils/writers/latex2e/docutils.sty
===================================================================
--- trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-08-30 13:07:56 UTC (rev 8549)
+++ trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-09-01 21:49:48 UTC (rev 8550)
@@ -14,35 +14,46 @@
% .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
%
%
-% :Abstract: Helper commands and element definitions for Docutils_ LaTeX output.
+% :Abstract:
+% Helper commands and element definitions for Docutils_ LaTeX output.
%
-% :Identification:
-% ::
-
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{docutils}
- [2020/08/28 v0.1 macros for Docutils LaTeX output]
-
-% Changelog:
-% .. class:: borderless
+% :Changelog:
+% .. class:: borderless
%
-% ====== ========== =========================================================
-% 0.1 2020-08-28 initial version
-% ====== ========== =========================================================
+% ====== ========== =========================================================
+% 0.1 2020-08-28 initial version
+% ====== ========== =========================================================
%
+% Installation
+% ============
%
-% Motivation
-% ==========
+% Copy/Move/Link ``docutils.sty`` to a suitable place in the “TeX Directory
+% Structure” (TDS_) and run ``texhash``, or place it in the current working
+% directory (e.g. for testing).
%
-% Several elements of the `Docutils document tree`_ have no corresponding
-% LaTeX construct. Others lack configurability_.
+% Usage
+% =====
%
-% Authors may specify this package with the `"stylesheet"`_ configuration_
-% option. Alternatively, the `Docutils LaTeX writer`_ will extract required
-% definitions and insert them into the preamble of generated documents.
+% When generating LaTeX documents from reStructuredText sources,
+% specify this package with the `"stylesheet"`_ configuration_ option, e.g.
+% ``rst2latex --stylesheet=docutils``.
+% Alternatively, the Docutils `LaTeX writer` will extract required definitions
+% and insert them into the preamble of generated documents
+% (see `Docutils LaTeX Writer`_ for details).
+%
+%
+% Implementation
+% ==============
+%
+% ::
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{docutils}
+ [2020/08/28 v0.1 macros for Docutils LaTeX output]
+
+
% Helpers
-% =======
+% -------
%
% duclass::
@@ -51,7 +62,8 @@
% \end{DUclass}{spam} tries \endDUCLASSspam
\ifx\DUclass\undefined % poor man's "provideenvironment"
\newenvironment{DUclass}[1]%
- {\def\DocutilsClassFunctionName{DUCLASS#1}% "#1" does not work in end-part of environment.
+ {% "#1" does not work in end-part of environment.
+ \def\DocutilsClassFunctionName{DUCLASS#1}
\csname \DocutilsClassFunctionName \endcsname}%
{\csname end\DocutilsClassFunctionName \endcsname}%
\fi
@@ -65,7 +77,7 @@
% Configuration defaults
-% ======================
+% ----------------------
%
% See `Docutils LaTeX Writer`_ for details.
%
@@ -83,7 +95,7 @@
}
% TODO: add \em to set dedication text in italics?
-
+%
% docinfo::
% width of docinfo table
@@ -102,7 +114,7 @@
\providecommand*\DUrolestring[1]{\textit{#1}}
% Elements
-% ============
+% --------
%
% Definitions for unknown or to-be-configured Docutils elements
% and roles (inline elements).
@@ -244,11 +256,11 @@
}
% References
-% ----------
+% ==========
%
% .. [Docutils] https://docutils.sourceforge.io/
%
-% .. _Docutils Document Tree:
+% .. _Docutils Document Tree:
% https://docutils.sourceforge.io/docs/ref/doctree.html
%
% .. _Docutils LaTeX Writer:
@@ -260,5 +272,4 @@
% .. _"stylesheet":
% https://docutils.sourceforge.io/docs/user/config.html#stylesheet-latex-writers
%
-% .. _configurability:
-% https://docutils.sourceforge.io/docs/user/latex.html#how-to-configure-the
+% .. _TDS: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tds
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2020-08-30 13:07:56 UTC (rev 8549)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2020-09-01 21:49:48 UTC (rev 8550)
@@ -41,7 +41,8 @@
% \end{DUclass}{spam} tries \endDUCLASSspam
\ifx\DUclass\undefined % poor man's "provideenvironment"
\newenvironment{DUclass}[1]%
- {\def\DocutilsClassFunctionName{DUCLASS#1}% "#1" does not work in end-part of environment.
+ {% "#1" does not work in end-part of environment.
+ \def\DocutilsClassFunctionName{DUCLASS#1}
\csname \DocutilsClassFunctionName \endcsname}%
{\csname end\DocutilsClassFunctionName \endcsname}%
\fi
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-08-30 13:07:56 UTC (rev 8549)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-09-01 21:49:48 UTC (rev 8550)
@@ -41,7 +41,8 @@
% \end{DUclass}{spam} tries \endDUCLASSspam
\ifx\DUclass\undefined % poor man's "provideenvironment"
\newenvironment{DUclass}[1]%
- {\def\DocutilsClassFunctionName{DUCLASS#1}% "#1" does not work in end-part of environment.
+ {% "#1" does not work in end-part of environment.
+ \def\DocutilsClassFunctionName{DUCLASS#1}
\csname \DocutilsClassFunctionName \endcsname}%
{\csname end\DocutilsClassFunctionName \endcsname}%
\fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-09-04 16:55:29
|
Revision: 8556
http://sourceforge.net/p/docutils/code/8556
Author: milde
Date: 2020-09-04 16:55:24 +0000 (Fri, 04 Sep 2020)
Log Message:
-----------
Change the `initial_header_level`_ setting's default to "2"
Browsers use the `same style for <h1> and <h2> when it's
nested in a section`.
cf. https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article
Modified Paths:
--------------
trunk/docutils/FAQ.txt
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
trunk/docutils/docutils/writers/html5_polyglot/plain.css
trunk/docutils/docutils/writers/html5_polyglot/tuftig.css
trunk/docutils/test/functional/expected/footnotes_html5.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
Modified: trunk/docutils/FAQ.txt
===================================================================
--- trunk/docutils/FAQ.txt 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/FAQ.txt 2020-09-04 16:55:24 UTC (rev 8556)
@@ -995,7 +995,12 @@
(Thanks to Mark McEahern for the question and much of the answer.)
+.. note:: For the html5 writer, `initial_header_level`_ defaults to
+ ``2`` because this is what the `HTML5 standard`__ expects as
+ start value for headings nested in <section> elements.
+ __ https://www.w3.org/TR/html53/sections.html#headings-and-sections
+
How are lists formatted in HTML?
--------------------------------
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/HISTORY.txt 2020-09-04 16:55:24 UTC (rev 8556)
@@ -54,6 +54,11 @@
- Use the new semantic tags <main>, <section>, <header>,
<footer>, <aside>, <figure>, and <figcaption>.
See ``minimal.css`` and ``plain.css`` for styling rule examples.
+
+ Change the `initial_header_level` setting default to "2", as browsers
+ use the `same style for <h1> and <h2> when nested in a <section>`__.
+
+ __ https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
<i>, <b>, <u>, <mark>, and <bdi> if a matching class value
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-09-04 16:55:24 UTC (rev 8556)
@@ -26,9 +26,6 @@
and/or ``\DUtitle`` or set to "True".
* HTML5 writer:
- Do not use <h1> for section headings when it is used for the document
- title. https://www.w3.org/wiki/HTML/Usage/Headings/h1only
-
Use <blockquote> instead of <div> tags for topics and admonitions.
* ``Node.traverse()`` will return an iterator instead of a list.
@@ -81,6 +78,9 @@
<footer>, <aside>, <figure>, and <figcaption>.
See ``minimal.css`` and ``plain.css`` for styling rule examples.
+ Change the `initial_header_level`_ setting's default to "2", as browsers
+ use the `same style for <h1> and <h2> when nested in a section`__.
+
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
<i>, <b>, <u>, <mark>, and <bdi> if a matching class value
is found in `inline` and `literal` elements.
@@ -91,6 +91,11 @@
Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
+ .. _initial_header_level: docs/user/config.html#initial-header-level
+ __ https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article
+
+
+
* LaTeX writer:
- New configuration setting `legacy_class_functions`_.
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/docs/user/config.txt 2020-09-04 16:55:24 UTC (rev 8556)
@@ -976,7 +976,9 @@
The initial level for header elements. This does not affect the
document title & subtitle; see doctitle_xform_.
-Default: 1 (for "<h1>"). Option: ``--initial-header-level``.
+Default: writer dependent (see `[html4css1 writer]`_, `[html5 writer]`_,
+`[pep_html writer]`_).
+Option: ``--initial-header-level``.
math_output
@@ -1139,7 +1141,7 @@
deactivate stylesheet inclusion.
Default: writer dependent (see `[html4css1 writer]`_, `[html5 writer]`_,
-[pep_html writer]_).
+`[pep_html writer]`_).
Options: ``--stylesheet-path``.
__ `embed_stylesheet [html writers]`_
@@ -1216,6 +1218,9 @@
Writer specific defaults:
+`initial_header_level`_
+ 1 (for "<h1>")
+
`stylesheet_path <stylesheet_path [html writers]_>`__:
"html4css1.css"
@@ -1253,15 +1258,20 @@
Writer specific defaults:
+`initial_header_level`_
+ 2 (for "<h2>", cf. the `HTML5.3 Working Draft`__)
+
`stylesheet_path <stylesheet_path [html writers]_>`__:
"minimal.css,plain.css"
New in Docutils 0.13.
+__ https://www.w3.org/TR/html53/sections.html#the-h1-h2-h3-h4-h5-and-h6-elements
.. _HTML5 Writer: html.html#html5-polyglot
.. _HTML5: http://www.w3.org/TR/html5/
+
[pep_html writer]
~~~~~~~~~~~~~~~~~
@@ -1271,6 +1281,9 @@
Writer specific defaults:
+`initial_header_level`_
+ 1 (for "<h1>")
+
`stylesheet_path <stylesheet_path [html writers]_>`__:
"pep.css"
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-09-04 16:55:24 UTC (rev 8556)
@@ -12,7 +12,7 @@
# notice and this notice are preserved.
# This file is offered as-is, without any warranty.
#
-# .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
# Use "best practice" as recommended by the W3C:
# http://www.w3.org/2009/cheatsheet/
@@ -82,10 +82,10 @@
{'metavar': '<dir[,dir,...]>',
'validator': frontend.validate_comma_separated_list,
'default': default_stylesheet_dirs}),
- ('Specify the initial header level. Default is 1 for "<h1>". '
+ ('Specify the initial header level. Default is 2 for "<h2>". '
'Does not affect document title & subtitle (see --no-doc-title).',
['--initial-header-level'],
- {'choices': '1 2 3 4 5 6'.split(), 'default': '1',
+ {'choices': '1 2 3 4 5 6'.split(), 'default': '2',
'metavar': '<level>'}),
('Format for footnote references: one of "superscript" or '
'"brackets". Default is "brackets".',
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2020-09-04 16:55:24 UTC (rev 8556)
@@ -40,10 +40,10 @@
font-weight: bold;
}
h1 + p.subtitle,
-h1 + p.section-subtitle {
+h2 + p.section-subtitle {
font-size: 1.6em;
}
-h2 + p.section-subtitle {
+h3 + p.section-subtitle {
font-size: 1.28em;
}
p.subtitle,
@@ -64,7 +64,7 @@
text-decoration: none; }
/* Warnings, Errors */
-div.system-messages h1,
+div.system-messages h2,
span.problematic,
p.system-message-title {
color: red;
Modified: trunk/docutils/docutils/writers/html5_polyglot/plain.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/plain.css 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/docutils/writers/html5_polyglot/plain.css 2020-09-04 16:55:24 UTC (rev 8556)
@@ -220,7 +220,7 @@
margin-left: 1em;
}
/* Stop floating sidebars, images and figures at section level 1,2,3 */
-h1, h2, h3 { clear: both; }
+h1, h2, h3, h4 { clear: both; }
/* Numbered figures */
figure.numbered > figcaption > p:before {
Modified: trunk/docutils/docutils/writers/html5_polyglot/tuftig.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/tuftig.css 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/docutils/writers/html5_polyglot/tuftig.css 2020-09-04 16:55:24 UTC (rev 8556)
@@ -62,13 +62,13 @@
section > div.topic.contents,
section > ol,
section > ul,
-section > h3,
+section > h4,
hr.docutils {
background: GhostWhite;
box-sizing: border-box;
width: 55%; /* of max 100em ≦ 55em, ca. 90…100 characters */
}
-section > h1, section > h2 {
+section > h2, section > h3 {
width: 60% /* cf. tufte-latex */
}
section > table {
@@ -139,9 +139,9 @@
section > div.topic.contents,
section > ol,
section > ul,
- section > h3,
+ section > h4,
hr.docutils,
- section > h1, section > h2 {
+ section > h2, section > h3 {
width: 95%;
}
section > table,
@@ -171,7 +171,7 @@
/* Titles and Headings */
-h1, h2, h3, p.subtitle, p.section-subtitle,
+h2, h3, h4, p.subtitle, p.section-subtitle,
p.topic-title, p.sidebar-title, p.sidebar-subtitle {
font-weight: 400;
font-style: italic;
@@ -199,19 +199,19 @@
font-size: 2.0em;
clear: both;
}
-h1 + p.section-subtitle {
+h2 + p.section-subtitle {
font-size: 1.6em;
}
-h2 {
+h3 {
margin-top: 2em;
font-size: 1.2em;
}
-h2 + p.section-subtitle {
+h3 + p.section-subtitle {
font-size: 1.1em;
}
-h3 {
+h4 {
margin-top: 1.7em;
font-size: 1.1em;
}
Modified: trunk/docutils/test/functional/expected/footnotes_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/footnotes_html5.html 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/test/functional/expected/footnotes_html5.html 2020-09-04 16:55:24 UTC (rev 8556)
@@ -44,7 +44,7 @@
</dd>
</dl>
<section id="citations">
-<h1>Citations</h1>
+<h2>Citations</h2>
<dl class="citation">
<dt class="label" id="cit2002"><span class="brackets">CIT2002</span><span class="fn-backref">(<a href="#citation-reference-1">1</a>,<a href="#citation-reference-3">2</a>)</span></dt>
<dd><p>Citations are text-labeled footnotes. They may be
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-09-04 16:53:11 UTC (rev 8555)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-09-04 16:55:24 UTC (rev 8556)
@@ -165,9 +165,9 @@
</ul>
</div>
<section id="structural-elements">
-<h1><a class="toc-backref" href="#toc-entry-1"><span class="sectnum">1</span> Structural Elements</a></h1>
+<h2><a class="toc-backref" href="#toc-entry-1"><span class="sectnum">1</span> Structural Elements</a></h2>
<section id="section-title">
-<h2 class="with-subtitle"><a class="toc-backref" href="#toc-entry-2"><span class="sectnum">1.1</span> Section Title</a></h2>
+<h3 class="with-subtitle"><a class="toc-backref" href="#toc-entry-2"><span class="sectnum">1.1</span> Section Title</a></h3>
<p class="section-subtitle" id="section-subtitle">Section Subtitle</p>
<p>Lone subsections are converted to a section subtitle by a transform
activated with the <span class="docutils literal"><span class="pre">--section-subtitles</span></span> command line option or the
@@ -174,10 +174,10 @@
<span class="docutils literal"><span class="pre">sectsubtitle-xform</span></span> configuration value.</p>
</section>
<section id="empty-section">
-<h2><a class="toc-backref" href="#toc-entry-3"><span class="sectnum">1.2</span> Empty Section</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-3"><span class="sectnum">1.2</span> Empty Section</a></h3>
</section>
<section id="transitions">
-<h2><a class="toc-backref" href="#toc-entry-4"><span class="sectnum">1.3</span> Transitions</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-4"><span class="sectnum">1.3</span> Transitions</a></h3>
<p>Here's a transition:</p>
<hr class="docutils" />
<p>It divides the section. Transitions may also occur between sections:</p>
@@ -185,12 +185,12 @@
</section>
<hr class="docutils" />
<section id="body-elements">
-<h1><a class="toc-backref" href="#toc-entry-5"><span class="sectnum">2</span> Body Elements</a></h1>
+<h2><a class="toc-backref" href="#toc-entry-5"><span class="sectnum">2</span> Body Elements</a></h2>
<section id="paragraphs">
-<h2><a class="toc-backref" href="#toc-entry-6"><span class="sectnum">2.1</span> Paragraphs</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-6"><span class="sectnum">2.1</span> Paragraphs</a></h3>
<p>A paragraph.</p>
<section id="inline-markup">
-<h3><a class="toc-backref" href="#toc-entry-7"><span class="sectnum">2.1.1</span> Inline Markup</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-7"><span class="sectnum">2.1.1</span> Inline Markup</a></h4>
<p>Paragraphs contain text and may contain inline markup: <em>emphasis</em>,
<strong>strong emphasis</strong>, <span class="docutils literal">inline literals</span>, standalone hyperlinks
(<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 brackets" href="#footnote-7" id="footnote-reference-18">7</a>), internal
@@ -219,7 +219,7 @@
</section>
</section>
<section id="bullet-lists">
-<h2><a class="toc-backref" href="#toc-entry-8"><span class="sectnum">2.2</span> Bullet Lists</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-8"><span class="sectnum">2.2</span> Bullet Lists</a></h3>
<ul>
<li><p>A bullet list</p>
<ul class="simple">
@@ -246,7 +246,7 @@
</ul>
</section>
<section id="enumerated-lists">
-<h2><a class="toc-backref" href="#toc-entry-9"><span class="sectnum">2.3</span> Enumerated Lists</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-9"><span class="sectnum">2.3</span> Enumerated Lists</a></h3>
<ol class="arabic">
<li><p>Arabic numerals.</p>
<ol class="loweralpha simple">
@@ -282,7 +282,7 @@
</ol>
</section>
<section id="definition-lists">
-<h2><a class="toc-backref" href="#toc-entry-10"><span class="sectnum">2.4</span> Definition Lists</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-10"><span class="sectnum">2.4</span> Definition Lists</a></h3>
<dl>
<dt>Term</dt>
<dd><p>Definition</p>
@@ -300,7 +300,7 @@
</dl>
</section>
<section id="field-lists">
-<h2><a class="toc-backref" href="#toc-entry-11"><span class="sectnum">2.5</span> Field Lists</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-11"><span class="sectnum">2.5</span> Field Lists</a></h3>
<dl class="field-list">
<dt>what</dt>
<dd><p>Field lists map field names to field bodies, like database
@@ -320,7 +320,7 @@
</dl>
</section>
<section id="option-lists">
-<h2><a class="toc-backref" href="#toc-entry-12"><span class="sectnum">2.6</span> Option Lists</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-12"><span class="sectnum">2.6</span> Option Lists</a></h3>
<p>For listing command-line options:</p>
<dl class="option-list">
<dt><kbd><span class="option">-a</span></kbd></dt>
@@ -359,7 +359,7 @@
description.</p>
</section>
<section id="literal-blocks">
-<h2><a class="toc-backref" href="#toc-entry-13"><span class="sectnum">2.7</span> Literal Blocks</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-13"><span class="sectnum">2.7</span> Literal Blocks</a></h3>
<p>Literal blocks are indicated with a double-colon ("::") at the end of
the preceding paragraph (over there <span class="docutils literal"><span class="pre">--></span></span>). They can be indented:</p>
<pre class="literal-block">if literal_block:
@@ -372,7 +372,7 @@
> Why didn't I think of that?</pre>
</section>
<section id="line-blocks">
-<h2><a class="toc-backref" href="#toc-entry-14"><span class="sectnum">2.8</span> Line Blocks</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-14"><span class="sectnum">2.8</span> Line Blocks</a></h3>
<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>
@@ -446,7 +446,7 @@
</div>
</section>
<section id="block-quotes">
-<h2><a class="toc-backref" href="#toc-entry-15"><span class="sectnum">2.9</span> Block Quotes</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-15"><span class="sectnum">2.9</span> Block Quotes</a></h3>
<p>Block quotes consist of indented body elements:</p>
<blockquote>
<p>My theory by A. Elk. Brackets Miss, brackets. This theory goes
@@ -465,7 +465,7 @@
</blockquote>
</section>
<section id="doctest-blocks">
-<h2><a class="toc-backref" href="#toc-entry-16"><span class="sectnum">2.10</span> Doctest Blocks</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-16"><span class="sectnum">2.10</span> Doctest Blocks</a></h3>
<pre class="code python doctest">>>> print 'Python-specific usage examples; begun with ">>>"'
Python-specific usage examples; begun with ">>>"
>>> print '(cut and pasted from interactive Python sessions)'
@@ -473,7 +473,7 @@
</pre>
</section>
<section id="footnotes">
-<h2><a class="toc-backref" href="#toc-entry-17"><span class="sectnum">2.11</span> Footnotes</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-17"><span class="sectnum">2.11</span> Footnotes</a></h3>
<dl class="footnote brackets">
<dt class="label" id="footnote-1"><span class="brackets">1</span><span class="fn-backref">(<a href="#footnote-reference-1">1</a>,<a href="#footnote-reference-5">2</a>,<a href="#footnote-reference-9">3</a>)</span></dt>
<dd><p>A footnote contains body elements, consistently indented by at
@@ -506,7 +506,7 @@
</dl>
</section>
<section id="citations">
-<h2><a class="toc-backref" href="#toc-entry-18"><span class="sectnum">2.12</span> Citations</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-18"><span class="sectnum">2.12</span> Citations</a></h3>
<dl class="citation">
<dt class="label" id="cit2002"><span class="brackets">CIT2002</span><span class="fn-backref">(<a href="#citation-reference-1">1</a>,<a href="#citation-reference-2">2</a>)</span></dt>
<dd><p>Citations are text-labeled footnotes. They may be
@@ -517,7 +517,7 @@
citation.</p>
</section>
<section id="targets">
-<span id="another-target"></span><h2><a class="toc-backref" href="#toc-entry-19"><span class="sectnum">2.13</span> Targets</a></h2>
+<span id="another-target"></span><h3><a class="toc-backref" href="#toc-entry-19"><span class="sectnum">2.13</span> Targets</a></h3>
<p id="example">This paragraph is pointed to by the explicit "example" target. A
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>
@@ -530,13 +530,13 @@
<p>Here's a <a href="#system-message-4"><span class="problematic" id="problematic-2">`hyperlink reference without a target`_</span></a>, which generates an
error.</p>
<section id="duplicate-target-names">
-<h3><a class="toc-backref" href="#toc-entry-20"><span class="sectnum">2.13.1</span> Duplicate Target Names</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-20"><span class="sectnum">2.13.1</span> Duplicate Target Names</a></h4>
<p>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.</p>
</section>
<section id="duplicate-target-names-1">
-<h3><a class="toc-backref" href="#toc-entry-21"><span class="sectnum">2.13.2</span> Duplicate Target Names</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-21"><span class="sectnum">2.13.2</span> Duplicate Target Names</a></h4>
<p>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: <a href="#system-message-5"><span class="problematic" id="problematic-3">`Duplicate Target Names`_</span></a>), an error is generated.</p>
@@ -543,7 +543,7 @@
</section>
</section>
<section id="directives">
-<h2><a class="toc-backref" href="#toc-entry-22"><span class="sectnum">2.14</span> Directives</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-22"><span class="sectnum">2.14</span> Directives</a></h3>
<div class="contents local topic" id="contents">
<ul class="auto-toc simple">
<li><p><a class="reference internal" href="#document-parts" id="toc-entry-55"><span class="sectnum">2.14.1</span> Document Parts</a></p></li>
@@ -562,13 +562,13 @@
others, please see
<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>
<section id="document-parts">
-<h3><a class="toc-backref" href="#toc-entry-55"><span class="sectnum">2.14.1</span> Document Parts</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-55"><span class="sectnum">2.14.1</span> Document Parts</a></h4>
<p>An example of the "contents" directive can be seen above this section
(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>
</section>
<section id="images-and-figures">
-<h3><a class="toc-backref" href="#toc-entry-56"><span class="sectnum">2.14.2</span> Images and Figures</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-56"><span class="sectnum">2.14.2</span> Images and Figures</a></h4>
<p>An image directive (also clickable -- a hyperlink reference):</p>
<p class="image-wrapper"><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>
<p>Image with multiple IDs:</p>
@@ -667,7 +667,7 @@
upon the style sheet and the browser or rendering software used.</p>
</section>
<section id="tables">
-<h3><a class="toc-backref" href="#toc-entry-57"><span class="sectnum">2.14.3</span> Tables</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-57"><span class="sectnum">2.14.3</span> Tables</a></h4>
<p>Tables may be given titles and additional arguments with the <em>table</em>
directive:</p>
<table class="align-left">
@@ -761,7 +761,7 @@
</table>
</section>
<section id="admonitions">
-<h3><a class="toc-backref" href="#toc-entry-58"><span class="sectnum">2.14.4</span> Admonitions</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-58"><span class="sectnum">2.14.4</span> Admonitions</a></h4>
<div class="admonition attention">
<p class="admonition-title">Attention!</p>
<p>Directives at large.</p>
@@ -810,7 +810,7 @@
</div>
</section>
<section id="topics-sidebars-and-rubrics">
-<h3><a class="toc-backref" href="#toc-entry-59"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-59"><span class="sectnum">2.14.5</span> Topics, Sidebars, and Rubrics</a></h4>
<p><em>Sidebars</em> are like miniature, parallel documents.</p>
<aside class="sidebar">
<p class="sidebar-title">Optional Sidebar Title</p>
@@ -834,7 +834,7 @@
allowed (e.g. inside a directive).</p>
</section>
<section id="target-footnotes">
-<h3><a class="toc-backref" href="#toc-entry-60"><span class="sectnum">2.14.6</span> Target Footnotes</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-60"><span class="sectnum">2.14.6</span> Target Footnotes</a></h4>
<dl class="footnote brackets">
<dt class="label" id="footnote-7"><span class="brackets">7</span><span class="fn-backref">(<a href="#footnote-reference-18">1</a>,<a href="#footnote-reference-19">2</a>,<a href="#footnote-reference-20">3</a>,<a href="#footnote-reference-25">4</a>)</span></dt>
<dd><p><a class="reference external" href="http://www.python.org/">http://www.python.org/</a></p>
@@ -863,11 +863,11 @@
</dl>
</section>
<section id="replacement-text">
-<h3><a class="toc-backref" href="#toc-entry-61"><span class="sectnum">2.14.7</span> Replacement Text</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-61"><span class="sectnum">2.14.7</span> Replacement Text</a></h4>
<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 brackets" href="#footnote-7" id="footnote-reference-20">7</a>.</p>
</section>
<section id="compound-paragraph">
-<h3><a class="toc-backref" href="#toc-entry-62"><span class="sectnum">2.14.8</span> Compound Paragraph</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-62"><span class="sectnum">2.14.8</span> Compound Paragraph</a></h4>
<p>The <em>compound</em> directive is used to create a "compound paragraph", which
is a single logical paragraph containing multiple physical body
elements. For example:</p>
@@ -978,7 +978,7 @@
</div>
</section>
<section id="parsed-literal-blocks">
-<h3><a class="toc-backref" href="#toc-entry-63"><span class="sectnum">2.14.9</span> Parsed Literal Blocks</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-63"><span class="sectnum">2.14.9</span> Parsed Literal Blocks</a></h4>
<pre class="literal-block">This is a parsed literal block.
This line is indented. The next line is blank.
@@ -988,7 +988,7 @@
footnotes <a class="footnote-reference brackets" href="#footnote-1" id="footnote-reference-9">1</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
</section>
<section id="code">
-<h3><a class="toc-backref" href="#toc-entry-64"><span class="sectnum">2.14.10</span> Code</a></h3>
+<h4><a class="toc-backref" href="#toc-entry-64"><span class="sectnum">2.14.10</span> Code</a></h4>
<p>Blocks of source code can be set with the <cite>code</cite> directive. If the code
language is specified, the content is parsed and tagged by the <a class="reference external" href="http://pygments.org/">Pygments</a> <a class="footnote-reference brackets" href="#footnote-8" id="footnote-reference-21">8</a>
syntax highlighter and can be formatted with a style sheet. (Code parsing
@@ -1014,13 +1014,13 @@
</section>
</section>
<section id="substitution-definitions">
-<h2><a class="toc-backref" href="#toc-entry-33"><span class="sectnum">2.15</span> Substitution Definitions</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-33"><span class="sectnum">2.15</span> Substitution Definitions</a></h3>
<p>An inline image (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" />) example:</p>
<p>A Unicode example:</p>
<p>(Substitution definitions are not visible in the HTML source.)</p>
</section>
<section id="comments">
-<h2><a class="toc-backref" href="#toc-entry-34"><span class="sectnum">2.16</span> Comments</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-34"><span class="sectnum">2.16</span> Comments</a></h3>
<p>Here's one:</p>
<!-- Comments begin with two dots and a space. Anything may
follow, except for the syntax of footnotes, hyperlink
@@ -1032,13 +1032,13 @@
<p>(View the HTML source to see the comment.)</p>
</section>
<section id="raw-text">
-<h2><a class="toc-backref" href="#toc-entry-35"><span class="sectnum">2.17</span> Raw text</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-35"><span class="sectnum">2.17</span> Raw text</a></h3>
<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.</section>
<section id="container">
-<h2><a class="toc-backref" href="#toc-entry-36"><span class="sectnum">2.18</span> Container</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-36"><span class="sectnum">2.18</span> Container</a></h3>
<div class="custom docutils container">
<p>paragraph 1</p>
<p>paragraph 2</p>
@@ -1045,7 +1045,7 @@
</div>
</section>
<section id="colspanning-tables">
-<h2><a class="toc-backref" href="#toc-entry-37"><span class="sectnum">2.19</span> Colspanning tables</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-37"><span class="sectnum">2.19</span> Colspanning tables</a></h3>
<p>This table has a cell spanning two columns:</p>
<table>
<colgroup>
@@ -1083,7 +1083,7 @@
</table>
</section>
<section id="rowspanning-tables">
-<h2><a class="toc-backref" href="#toc-entry-38"><span class="sectnum">2.20</span> Rowspanning tables</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-38"><span class="sectnum">2.20</span> Rowspanning tables</a></h3>
<p>Here's a table with cells spanning several rows:</p>
<table>
<colgroup>
@@ -1116,7 +1116,7 @@
</table>
</section>
<section id="complex-tables">
-<h2><a class="toc-backref" href="#toc-entry-39"><span class="sectnum">2.21</span> Complex tables</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-39"><span class="sectnum">2.21</span> Complex tables</a></h3>
<p>Here's a complex table, which should test all features.</p>
<table>
<colgroup>
@@ -1165,7 +1165,7 @@
</table>
</section>
<section id="list-tables">
-<h2><a class="toc-backref" href="#toc-entry-40"><span class="sectnum">2.22</span> List Tables</a></h2>
+<h3><a class="toc-backref" href="#toc-entry-40"><span class="sectnum">2.22</span> List Tables</a></h3>
<p>Here's a list table exercising all features:</p>
<table class="colwidths-given test" style="width: 40em">
<caption>list table with integral header</caption>
@@ -121...
[truncated message content] |
|
From: <mi...@us...> - 2020-09-04 16:58:27
|
Revision: 8557
http://sourceforge.net/p/docutils/code/8557
Author: milde
Date: 2020-09-04 16:58:24 +0000 (Fri, 04 Sep 2020)
Log Message:
-----------
LaTeX writer update
Fix workaround for section title of unsupported levels
with the new-style class handling (class wrapper instead of
class-argument for \DUtitle).
Require minimal version of "docutils.sty" to get a warning
in the LaTeX-log for obsolete files with the same name.
Update documentation.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docs/user/latex.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/latex2e/docutils.sty
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/HISTORY.txt 2020-09-04 16:58:24 UTC (rev 8557)
@@ -95,9 +95,13 @@
.. _graphicx_option: docs/user/config.html#graphicx-option
- Most helper commands and element definitions are now defined in the
- LaTeX package `docutils.sty` and no longer inserted in the document
- preamble if the `stylesheet` setting lists "docutils".
+ LaTeX package `docutils.sty`_ and only inserted in the document
+ preamble if the `stylesheet`__ setting does not list "docutils".
+
+ .. _docutils.sty: https://ctan.org/pkg/docutils
+ __ docs/user/config.html#stylesheet-latex-writers
+
* docutils/writers/manpage.py
- Fix #394 fix missing new line after rubric.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-09-04 16:58:24 UTC (rev 8557)
@@ -109,9 +109,9 @@
__ docs/user/latex.html#classes
- Most helper commands and element definitions are now defined in the
- LaTeX package `docutils.sty` and no longer inserted in the document
- preamble if the stylesheet__ setting lists "docutils".
-
+ LaTeX package `docutils.sty`_ and only inserted in the document
+ preamble if the stylesheet__ setting does not lists "docutils".
+
__ docs/user/config.html#stylesheet-latex-writers
.. _setuptools: https://pypi.org/project/setuptools/
@@ -118,7 +118,7 @@
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
.. _graphicx_option: docs/user/config.html#graphicx-option
-.. docutils.sty: https://ctan.org/pkg/docutils (coming soon)
+.. _docutils.sty: https://ctan.org/pkg/docutils
Release 0.16 (2020-01-12)
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/docs/user/config.txt 2020-09-04 16:58:24 UTC (rev 8557)
@@ -1473,8 +1473,7 @@
LaTeX graphicx package option.
-Possible values are "dvips", "pdftex", "auto". "auto" includes LaTeX code
-to use "pdftex" if processing with pdf(la)tex and dvips otherwise.
+Possible values are "dvips", "pdftex", "dvipdfmx".
Default: "". Option: ``--graphicx-option``.
Modified: trunk/docutils/docs/user/latex.txt
===================================================================
--- trunk/docutils/docs/user/latex.txt 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/docs/user/latex.txt 2020-09-04 16:58:24 UTC (rev 8557)
@@ -62,9 +62,12 @@
length) to allow customization. By convention, special macros use the
prefix ``\DU``\ [#]_.
+The `docutils.sty`_ LaTeX package providing required definitions is
+part of Docutils ≥ 0.17 and available on CTAN since 2020-09-04.
The generated LaTeX documents should be kept processable by a standard LaTeX
installation. Therefore fallback definitions are included after the `custom
-style sheets`_, if a macro is required in the document.
+style sheets`_, if a macro is required in the document and
+the `stylesheet`_ setting does not include "docutils".
* Custom `style sheets`_ can define alternative implementations with
``\newcommand``, ``\newenvironment``, and ``\newlength`` followed by
@@ -78,7 +81,10 @@
.. [#] DU for Documentation Utilities = Docutils
+.. _docutils.sty: https://ctan.org/pkg/docutils
+
+
Length units
------------
@@ -239,7 +245,7 @@
order of the class arguments cannot be ignored in LaTeX
* Class handling differs for some elements and class values:
-
+
* Class argument values starting with ``align-`` are transformed to
"align" argument values. Class argument values starting with
``language-`` set the elements language property.
@@ -442,10 +448,10 @@
Command:
``\DUadmonition`` (with legacy-class-functions_)
-
+
Environment:
``DUadmonition`` (with new-class-functions_)
-
+
.. _new-class-functions: legacy-class-functions_
Default:
@@ -466,9 +472,9 @@
\end{quote}
\fi
}
-
+
rsp with new-class-functions_::
-
+
\newenvironment{DUadmonition}%
{\begin{quote}}
{\end{quote}}
@@ -1569,7 +1575,7 @@
\subsubsection*{\centerline{\color{red}#1}}}
.. note::
- Class attribute values are ignored because the "classes_ wrapper"
+ Class attribute values are ignored because the "classes_ wrapper"
interferes with LaTeX's formatting (spacing/indendation) of text following
a section heading. Consider using a `topic element`_ or a container_.
@@ -1589,14 +1595,14 @@
===== ============= ================== ============= ==============
1 section part chapter part
2 subsection section section chapter
- 3 subsubsection subsection subsection section
- 4 paragraph subsubsection subsubsection subsection
+ 3 subsubsection subsection subsection section
+ 4 paragraph subsubsection subsubsection subsection
5 subparagraph paragraph paragraph subsubsection
- 6 DUtitle subparagraph subparagraph paragraph
- 7 DUtitle DUtitle DUtitle subparagraph
+ 6 DUtitle subparagraph subparagraph paragraph
+ 7 DUtitle DUtitle DUtitle subparagraph
===== ============= ================== ============= ==============
-
+
.. [#] One of the document classes 'book', 'memoir', 'report 'scrbook',
or 'scrreprt'.
@@ -1976,11 +1982,11 @@
* pdflatex_ and xelatex_ work with PNG, JPG, or PDF, but **not EPS**.
* Standard latex_ can include **only EPS** graphics, no other format.
* latex + dvipdfmx works with EPS and JPG (add 'dvipdfmx' to the
- documentoptions_ or graphicx_ setting
+ documentoptions_ or graphicx-option_ setting
and 'bmpsize' to the stylesheet_ setting).
If PDF-image inclusion in PDF files fails, specifying
-``--graphicx-option=pdftex`` or ``--graphicx-option=auto`` might help.
+``--graphicx-option=pdftex`` might help.
For details see grfguide.pdf_.
@@ -1995,8 +2001,8 @@
__ ../ref/rst/directives.html#images
.. _grfguide.pdf:
http://mirrors.ctan.org/macros/latex/required/graphics/grfguide.pdf
-.. _grffile:
- http://ctan.org/pkg/grffile
+.. _grffile: http://ctan.org/pkg/grffile
+.. _graphicx-option: config.html#graphicx-option
@@ -2089,7 +2095,7 @@
.. _pmboxdraw.pdf:
http://mirrors.ctan.org/macros/latex/contrib/pmboxdraw/pmboxdraw.pdf
-
+
Bugs and open issues
--------------------
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-09-04 16:58:24 UTC (rev 8557)
@@ -784,9 +784,10 @@
"""
if level <= len(self.sections):
return self.sections[level-1]
- else: # unsupported levels
- return 'DUtitle[section%s]' % roman.toRoman(level)
+ # unsupported levels
+ return 'DUtitle'
+
class Table(object):
"""Manage a table while traversing.
@@ -1238,17 +1239,21 @@
# (the name `self.stylesheet` is singular because only one
# stylesheet was supported before Docutils 0.6).
stylesheet_list = utils.get_stylesheet_list(settings)
- self.fallback_stylesheet = [sheet for sheet in stylesheet_list
- if sheet == 'docutils']
- # docutils.sty is incompatible with legacy functions
- if self.fallback_stylesheet and self.settings.legacy_class_functions:
- self.fallback_stylesheet = []
+ if 'docutils' in stylesheet_list:
stylesheet_list = [sheet for sheet in stylesheet_list
if sheet != 'docutils']
+ if self.settings.legacy_class_functions:
+ # docutils.sty is incompatible with legacy functions
+ self.fallback_stylesheet = False
+ else:
+ self.fallback_stylesheet = True
+ # require a minimal version:
+ self.fallbacks['docutils.sty'
+ ] = r'\usepackage{docutils}[2020/08/28]'
+
self.stylesheet = [self.stylesheet_call(path)
for path in stylesheet_list]
-
# PDF setup
if self.hyperlink_color in ('0', 'false', 'False', ''):
self.hyperref_options = ''
@@ -2999,8 +3004,21 @@
else:
if hasattr(PreambleCmds, 'secnumdepth'):
self.requirements['secnumdepth'] = PreambleCmds.secnumdepth
- section_name = self.d_class.section(self.section_level)
+ level = self.section_level
+ section_name = self.d_class.section(level)
self.out.append('\n\n')
+ if level > len(self.d_class.sections):
+ # section level not supported by LaTeX
+ if self.settings.legacy_class_functions:
+ self.fallbacks['title'] = PreambleCmds.title_legacy
+ section_name += '[section%s]' % roman.toRoman(level)
+ else:
+ if not self.fallback_stylesheet:
+ self.fallbacks['title'] = PreambleCmds.title
+ self.fallbacks['DUclass'] = PreambleCmds.duclass
+ self.out.append('\\begin{DUclass}{section%s}\n'
+ % roman.toRoman(level))
+
# System messages heading in red:
if ('system-messages' in node.parent['classes']):
self.requirements['color'] = PreambleCmds.color
@@ -3009,21 +3027,19 @@
section_name, section_title))
else:
self.out.append(r'\%s{' % section_name)
- if self.section_level > len(self.d_class.sections):
- # section level not supported by LaTeX
- if not self.fallback_stylesheet:
- self.fallbacks['title'] = PreambleCmds.title
- # self.out.append('\\phantomsection%\n ')
+
# label and ToC entry:
bookmark = ['']
# add sections with unsupported level to toc and pdfbookmarks?
- ## if self.section_level > len(self.d_class.sections):
+ ## if level > len(self.d_class.sections):
## section_title = self.encode(node.astext())
## bookmark.append(r'\addcontentsline{toc}{%s}{%s}' %
## (section_name, section_title))
bookmark += self.ids_to_labels(node.parent, set_anchor=False)
self.context.append('%\n '.join(bookmark) + '%\n}\n')
-
+ if (level > len(self.d_class.sections)
+ and not self.settings.legacy_class_functions):
+ self.context[-1] += '\\end{DUclass}\n'
# MAYBE postfix paragraph and subparagraph with \leavemode to
# ensure floats stay in the section and text starts on a new line.
Modified: trunk/docutils/docutils/writers/latex2e/docutils.sty
===================================================================
--- trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-09-04 16:58:24 UTC (rev 8557)
@@ -1,47 +1,15 @@
-% docutils.sty
-% ************
-% Style file for docutils LaTeX output
-% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+%% docutils.sty: macros for Docutils LaTeX output.
+%%
+%% Copyright © 2020 Günter Milde
+%% Released under the terms of the `2-Clause BSD license`, in short:
+%%
+%% Copying and distribution of this file, with or without modification,
+%% are permitted in any medium without royalty provided the copyright
+%% notice and this notice are preserved.
+%% This file is offered as-is, without any warranty.
+
+% .. include:: README
%
-% :Copyright: © 2020 Günter Milde
-% :Licence: Released under the terms of the `2-Clause BSD license`_, in short:
-%
-% Copying and distribution of this file, with or without modification,
-% are permitted in any medium without royalty provided the copyright
-% notice and this notice are preserved.
-% This file is offered as-is, without any warranty.
-%
-% .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
-%
-%
-% :Abstract:
-% Helper commands and element definitions for Docutils_ LaTeX output.
-%
-% :Changelog:
-% .. class:: borderless
-%
-% ====== ========== =========================================================
-% 0.1 2020-08-28 initial version
-% ====== ========== =========================================================
-%
-% Installation
-% ============
-%
-% Copy/Move/Link ``docutils.sty`` to a suitable place in the “TeX Directory
-% Structure” (TDS_) and run ``texhash``, or place it in the current working
-% directory (e.g. for testing).
-%
-% Usage
-% =====
-%
-% When generating LaTeX documents from reStructuredText sources,
-% specify this package with the `"stylesheet"`_ configuration_ option, e.g.
-% ``rst2latex --stylesheet=docutils``.
-% Alternatively, the Docutils `LaTeX writer` will extract required definitions
-% and insert them into the preamble of generated documents
-% (see `Docutils LaTeX Writer`_ for details).
-%
-%
% Implementation
% ==============
%
@@ -49,9 +17,8 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{docutils}
- [2020/08/28 v0.1 macros for Docutils LaTeX output]
+ [2020/08/28 macros for Docutils LaTeX output]
-
% Helpers
% -------
%
@@ -116,8 +83,7 @@
% Elements
% --------
%
-% Definitions for unknown or to-be-configured Docutils elements
-% and roles (inline elements).
+% Definitions for unknown or to-be-configured Docutils elements.
%
% admonition::
@@ -254,22 +220,3 @@
\hspace*{\fill}\hrulefill\hspace*{\fill}
\vskip 0.5\baselineskip
}
-
-% References
-% ==========
-%
-% .. [Docutils] https://docutils.sourceforge.io/
-%
-% .. _Docutils Document Tree:
-% https://docutils.sourceforge.io/docs/ref/doctree.html
-%
-% .. _Docutils LaTeX Writer:
-% https://docutils.sourceforge.io/docs/user/latex.html
-%
-% .. _Configuration:
-% https://docutils.sourceforge.io/docs/user/config.html
-%
-% .. _"stylesheet":
-% https://docutils.sourceforge.io/docs/user/config.html#stylesheet-latex-writers
-%
-% .. _TDS: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tds
Modified: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex 2020-09-04 16:58:24 UTC (rev 8557)
@@ -18,9 +18,9 @@
\usepackage{courier}
%%% User specified packages and stylesheets
-\usepackage{docutils}
%%% Fallback definitions for Docutils-specific commands
+\usepackage{docutils}[2020/08/28]
% character width in monospaced font
\newlength{\ttemwidth}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2020-09-04 16:58:24 UTC (rev 8557)
@@ -18,9 +18,9 @@
\usepackage{courier}
%%% User specified packages and stylesheets
-\usepackage{docutils}
%%% Fallback definitions for Docutils-specific commands
+\usepackage{docutils}[2020/08/28]
% character width in monospaced font
\newlength{\ttemwidth}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2020-09-04 16:58:24 UTC (rev 8557)
@@ -24,9 +24,9 @@
%%% User specified packages and stylesheets
-\usepackage{docutils}
%%% Fallback definitions for Docutils-specific commands
+\usepackage{docutils}[2020/08/28]
% character width in monospaced font
\newlength{\ttemwidth}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2020-09-04 16:58:24 UTC (rev 8557)
@@ -17,9 +17,9 @@
\usepackage{courier}
%%% User specified packages and stylesheets
-\usepackage{docutils}
%%% Fallback definitions for Docutils-specific commands
+\usepackage{docutils}[2020/08/28]
% character width in monospaced font
\newlength{\ttemwidth}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2020-09-04 16:58:24 UTC (rev 8557)
@@ -18,9 +18,9 @@
\usepackage{courier}
%%% User specified packages and stylesheets
-\usepackage{docutils}
%%% Fallback definitions for Docutils-specific commands
+\usepackage{docutils}[2020/08/28]
% character width in monospaced font
\newlength{\ttemwidth}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-09-04 16:55:24 UTC (rev 8556)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-09-04 16:58:24 UTC (rev 8557)
@@ -32,9 +32,9 @@
\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}
%%% User specified packages and stylesheets
-\usepackage{docutils}
%%% Fallback definitions for Docutils-specific commands
+\usepackage{docutils}[2020/08/28]
\newcounter{enumv}
\DUprovidelength{\pdfpxdimen}{1bp}
@@ -2725,9 +2725,11 @@
(depending on the document class)
-\DUtitle[sectionVI]{3.11.1.1.1.1 level 6%
+\begin{DUclass}{sectionVI}
+\DUtitle{3.11.1.1.1.1 level 6%
\label{level-6}%
}
+\end{DUclass}
an unsupported level.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-09-10 21:42:56
|
Revision: 8562
http://sourceforge.net/p/docutils/code/8562
Author: milde
Date: 2020-09-10 21:42:53 +0000 (Thu, 10 Sep 2020)
Log Message:
-----------
Prevent circular inclusion
Check "include" directives for circular dependencies and raise
a warning (similar to the one rised when file-insertion is disabled).
To prevent endless loops, we
rise a warning when a nested inclusion with the same "path",
"first-line", "end-line", "start-after", and "end-before"
options is detected.
In order to achieve this, the current source's parents are logged.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
Added Paths:
-----------
trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include15.txt
trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include16.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-09-08 11:57:41 UTC (rev 8561)
+++ trunk/docutils/HISTORY.txt 2020-09-10 21:42:53 UTC (rev 8562)
@@ -45,6 +45,10 @@
- Make the sidebar's "title" argument optional (feature request #69).
+* docutils/parsers/rst/directives/misc.py:
+
+ - Prevent infinite inclusion loops.
+
* docutils/utils/smartquotes.py
- Fix bug #383: Smart quotes around opening and separator characters.
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-09-08 11:57:41 UTC (rev 8561)
+++ trunk/docutils/docutils/nodes.py 2020-09-10 21:42:53 UTC (rev 8562)
@@ -1338,6 +1338,9 @@
self.transformer = docutils.transforms.Transformer(self)
"""Storage for transforms to be applied to this document."""
+ self.include_log = []
+ """The current source's parents (to detect inclusion loops)."""
+
self.decoration = None
"""Document's `decoration` node."""
@@ -1361,7 +1364,7 @@
return domroot
def set_id(self, node, msgnode=None, suggested_prefix=''):
- if node['ids']:
+ if node['ids']:
# register and check for duplicates
for id in node['ids']:
self.ids.setdefault(id, node)
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2020-09-08 11:57:41 UTC (rev 8561)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2020-09-10 21:42:53 UTC (rev 8562)
@@ -81,6 +81,8 @@
except IOError as error:
raise self.severe(u'Problems with "%s" directive path:\n%s.' %
(self.name, ErrorString(error)))
+
+ # Get to-be-included content
startline = self.options.get('start-line', None)
endline = self.options.get('end-line', None)
try:
@@ -142,6 +144,7 @@
else:
literal_block += nodes.Text(text)
return [literal_block]
+
if 'code' in self.options:
self.options['source'] = path
# Don't convert tabs to spaces, if `tab_width` is negative:
@@ -157,7 +160,30 @@
self.state,
self.state_machine)
return codeblock.run()
+
+ # include as rST source
+ #
+ # Prevent circular inclusion:
+ source = utils.relative_path(None, source)
+ clip_options = (startline, endline, before_text, after_text)
+ include_log = self.state.document.include_log
+ if not include_log: # new document:
+ # log entries: (<source>, <clip-options>, <insertion end index>)
+ include_log = [(source, (None,None,None,None), sys.maxsize/2)]
+ # cleanup: we may have passed the last inclusion(s):
+ include_log = [entry for entry in include_log
+ if entry[2] >= self.lineno]
+ if (path, clip_options) in [(pth, opt)
+ for (pth, opt, e) in include_log]:
+ raise self.warning('circular inclusion in "%s" directive: %s'
+ % (self.name, ' < '.join([path] + [pth for (pth, opt, e)
+ in include_log[::-1]])))
+ # include as input
self.state_machine.insert_input(include_lines, path)
+ # update include-log
+ include_log.append((path, clip_options, self.lineno))
+ self.state.document.include_log = [(pth, opt, e+len(include_lines)+2)
+ for (pth, opt, e) in include_log]
return []
Added: trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include15.txt
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include15.txt (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include15.txt 2020-09-10 21:42:53 UTC (rev 8562)
@@ -0,0 +1,3 @@
+File "include15.txt": example of rekursive inclusion.
+
+.. include:: include16.txt
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include15.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include16.txt
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include16.txt (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include16.txt 2020-09-10 21:42:53 UTC (rev 8562)
@@ -0,0 +1,8 @@
+File "include16.txt": example of rekursive inclusion.
+
+.. include:: include15.txt
+
+No loop when clipping before the "include" directive:
+
+.. include:: include15.txt
+ :end-before: .. include
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/includes/include16.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2020-09-08 11:57:41 UTC (rev 8561)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2020-09-10 21:42:53 UTC (rev 8562)
@@ -46,6 +46,8 @@
include12 = mydir('include12.txt')
include13 = mydir('include13.txt')
include14 = mydir('includes/include14.txt')
+include15 = mydir('includes/include15.txt')
+include16 = mydir('includes/include16.txt')
include_literal = mydir('include_literal.txt')
utf_16_file = mydir('utf-16.csv')
utf_16_error_str = ("UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe "
@@ -1025,6 +1027,59 @@
::
../sibling/include7.txt
""" % reldir(include6)],
+["""\
+Circular inclusion
+
+.. include:: %s
+""" % include15,
+"""\
+<document source="test data">
+ <paragraph>
+ Circular inclusion
+ <paragraph>
+ File "include15.txt": example of rekursive inclusion.
+ <paragraph>
+ File "include16.txt": example of rekursive inclusion.
+ <system_message level="2" line="3" source="%s" type="WARNING">
+ <paragraph>
+ circular inclusion in "include" directive: %s < %s < %s < test data
+ <literal_block xml:space="preserve">
+ .. include:: include15.txt
+ <paragraph>
+ No loop when clipping before the "include" directive:
+ <paragraph>
+ File "include15.txt": example of rekursive inclusion.
+""" % (reldir(include16), reldir(include15),
+ reldir(include16), reldir(include15))],
+["""\
+Circular inclusion with clipping.
+
+.. include:: %s
+ :start-line: 2
+""" % include16,
+"""\
+<document source="test data">
+ <paragraph>
+ Circular inclusion with clipping.
+ <paragraph>
+ File "include15.txt": example of rekursive inclusion.
+ <paragraph>
+ File "include16.txt": example of rekursive inclusion.
+ <system_message level="2" line="3" source="%s" type="WARNING">
+ <paragraph>
+ circular inclusion in "include" directive: %s < %s < %s < %s < test data
+ <literal_block xml:space="preserve">
+ .. include:: include15.txt
+ <paragraph>
+ No loop when clipping before the "include" directive:
+ <paragraph>
+ File "include15.txt": example of rekursive inclusion.
+ <paragraph>
+ No loop when clipping before the "include" directive:
+ <paragraph>
+ File "include15.txt": example of rekursive inclusion.
+""" % (reldir(include16), reldir(include15), reldir(include16),
+ reldir(include15), reldir(include16))],
]
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-09-14 10:26:06
|
Revision: 8565
http://sourceforge.net/p/docutils/code/8565
Author: milde
Date: 2020-09-14 10:26:03 +0000 (Mon, 14 Sep 2020)
Log Message:
-----------
Limit length of input lines and substitution expansion.
Mitigate the danger of DoS attacs using
specially crafted rST input (cf. bug #381).
The default value of 10 000 characters should suffice for
legitimate use cases (e.g. long paragraphs in auto-wrapping editors
or extensive creative use of substitutions).
Applications processing untrusted rST might wish to lower this
limitation (together with other safety measures described in
docs/howto/security.txt).
Unsupervised processing of untrusted rST input should always
be safeguarded with limits on processing time and memory use.
Modified Paths:
--------------
trunk/docutils/docs/howto/security.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/parsers/rst/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/references.py
Added Paths:
-----------
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py
trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py
Modified: trunk/docutils/docs/howto/security.txt
===================================================================
--- trunk/docutils/docs/howto/security.txt 2020-09-13 17:29:38 UTC (rev 8564)
+++ trunk/docutils/docs/howto/security.txt 2020-09-14 10:26:03 UTC (rev 8565)
@@ -76,7 +76,11 @@
It is recommended to enforce limits for the computation time and resource
utilization of the Docutils process when processing untrusted input.
+In addition, the "line_length_limit_" can be adapted.
+.. _line_length_limit: ../user/config.html#line-length-limit
+
+
Securing Docutils
=================
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2020-09-13 17:29:38 UTC (rev 8564)
+++ trunk/docutils/docs/user/config.txt 2020-09-14 10:26:03 UTC (rev 8565)
@@ -639,6 +639,21 @@
.. _include: ../ref/rst/directives.html#include
.. _raw: ../ref/rst/directives.html#raw
+line_length_limit
+~~~~~~~~~~~~~~~~~
+
+Maximal number of characters in an input line or `substitution`_
+definition. To prevent extraordinary high processing times or memory
+usage for certain input constructs, a "warning" system message is
+inserted instead.
+
+Default: 10 000.
+Option: ``--line-length-limit``
+
+New in Docutils 0.17.
+
+.. _substitution: ../ref/rst/directives.html#substitution
+
pep_references
~~~~~~~~~~~~~~
Modified: trunk/docutils/docutils/parsers/rst/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/__init__.py 2020-09-13 17:29:38 UTC (rev 8564)
+++ trunk/docutils/docutils/parsers/rst/__init__.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -133,6 +133,10 @@
('Enable the "raw" directive. Enabled by default.',
['--raw-enabled'],
{'action': 'store_true'}),
+ ('Maximal number of characters in an input line. Default 10 000.',
+ ['--line-length-limit'],
+ {'metavar': '<length>', 'type': 'int', 'default': 10000,
+ 'validator': frontend.validate_nonnegative_int}),
('Token name set for parsing code with Pygments: one of '
'"long", "short", or "none (no parsing)". Default is "long".',
['--syntax-highlight'],
@@ -188,7 +192,14 @@
inputlines = docutils.statemachine.string2lines(
inputstring, tab_width=document.settings.tab_width,
convert_whitespace=True)
- self.statemachine.run(inputlines, document, inliner=self.inliner)
+ for i, line in enumerate(inputlines):
+ if len(line) > self.document.settings.line_length_limit:
+ error = self.document.reporter.error(
+ 'Line %d exceeds the line-length-limit.'%(i+1))
+ self.document.append(error)
+ break
+ else:
+ self.statemachine.run(inputlines, document, inliner=self.inliner)
# restore the "default" default role after parsing a document
if '' in roles._roles:
del roles._roles['']
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2020-09-13 17:29:38 UTC (rev 8564)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -115,8 +115,13 @@
include_lines = statemachine.string2lines(rawtext, tab_width,
convert_whitespace=True)
+ for i, line in enumerate(include_lines):
+ if len(line) > self.state.document.settings.line_length_limit:
+ raise self.warning('"%s": line %d exceeds the'
+ ' line-length-limit.' % (path, i+1))
+
if 'literal' in self.options:
- # Don't convert tabs to spaces, if `tab_width` is positive.
+ # Don't convert tabs to spaces, if `tab_width` is negative.
if tab_width >= 0:
text = rawtext.expandtabs(tab_width)
else:
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2020-09-13 17:29:38 UTC (rev 8564)
+++ trunk/docutils/docutils/statemachine.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -1505,12 +1505,12 @@
- `astring`: a multi-line string.
- `tab_width`: the number of columns between tab stops.
- `convert_whitespace`: convert form feeds and vertical tabs to spaces?
+ - `whitespace`: pattern object with the to-be-converted
+ whitespace characters (default [\\v\\f]).
"""
if convert_whitespace:
astring = whitespace.sub(' ', astring)
lines = [s.expandtabs(tab_width).rstrip() for s in astring.splitlines()]
- # TODO: test for too long lines (fixes bug #381):
- # for line in lines:
return lines
def _exception_data():
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2020-09-13 17:29:38 UTC (rev 8564)
+++ trunk/docutils/docutils/transforms/references.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -663,11 +663,13 @@
def apply(self):
defs = self.document.substitution_defs
normed = self.document.substitution_names
- subreflist = list(self.document.traverse(nodes.substitution_reference))
nested = {}
+ line_length_limit = getattr(self.document.settings,
+ "line_length_limit", 10000)
subreflist = list(self.document.traverse(nodes.substitution_reference))
for ref in subreflist:
+ msg = ''
refname = ref['refname']
if refname in defs:
key = refname
@@ -678,6 +680,13 @@
msg = self.document.reporter.error(
'Undefined substitution referenced: "%s".'
% refname, base_node=ref)
+ else:
+ subdef = defs[key]
+ if len(subdef.astext()) > line_length_limit:
+ msg = self.document.reporter.error(
+ 'Substitution definition "%s" exceeds the'
+ ' line-length-limit.' % (key))
+ if msg:
msgid = self.document.set_id(msg)
prb = nodes.problematic(
ref.rawsource, ref.rawsource, refid=msgid)
@@ -686,7 +695,6 @@
ref.replace_self(prb)
continue
- subdef = defs[key]
parent = ref.parent
index = parent.index(ref)
if ('ltrim' in subdef.attributes
Added: trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -0,0 +1,76 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# $Id$
+# Author: David Goodger <go...@py...>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for inline markup in docutils/parsers/rst/states.py.
+Interpreted text tests are in a separate module, test_interpreted.py.
+"""
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_parsers import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite(
+ suite_settings={'line_length_limit': 80})
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['default'] = [
+["""\
+within the limit
+%s
+""" % ("x"*80),
+"""\
+<document source="test data">
+ <paragraph>
+ within the limit
+ %s
+""" % ("x"*80)],
+["""\
+above the limit
+%s
+""" % ("x"*81),
+"""\
+<document source="test data">
+ <system_message level="3" source="test data" type="ERROR">
+ <paragraph>
+ Line 2 exceeds the line-length-limit.
+"""],
+["""\
+Include Test
+============
+
+.. include:: docutils.conf
+ :literal:
+
+A paragraph.
+""",
+"""\
+<document source="test data">
+ <section ids="include-test" names="include\\ test">
+ <title>
+ Include Test
+ <system_message level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ "docutils.conf": line 5 exceeds the line-length-limit.
+ <literal_block xml:space="preserve">
+ .. include:: docutils.conf
+ :literal:
+ <paragraph>
+ A paragraph.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -0,0 +1,52 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# $Id$
+# Author: David Goodger <go...@py...>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for inline markup in docutils/parsers/rst/states.py.
+Interpreted text tests are in a separate module, test_interpreted.py.
+"""
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_parsers import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['default'] = [
+["""\
+within the limit
+%s
+""" % ("x"*10000),
+"""\
+<document source="test data">
+ <paragraph>
+ within the limit
+ %s
+""" % ("x"*10000)],
+["""\
+above the limit
+%s
+""" % ("x"*10001),
+"""\
+<document source="test data">
+ <system_message level="3" source="test data" type="ERROR">
+ <paragraph>
+ Line 2 exceeds the line-length-limit.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py
===================================================================
--- trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py (rev 0)
+++ trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py 2020-09-14 10:26:03 UTC (rev 8565)
@@ -0,0 +1,71 @@
+#! /usr/bin/env python
+
+# $Id$
+# Author: David Goodger <go...@py...>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.references.Substitutions.
+"""
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_transforms import DocutilsTestSupport
+from docutils.transforms.references import Substitutions
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser,
+ suite_settings={'line_length_limit': 80})
+ s.generateTests(totest)
+ return s
+
+# pseudoxml representation of the substitution definition content:
+a = ' lol'
+b = ' 10^1 \n' + '\n \n'.join(10 * [a])
+c = ' 10^2 \n' + '\n \n'.join(10 * [b])
+
+totest = {}
+
+totest['substitutions'] = ((Substitutions,), [
+["""\
+The billion laughs attack for ReStructuredText:
+
+.. |a| replace:: lol
+.. |b| replace:: 10^1 |a| |a| |a| |a| |a| |a| |a| |a| |a| |a|
+.. |c| replace:: 10^2 |b| |b| |b| |b| |b| |b| |b| |b| |b| |b|
+.. ...
+
+|a| |c| continuation text
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ The billion laughs attack for ReStructuredText:
+ <substitution_definition names="a">
+ lol
+ <substitution_definition names="b">
+{}
+ <substitution_definition names="c">
+{}
+ <comment xml:space="preserve">
+ ...
+ <paragraph>
+ lol
+ \n\
+ <problematic ids="id2" refid="id1">
+ |c|
+ continuation text
+ <system_message backrefs="id2" ids="id1" level="3" line="9" source="test data" type="ERROR">
+ <paragraph>
+ Substitution definition "c" exceeds the line-length-limit.
+""".format(b, c)],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-10-27 22:42:38
|
Revision: 8569
http://sourceforge.net/p/docutils/code/8569
Author: milde
Date: 2020-10-27 22:42:35 +0000 (Tue, 27 Oct 2020)
Log Message:
-----------
Apply patch #173 by John Thorvald Wodder II.
Make *TeX writers convert nonstandard table classes to DUclass environments.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-10-27 21:51:30 UTC (rev 8568)
+++ trunk/docutils/HISTORY.txt 2020-10-27 22:42:35 UTC (rev 8569)
@@ -58,10 +58,10 @@
- Use the new semantic tags <main>, <section>, <header>,
<footer>, <aside>, <figure>, and <figcaption>.
See ``minimal.css`` and ``plain.css`` for styling rule examples.
-
+
Change the `initial_header_level` setting default to "2", as browsers
use the `same style for <h1> and <h2> when nested in a <section>`__.
-
+
__ https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
@@ -73,7 +73,7 @@
- Wrap block-level image elements in <p> (except for figures).
Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
-
+
- Fix bug #398: properly close link tag to "schema.dcterms".
* docutils/writers/latex2e/__init__.py:
@@ -81,7 +81,7 @@
- Use LaTeX environments for admonitions and "class wrappers" for styling
admonitions and titles if the new configuration setting
`legacy_class_functions`_ is False.
-
+
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
@@ -89,10 +89,10 @@
`styling command`__ prefix ``\docutilsrole``.
__ docs/user/latex.html#custom-interpreted-text-roles
-
+
- Support the `memoir` LaTeX document class.
- Fixes #390, #391, and #392.
-
+ Fixes #390, #391, and #392.
+
- The special value "auto" for the `graphicx_option`_ setting
is no longer supported (it never worked for xetex/luatex).
@@ -101,10 +101,12 @@
- Most helper commands and element definitions are now defined in the
LaTeX package `docutils.sty`_ and only inserted in the document
preamble if the `stylesheet`__ setting does not list "docutils".
-
+
.. _docutils.sty: https://ctan.org/pkg/docutils
__ docs/user/config.html#stylesheet-latex-writers
+ - Apply patch #173 "Make *TeX writers convert nonstandard table
+ classes to DUclass environments" by John Thorvald Wodder II.
* docutils/writers/manpage.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-10-27 21:51:30 UTC (rev 8568)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-10-27 22:42:35 UTC (rev 8569)
@@ -1539,6 +1539,8 @@
if language:
self.babel.otherlanguages[language] = True
self.out.append('\\begin{selectlanguage}{%s}\n' % language)
+ elif isinstance(node, nodes.table) and cls in Writer.table_style_values:
+ pass
else:
if not self.fallback_stylesheet:
self.fallbacks['DUclass'] = PreambleCmds.duclass
@@ -1551,6 +1553,8 @@
language = self.babel.language_name(cls[9:])
if language:
self.out.append('\\end{selectlanguage}\n')
+ elif isinstance(node, nodes.table) and cls in Writer.table_style_values:
+ pass
else:
if not self.fallback_stylesheet:
self.fallbacks['DUclass'] = PreambleCmds.duclass
@@ -2871,6 +2875,7 @@
self.depart_admonition(node)
def visit_table(self, node):
+ self.duclass_open(node)
self.requirements['table'] = PreambleCmds.table
if self.active_table.is_open():
self.table_stack.append(self.active_table)
@@ -2900,7 +2905,9 @@
width = self.to_latex_length(node.attributes['width'])
except KeyError:
width = r'\linewidth'
- self.out.append('\n' + self.active_table.get_opening(width))
+ if isinstance(node.parent, nodes.compound):
+ self.out.append('\n')
+ self.out.append(self.active_table.get_opening(width))
self.out += content
self.out.append(self.active_table.get_closing() + '\n')
self.active_table.close()
@@ -2910,6 +2917,7 @@
# other places (beginning, caption) result in LaTeX errors.
if node.get('ids'):
self.out += self.ids_to_labels(node, set_anchor=False) + ['\n']
+ self.duclass_close(node)
def visit_target(self, node):
# Skip indirect targets:
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2020-10-27 21:51:30 UTC (rev 8568)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2020-10-27 22:42:35 UTC (rev 8569)
@@ -1675,6 +1675,7 @@
Here's a list table exercising all features:
+\begin{DUclass}{test}
\setlength{\DUtablewidth}{40em}
\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
\caption{list table with integral header}\\
@@ -1728,6 +1729,7 @@
\\
\hline
\end{longtable}
+\end{DUclass}
\begin{longtable}[c]{|l|l|}
\caption{center aligned list table}\\
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-10-27 21:51:30 UTC (rev 8568)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-10-27 22:42:35 UTC (rev 8569)
@@ -1679,6 +1679,7 @@
Here’s a list table exercising all features:
+\begin{DUclass}{test}
\setlength{\DUtablewidth}{40em}
\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
\caption{list table with integral header}\\
@@ -1732,6 +1733,7 @@
\\
\hline
\end{longtable}
+\end{DUclass}
\begin{longtable}[c]{|l|l|}
\caption{center aligned list table}\\
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-10-27 21:51:30 UTC (rev 8568)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-10-27 22:42:35 UTC (rev 8569)
@@ -1565,6 +1565,7 @@
Here’s a list table exercising all features:
+\begin{DUclass}{test}
\setlength{\DUtablewidth}{40em}
\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
\caption{list table with integral header}\\
@@ -1618,6 +1619,7 @@
\\
\hline
\end{longtable}
+\end{DUclass}
\begin{longtable}[c]{|l|l|}
\caption{center aligned list table}\\
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2020-10-27 21:51:30 UTC (rev 8568)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2020-10-27 22:42:35 UTC (rev 8569)
@@ -836,6 +836,58 @@
"""],
]
+totest['table_nonstandard_class'] = [
+["""\
+.. table::
+ :class: my-class
+
+ +-----+-----+
+ | 1 | 2 |
+ +-----+-----+
+ | 3 | 4 |
+ +-----+-----+
+""",
+head_template.substitute(
+ dict(
+ parts,
+ requirements = parts['requirements'] + parts['longtable'],
+ fallbacks = r"""
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {% "#1" does not work in end-part of environment.
+ \def\DocutilsClassFunctionName{DUCLASS#1}
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+"""
+ )
+) + r"""
+\begin{DUclass}{my-class}
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+
+3
+ &
+4
+ \\
+\hline
+\end{longtable*}
+\end{DUclass}
+
+\end{document}
+"""],
+]
+
# The "[" needs to be protected (otherwise it will be seen as an
# option to "\\", "\item", etc. ).
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-10-28 08:46:23
|
Revision: 8571
http://sourceforge.net/p/docutils/code/8571
Author: milde
Date: 2020-10-28 08:46:19 +0000 (Wed, 28 Oct 2020)
Log Message:
-----------
Apply patch #174 Lowercase new role names on registration
and document that role names are case insensitive.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/HISTORY.txt 2020-10-28 08:46:19 UTC (rev 8571)
@@ -41,14 +41,18 @@
- Apply version of patch #167: Let document.set_id() register all
existing IDs (thanks to Takeshi KOMIYA).
-* docutils/parsers/rst/directives/body.py:
+* docutils/parsers/rst/directives/body.py
- Make the sidebar's "title" argument optional (feature request #69).
-* docutils/parsers/rst/directives/misc.py:
+* docutils/parsers/rst/directives/misc.py
- Prevent infinite inclusion loops.
+* docutils/parsers/rst/roles.py
+
+ - Apply patch #174 Lowercase new role names on registration
+
* docutils/utils/smartquotes.py
- Fix bug #383: Smart quotes around opening and separator characters.
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/docs/ref/rst/directives.txt 2020-10-28 08:46:19 UTC (rev 8571)
@@ -1775,7 +1775,7 @@
:Directive Type: "role"
:Doctree Element: None; affects subsequent parsing.
-:Directive Arguments: Two; one required (new role name), one optional
+:Directive Arguments: Two; one required (new `role name`_), one optional
(base role name, in parentheses).
:Directive Options: Possible (depends on base role).
:Directive Content: depends on base role.
@@ -1801,6 +1801,12 @@
The role must be declared in a document before it can be used.
+.. _role name:
+
+Role names are case insensitive and must conform to the rules of
+simple `reference names`_ (but do not share a namespace with
+hyperlinks, footnotes, and citations).
+
The new role may be based on an existing role, specified as a second
argument in parentheses (whitespace optional)::
@@ -1966,7 +1972,8 @@
New in Docutils 0.8.
-.. _reference name: restructuredtext.html#reference-names
+.. _reference name:
+.. _reference names: restructuredtext.html#reference-names
.. _hyperlink target: restructuredtext.html#hyperlink-targets
.. _hyperlink references: restructuredtext.html#hyperlink-references
.. _class names: ../doctree.html#classnames-type
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2020-10-28 08:46:19 UTC (rev 8571)
@@ -372,6 +372,7 @@
r"""This is a raw docstring. Backslashes (\) are not touched."""
+.. _reference name:
Reference Names
===============
@@ -2669,7 +2670,8 @@
markup constructs. To emphasis_, `strong emphasis`_, `inline
literals`_, and `hyperlink references`_, we can add "title reference",
"index entry", "acronym", "class", "red", "blinking" or anything else
-we want. Only pre-determined roles are recognized; unknown roles will
+we want (as long as it is a simple `reference name`_).
+Only pre-determined roles are recognized; unknown roles will
generate errors. A core set of standard roles is implemented in the
reference parser; see `reStructuredText Interpreted Text Roles`_ for
individual descriptions. The role_ directive can be used to define
@@ -2888,7 +2890,7 @@
- a single "#" (denoting `auto-numbered footnotes`_),
-- a "#" followed by a simple reference name (an `autonumber label`_),
+- a "#" followed by a simple `reference name`_ (an `autonumber label`_),
or
- a single "*" (denoting `auto-symbol footnotes`_).
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2020-10-28 08:46:19 UTC (rev 8571)
@@ -152,7 +152,7 @@
- `role_fn`: The role function. See the module docstring.
"""
set_implicit_options(role_fn)
- _role_registry[name] = role_fn
+ _role_registry[name.lower()] = role_fn
def register_local_role(name, role_fn):
"""
@@ -163,7 +163,7 @@
- `role_fn`: The role function. See the module docstring.
"""
set_implicit_options(role_fn)
- _roles[name] = role_fn
+ _roles[name.lower()] = role_fn
def set_implicit_options(role_fn):
"""
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py 2020-10-28 08:46:19 UTC (rev 8571)
@@ -212,6 +212,19 @@
and empty
<inline classes="special">
"""],
+["""\
+.. role:: CaSiNg
+
+Role names are :cAsInG:`case-insensitive`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Role names are \n\
+ <inline classes="casing">
+ case-insensitive
+ .
+"""],
]
totest['raw_role'] = [
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|