|
From: <mi...@us...> - 2024-11-25 20:45:30
|
Revision: 9991
http://sourceforge.net/p/docutils/code/9991
Author: milde
Date: 2024-11-25 20:45:27 +0000 (Mon, 25 Nov 2024)
Log Message:
-----------
Change default of "root_prefix" setting to empty string.
Part of a patch by Adam Turner
(cf. https://sourceforge.net/p/docutils/bugs/493/#55f0 ff.).
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docs/user/config.rst
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/data/help/docutils.rst
trunk/docutils/test/data/help/rst2html.rst
trunk/docutils/test/data/help/rst2latex.rst
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/HISTORY.rst 2024-11-25 20:45:27 UTC (rev 9991)
@@ -37,9 +37,9 @@
* docutils/core.py
- Removed `Publisher.setup_option_parser()` (internal, obsolete).
- - Allow a string value (component name or alias) in the
- "reader", "parser", and "writer" arguments of `Publisher.__init__()`
- and the `publish_*()` convenience functions.
+ - Allow a string value (component name or alias) in the "reader",
+ "parser", and "writer" arguments of `Publisher.__init__()` and
+ the `publish_*()` convenience functions.
* docutils/frontend.py
@@ -46,6 +46,8 @@
- Drop short options ``-i`` and ``-o`` for ``--input-encoding``
and ``--output-encoding``.
- Change the default input encoding from ``None`` (auto-detect) to "utf-8".
+ - Change the default value of the _root_prefix setting to the empty string
+ (no change to the behaviour).
* docutils/io.py
@@ -194,8 +196,8 @@
- Add command line option ``--macro-references``/``--text-references``
to enable/disable usage of *man* macros .UR/.UE.
- Do not output .UR/.UE macros without refuri in node.
- - Use .MT/.ME macros for mailto.uris.
- - If macro references is active output refuri always.
+ - Use .MT/.ME macros for mailto.uris.
+ - If macro references is active output refuri always.
* docutils/writers/null.py
@@ -768,6 +770,7 @@
=========================
* docutils/frontend.py
+
- Mark as provisional (will switch from using `optparse` to `argparse`).
- Remove hack for the now obsolete "mod_python" Apache module.
- New function `get_default_settings()` as a replacement for the
Modified: trunk/docutils/docs/user/config.rst
===================================================================
--- trunk/docutils/docs/user/config.rst 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/docs/user/config.rst 2024-11-25 20:45:27 UTC (rev 9991)
@@ -589,8 +589,8 @@
Also applied when a writer converts an image URI__ to a local filesystem
path in order to determine the image size or embed the image in the output.
-:Default: "/" (keep paths unchanged).
-:Option: ``--root-prefix``
+:Default: "".
+:Option: ``--root-prefix``.
New in Docutils 0.21.
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/docutils/frontend.py 2024-11-25 20:45:27 UTC (rev 9991)
@@ -706,9 +706,9 @@
['--no-datestamp'], {'action': 'store_const', 'const': None,
'dest': 'datestamp'}),
('Base directory for absolute paths when reading '
- 'from the local filesystem. Default "/".',
+ 'from the local filesystem. Default "".',
['--root-prefix'],
- {'default': '/', 'metavar': '<path>'}),
+ {'default': '', 'metavar': '<path>'}),
('Include a "View document source" link.',
['--source-link', '-s'], {'action': 'store_true',
'validator': validate_boolean}),
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2024-11-25 20:45:27 UTC (rev 9991)
@@ -25,12 +25,12 @@
from docutils.nodes import Node, StrPath
-def adapt_path(path: str, source='', root_prefix='/') -> str:
+def adapt_path(path: str, source='', root_prefix='') -> str:
# Adapt path to files to include or embed.
# `root_prefix` is prepended to absolute paths (cf. root_prefix setting),
# `source` is the `current_source` of the including directive (which may
# be a file included by the main document).
- if path.startswith('/'):
+ if root_prefix and path.startswith('/'):
base = Path(root_prefix)
path = path[1:]
else:
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/docutils/writers/_html_base.py 2024-11-25 20:45:27 UTC (rev 9991)
@@ -650,9 +650,9 @@
if uri_parts.scheme not in ('', 'file'):
raise ValueError('Can only read local images.')
imagepath = urllib.parse.unquote(uri_parts.path)
- if imagepath.startswith('/'): # cf. config.html#root-prefix
+ if self.settings.root_prefix and imagepath.startswith('/'):
root_prefix = Path(self.settings.root_prefix)
- imagepath = (root_prefix/imagepath[1:]).as_posix()
+ imagepath = (root_prefix/imagepath.removeprefix('/')).as_posix()
elif not os.path.isabs(imagepath): # path may be absolute Windows path
destdir = os.path.abspath(os.path.dirname(destination))
imagepath = utils.relative_path(None,
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2024-11-25 20:45:27 UTC (rev 9991)
@@ -2131,7 +2131,7 @@
uri_parts = urllib.parse.urlparse(source)
if uri_parts.scheme in ('', 'file'):
source = urllib.parse.unquote(uri_parts.path)
- if source.startswith('/'):
+ if self.settings.root_prefix and source.startswith('/'):
root_prefix = Path(self.settings.root_prefix)
source = (root_prefix/source[1:]).as_posix()
else:
Modified: trunk/docutils/test/data/help/docutils.rst
===================================================================
--- trunk/docutils/test/data/help/docutils.rst 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/test/data/help/docutils.rst 2024-11-25 20:45:27 UTC (rev 9991)
@@ -20,7 +20,7 @@
--time, -t Include the time & date (UTC).
--no-datestamp Do not include a datestamp of any kind.
--root-prefix=<path> Base directory for absolute paths when reading from
- the local filesystem. Default "/".
+ the local filesystem. Default "".
--source-link, -s Include a "View document source" link.
--source-url=<URL> Use <URL> for a source link; implies --source-link.
--no-source-link Do not include a "View document source" link.
Modified: trunk/docutils/test/data/help/rst2html.rst
===================================================================
--- trunk/docutils/test/data/help/rst2html.rst 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/test/data/help/rst2html.rst 2024-11-25 20:45:27 UTC (rev 9991)
@@ -21,7 +21,7 @@
--time, -t Include the time & date (UTC).
--no-datestamp Do not include a datestamp of any kind.
--root-prefix=<path> Base directory for absolute paths when reading from
- the local filesystem. Default "/".
+ the local filesystem. Default "".
--source-link, -s Include a "View document source" link.
--source-url=<URL> Use <URL> for a source link; implies --source-link.
--no-source-link Do not include a "View document source" link.
Modified: trunk/docutils/test/data/help/rst2latex.rst
===================================================================
--- trunk/docutils/test/data/help/rst2latex.rst 2024-11-25 13:48:58 UTC (rev 9990)
+++ trunk/docutils/test/data/help/rst2latex.rst 2024-11-25 20:45:27 UTC (rev 9991)
@@ -21,7 +21,7 @@
--time, -t Include the time & date (UTC).
--no-datestamp Do not include a datestamp of any kind.
--root-prefix=<path> Base directory for absolute paths when reading from
- the local filesystem. Default "/".
+ the local filesystem. Default "".
--source-link, -s Include a "View document source" link.
--source-url=<URL> Use <URL> for a source link; implies --source-link.
--no-source-link Do not include a "View document source" link.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|