summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2023-01-16 09:19:08 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2023-01-16 09:19:08 +0000
commitafa6bbb9e9499ab404bce4a64090e327101f3363 (patch)
treec6268e8949c6f21633368c0316b37261a29c1413
parent05913a774ed723da7b177bbbf47544e7fd40e515 (diff)
downloaddocutils-afa6bbb9e9499ab404bce4a64090e327101f3363.tar.gz
Always use POSIX path in macros loading stylesheets.
Thanks to Alan G. Isaac for reporting the bug and proposing a patch. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9316 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--docutils/HISTORY.txt3
-rw-r--r--docutils/docs/user/config.txt4
-rw-r--r--docutils/docutils/writers/latex2e/__init__.py15
3 files changed, 11 insertions, 11 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt
index 24b9d600c..fdb6cda15 100644
--- a/docutils/HISTORY.txt
+++ b/docutils/HISTORY.txt
@@ -56,7 +56,7 @@ Changes Since 0.19
- New utility function `xml_declaration()`.
- `DependencyList.add()` accepts `pathlib.Path` instances.
- `find_file_in_dirs()` now returns a POSIX path also on Windows;
- `get_stylesheet_list()` no longer converts "\" to "/".
+ `get_stylesheet_list()` no longer converts ``\`` to ``/``.
* docutils/utils/math/latex2mathml.py
@@ -86,6 +86,7 @@ Changes Since 0.19
- Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
LaTeX sources. UTF-8 is the default encoding for LaTeX2e since 2018.
- Fix handling of the "use_bibtex" setting.
+ - Use POSIX paths in stylesheet loading macros [report Alan G. Isaac].
* docutils/writers/latex2e/titlepage.tex
diff --git a/docutils/docs/user/config.txt b/docutils/docs/user/config.txt
index f94c4cb5f..5fb6b3011 100644
--- a/docutils/docs/user/config.txt
+++ b/docutils/docs/user/config.txt
@@ -1760,6 +1760,8 @@ stylesheet
~~~~~~~~~~
A comma-separated list_ of style files.
+Used without path adaption (cf. `stylesheet_path [latex writers]`_).
+Under Windows, path separators are normalized to forward slashes (``/``).
See also `stylesheet [html writers]`_.
Overrides also stylesheet_path__. [#override]_
@@ -1811,7 +1813,7 @@ output file path. Run ``latex`` from the directory containing
the output file.
See also `stylesheet_path [html writers]`_.
-The stylesheet__ option is preferred for files in the `TeX input path`_.
+For files in the `TeX input path`_, the stylesheet__ option is recommended.
Also overrides stylesheet__. [#override]_
diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py
index 120ab2bbc..d46272a19 100644
--- a/docutils/docutils/writers/latex2e/__init__.py
+++ b/docutils/docutils/writers/latex2e/__init__.py
@@ -256,8 +256,8 @@ class Writer(writers.Writer):
writers.Writer.__init__(self)
self.translator_class = LaTeXTranslator
- # Override parent method to add latex-specific transforms
def get_transforms(self):
+ # Override parent method to add latex-specific transforms
return super().get_transforms() + [
# Convert specific admonitions to generic one
writer_aux.Admonitions,
@@ -1327,8 +1327,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
stylesheet_list = utils.get_stylesheet_list(settings)
self.fallback_stylesheet = 'docutils' in stylesheet_list
if self.fallback_stylesheet:
- stylesheet_list = [sheet for sheet in stylesheet_list
- if sheet != 'docutils']
+ stylesheet_list.remove('docutils')
if settings.legacy_class_functions:
# docutils.sty is incompatible with legacy functions
self.fallback_stylesheet = False
@@ -1403,12 +1402,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.document.reporter.error(msg)
return '% ' + msg.replace('\n', '\n% ')
else:
- self.settings.record_dependencies.add(path)
+ self.settings.record_dependencies.add(path.as_posix())
if is_package:
# allow '@' in macro names:
- content = (r'\makeatletter'
- f'\n{content}\n'
- r'\makeatother')
+ content = (f'\\makeatletter\n{content}\n\\makeatother')
return (f'% embedded stylesheet: {path.as_posix()}\n'
f'{content}')
# Link to style file:
@@ -1419,8 +1416,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
cmd = r'\input{%s}'
if self.settings.stylesheet_path:
# adapt path relative to output (cf. config.html#stylesheet-path)
- path = utils.relative_path(self.settings._destination, path)
- return cmd % path
+ return cmd % utils.relative_path(self.settings._destination, path)
+ return cmd % path.as_posix()
def to_latex_encoding(self, docutils_encoding):
"""Translate docutils encoding name into LaTeX's.