SF.net SVN: docutils:[9937 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9937
          http://sourceforge.net/p/docutils/code/9937
Author:   milde
Date:     2024-09-23 22:36:38 +0000 (Mon, 23 Sep 2024)
Log Message:
-----------
LaTeX writer: stop requiring "ifthen.sty", fix Babel warning.

Replace use of ``\ifthenelse`` from "ifthen.sty" with the
eTeX primitive ``\ifdefined``.

Mark the main language when loading "babel" to prevent a warning
about another language being processed last. This happens when there
is more than one language in the document as we put the main language
also in the document options (for other packages to see).

Modified Paths:
--------------
    trunk/docutils/HISTORY.rst
    trunk/docutils/RELEASE-NOTES.rst
    trunk/docutils/docs/user/latex.rst
    trunk/docutils/docutils/writers/latex2e/__init__.py
    trunk/docutils/docutils/writers/latex2e/docutils.sty
    trunk/docutils/test/functional/expected/cyrillic.tex
    trunk/docutils/test/functional/expected/latex_babel.tex
    trunk/docutils/test/functional/expected/latex_cornercases.tex
    trunk/docutils/test/functional/expected/latex_docinfo.tex
    trunk/docutils/test/functional/expected/latex_leavevmode.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/test_writers/test_latex2e.py
    trunk/docutils/test/test_writers/test_xetex_misc.py

Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/HISTORY.rst	2024-09-23 22:36:38 UTC (rev 9937)
@@ -162,6 +162,9 @@
     move XeTeX-specific code to the "xetex" writer.
   - Don't wrap references with custom reference-label_ in
     a ``\hyperref`` command.
+  - Stop requiring "ifthen.sty". Replace use of ``\ifthenelse{\isundefined...``
+    with the eTeX primitive ``\ifdefined``.
+  - Mark the main language when loading "babel".
   - Provide an "unknown_references_resolver" (cf. `docutils/TransformSpec`)
     for citation references resolved with BibTeX (cf. `use_bibtex`_ setting).
 

Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/RELEASE-NOTES.rst	2024-09-23 22:36:38 UTC (rev 9937)
@@ -198,6 +198,9 @@
      command. The "hyperref" package generates hyperlinks for labels by
      default, so there is no change in the PDF (except for "ref*").
 
+     Stop requiring "ifthen.sty". Replace use of
+     ``\ifthenelse{\isundefined...`` with the eTeX primitive ``\ifdefined``.
+
      .. _reference-label: docs/user/config.html#reference-label
 
   HTML5:

Modified: trunk/docutils/docs/user/latex.rst
===================================================================
--- trunk/docutils/docs/user/latex.rst	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/docs/user/latex.rst	2024-09-23 22:36:38 UTC (rev 9937)
@@ -379,7 +379,7 @@
 Some customizations require commands at places other than the insertion
 point of stylesheets or depend on the deletion/replacement of parts of the
 document. This can be done via a custom template. See the `publisher
-documentation`_ for a description of the document parts available in a
+documentation`_ for a description of the `document parts`_ available in a
 template file.
 
 Option:
@@ -396,8 +396,11 @@
     --template=titlepage.tex
 
 .. _publisher documentation: ../api/publisher.html
+.. _document parts:
+    ../api/publisher.html#parts-provided-by-the-xe-latex-writers
 .. _template: config.html#template-latex-writers
 
+
 Raw LaTeX
 `````````
 

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2024-09-23 22:36:38 UTC (rev 9937)
@@ -435,7 +435,10 @@
     def __call__(self):
         """Return the babel call with correct options and settings"""
         languages = sorted(self.otherlanguages.keys())
-        languages.append(self.language or 'english')
+        if languages:
+            languages.append(f'main={self.language or "english"}')
+        else:
+            languages.append(self.language or 'english')
         self.setup = [r'\usepackage[%s]{babel}' % ','.join(languages)]
         # Deactivate "active characters"
         shorthands = []
@@ -456,7 +459,7 @@
             self.setup.extend([r'\makeatletter',
                                r'  \addto\extrasbasque{\bbl@deactivate{~}}',
                                r'\makeatother'])
-        if (languages[-1] == 'english'
+        if (languages[-1] == 'main=english'
             and 'french' in self.otherlanguages.keys()):
             self.setup += ['% Prevent side-effects if French hyphenation '
                            'patterns are not loaded:',
@@ -520,11 +523,12 @@
 \floatplacement{figure}{H} % place figures here definitely"""
 
 PreambleCmds.linking = r"""%% hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[%s]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} %% normal text font (alternatives: tt, rm, sf)
-}{}"""
+\fi"""
 
 PreambleCmds.minitoc = r"""%% local table of contents
 \usepackage{minitoc}"""
@@ -1254,7 +1258,6 @@
                             (self.documentoptions,
                              settings.documentclass)]
         self.requirements = SortableDict()  # made a list in depart_document()
-        self.requirements['__static'] = r'\usepackage{ifthen}'
         self.latex_preamble = [settings.latex_preamble]
         self.fallbacks = SortableDict()  # made a list in depart_document()
         self.pdfsetup = []  # PDF properties (hyperref package)

Modified: trunk/docutils/docutils/writers/latex2e/docutils.sty
===================================================================
--- trunk/docutils/docutils/writers/latex2e/docutils.sty	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/docutils/writers/latex2e/docutils.sty	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,6 +1,6 @@
 %% docutils.sty: macros for Docutils LaTeX output.
 %%
-%%   Copyright © 2020 Günter Milde
+%%   Copyright © 2020, 2024 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,
@@ -8,7 +8,12 @@
 %%      notice and this notice are preserved.
 %%      This file is offered as-is, without any warranty.
 
+% docutils.sty
+% ************
+%
+% .. contents::
 % .. include:: README.md
+%    :parser: commonmark
 %
 % Implementation
 % ==============
@@ -17,7 +22,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{docutils}
-  [2021/05/18 macros for Docutils LaTeX output]
+  [2024-09-23 macros for Docutils LaTeX output]
 
 % Helpers
 % -------
@@ -27,19 +32,23 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\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}}{}
+\providecommand*{\DUprovidelength}[2]{%
+  \ifdefined#1
+  \else
+    \newlength{#1}\setlength{#1}{#2}%
+  \fi
 }
 
 
@@ -46,7 +55,7 @@
 % Configuration defaults
 % ----------------------
 %
-% See `Docutils LaTeX Writer`_ for details.
+% See `Generating LaTeX with Docutils`_ for details.
 %
 % abstract::
 
@@ -61,7 +70,7 @@
   \renewenvironment{quote}{\begin{center}}{\end{center}}%
 }
 
-% TODO: add \em to set dedication text in italics?
+% .. TODO: add \em to set dedication text in italics?
 %
 % docinfo::
 
@@ -88,28 +97,30 @@
 % admonition::
 
 % admonition environment (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}
-  }
+\ifdefined\DUadmonition
+\else % 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
 
 % fieldlist::
 
 % field list environment (for separate configuration of `field lists`)
-\ifthenelse{\isundefined{\DUfieldlist}}{
+\ifdefined\DUfieldlist
+\else
   \newenvironment{DUfieldlist}%
     {\quote\description}
     {\enddescription\endquote}
-}{}
+\fi
 
 % footnotes::
 
@@ -141,15 +152,17 @@
 % legend::
 
 % legend environment (in figures and formal tables)
-\ifthenelse{\isundefined{\DUlegend}}{
+\ifdefined\DUlegend
+\else
   \newenvironment{DUlegend}{\small}{}
-}{}
+\fi
 
 % lineblock::
 
 % line block environment
 \DUprovidelength{\DUlineblockindent}{2.5em}
-\ifthenelse{\isundefined{\DUlineblock}}{
+\ifdefined\DUlineblock
+\else
   \newenvironment{DUlineblock}[1]{%
     \list{}{\setlength{\partopsep}{\parskip}
             \addtolength{\partopsep}{\baselineskip}
@@ -160,7 +173,7 @@
     \raggedright
   }
   {\endlist}
-}{}
+\fi
 
 % optionlist::
 
@@ -167,7 +180,8 @@
 % list of command line options
 \providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
 \DUprovidelength{\DUoptionlistindent}{3cm}
-\ifthenelse{\isundefined{\DUoptionlist}}{
+\ifdefined\DUoptionlist
+\else
   \newenvironment{DUoptionlist}{%
     \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
             \setlength{\rightmargin}{1cm}
@@ -177,7 +191,7 @@
             \renewcommand{\makelabel}{\DUoptionlistlabel}}
   }
   {\endlist}
-}{}
+\fi
 
 % rubric::
 
@@ -221,3 +235,9 @@
   \hspace*{\fill}\hrulefill\hspace*{\fill}
   \vskip 0.5\baselineskip
 }
+
+
+% .. References:
+%
+% .. _Generating LaTeX with Docutils:
+%     https://docutils.sourceforge.io/docs/user/latex.html

Modified: trunk/docutils/test/functional/expected/cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/cyrillic.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/cyrillic.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,9 +1,8 @@
 \documentclass[a4paper,russian]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1,T2A]{fontenc}
-\usepackage[english,russian]{babel}
+\usepackage[english,main=russian]{babel}
 \setcounter{secnumdepth}{0}
 
 %%% Custom LaTeX preamble
@@ -18,11 +17,12 @@
 %%% Fallback definitions for Docutils-specific commands
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdflang={ru},
 }

Modified: trunk/docutils/test/functional/expected/latex_babel.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_babel.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_babel.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,9 +1,8 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
-\usepackage[basque,esperanto,estonian,galician,ngerman,english]{babel}
+\usepackage[basque,esperanto,estonian,galician,ngerman,main=english]{babel}
 \AtBeginDocument{\shorthandoff{.<>}}
 \deactivatetilden % restore ~ in Galician
 \makeatletter
@@ -24,11 +23,12 @@
 %%% Fallback definitions for Docutils-specific commands
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 
 %%% Body
 \begin{document}

Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \DeclareUnicodeCharacter{21D4}{\ensuremath{\Leftrightarrow}}
 \DeclareUnicodeCharacter{2660}{\ensuremath{\spadesuit}}
@@ -33,42 +32,49 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 
 % Provide a length variable and set default, if it is new
-\providecommand*{\DUprovidelength}[2]{
-  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+\providecommand*{\DUprovidelength}[2]{%
+  \ifdefined#1
+  \else
+    \newlength{#1}\setlength{#1}{#2}%
+  \fi
 }
 
 % admonition environment (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}
-  }
+\ifdefined\DUadmonition
+\else % 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
 
 % legend environment (in figures and formal tables)
-\ifthenelse{\isundefined{\DUlegend}}{
+\ifdefined\DUlegend
+\else
   \newenvironment{DUlegend}{\small}{}
-}{}
+\fi
 
 % line block environment
 \DUprovidelength{\DUlineblockindent}{2.5em}
-\ifthenelse{\isundefined{\DUlineblock}}{
+\ifdefined\DUlineblock
+\else
   \newenvironment{DUlineblock}[1]{%
     \list{}{\setlength{\partopsep}{\parskip}
             \addtolength{\partopsep}{\baselineskip}
@@ -79,12 +85,13 @@
     \raggedright
   }
   {\endlist}
-}{}
+\fi
 
 % list of command line options
 \providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
 \DUprovidelength{\DUoptionlistindent}{3cm}
-\ifthenelse{\isundefined{\DUoptionlist}}{
+\ifdefined\DUoptionlist
+\else
   \newenvironment{DUoptionlist}{%
     \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
             \setlength{\rightmargin}{1cm}
@@ -94,7 +101,7 @@
             \renewcommand{\makelabel}{\DUoptionlistlabel}}
   }
   {\endlist}
-}{}
+\fi
 
 % title for topics, admonitions, unsupported section levels, and sidebar
 \providecommand*{\DUtitle}[1]{%
@@ -110,11 +117,12 @@
 }
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdftitle={Additional Tests for the LaTeX Writer},
 }

Modified: trunk/docutils/test/functional/expected/latex_docinfo.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_docinfo.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_docinfo.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 
 %%% Custom LaTeX preamble
@@ -15,11 +14,12 @@
 %%% Fallback definitions for Docutils-specific commands
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdfauthor={Foo Fred;Bar Barney}
 }

Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{alltt}
 \usepackage{amsmath}
@@ -27,17 +26,21 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 
 % Provide a length variable and set default, if it is new
-\providecommand*{\DUprovidelength}[2]{
-  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+\providecommand*{\DUprovidelength}[2]{%
+  \ifdefined#1
+  \else
+    \newlength{#1}\setlength{#1}{#2}%
+  \fi
 }
 
 \providecommand*{\DUCLASSabstract}{
@@ -45,18 +48,19 @@
 }
 
 % admonition environment (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}
-  }
+\ifdefined\DUadmonition
+\else % 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
 
 % width of docinfo table
@@ -63,11 +67,12 @@
 \DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
 
 % field list environment (for separate configuration of `field lists`)
-\ifthenelse{\isundefined{\DUfieldlist}}{
+\ifdefined\DUfieldlist
+\else
   \newenvironment{DUfieldlist}%
     {\quote\description}
     {\enddescription\endquote}
-}{}
+\fi
 
 % numerical or symbol footnotes with hyperlinks and backlinks
 \providecommand*{\DUfootnotemark}[3]{%
@@ -94,7 +99,8 @@
 
 % line block environment
 \DUprovidelength{\DUlineblockindent}{2.5em}
-\ifthenelse{\isundefined{\DUlineblock}}{
+\ifdefined\DUlineblock
+\else
   \newenvironment{DUlineblock}[1]{%
     \list{}{\setlength{\partopsep}{\parskip}
             \addtolength{\partopsep}{\baselineskip}
@@ -105,12 +111,13 @@
     \raggedright
   }
   {\endlist}
-}{}
+\fi
 
 % list of command line options
 \providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
 \DUprovidelength{\DUoptionlistindent}{3cm}
-\ifthenelse{\isundefined{\DUoptionlist}}{
+\ifdefined\DUoptionlist
+\else
   \newenvironment{DUoptionlist}{%
     \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
             \setlength{\rightmargin}{1cm}
@@ -120,7 +127,7 @@
             \renewcommand{\makelabel}{\DUoptionlistlabel}}
   }
   {\endlist}
-}{}
+\fi
 
 % informal heading
 \providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
@@ -133,11 +140,12 @@
 \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdftitle={Styling of Elements in Definition- or Field-List},
   pdfauthor={Hänsel;Gretel}

Modified: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{alltt}
 \usepackage{amsmath}
@@ -27,11 +26,12 @@
 \settowidth{\ttemwidth}{\ttfamily M}
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 
 %%% Body
 \begin{document}

Modified: trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{amsmath}
 \usepackage{color}
@@ -27,11 +26,12 @@
 \settowidth{\ttemwidth}{\ttfamily M}
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 
 %%% Body
 \begin{document}

Modified: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{amsmath}
 \usepackage{color}
@@ -33,11 +32,12 @@
 \settowidth{\ttemwidth}{\ttfamily M}
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 
 %%% Body
 \begin{document}

Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{amsmath}
 \usepackage{color}
@@ -26,11 +25,12 @@
 \settowidth{\ttemwidth}{\ttfamily M}
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 
 %%% Body
 \begin{document}

Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,7 +1,6 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{amsmath}
 \usepackage{color}
@@ -27,11 +26,12 @@
 \settowidth{\ttemwidth}{\ttfamily M}
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 
 %%% Body
 \begin{document}

Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,11 +1,10 @@
 % generated by Docutils <https://docutils.sourceforge.io/>
 \documentclass[a4paper]{memoir}
 
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{alltt}
 \usepackage{amsmath}
-\usepackage[british,french,ngerman,english]{babel}
+\usepackage[british,french,ngerman,main=english]{babel}
 % Prevent side-effects if French hyphenation patterns are not loaded:
 \frenchbsetup{StandardLayout}
 \AtBeginDocument{\selectlanguage{english}\noextrasfrench}
@@ -34,17 +33,21 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 
 % Provide a length variable and set default, if it is new
-\providecommand*{\DUprovidelength}[2]{
-  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+\providecommand*{\DUprovidelength}[2]{%
+  \ifdefined#1
+  \else
+    \newlength{#1}\setlength{#1}{#2}%
+  \fi
 }
 
 % abstract title
@@ -78,11 +81,12 @@
 \providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}
 
 % field list environment (for separate configuration of `field lists`)
-\ifthenelse{\isundefined{\DUfieldlist}}{
+\ifdefined\DUfieldlist
+\else
   \newenvironment{DUfieldlist}%
     {\quote\description}
     {\enddescription\endquote}
-}{}
+\fi
 
 % numerical or symbol footnotes with hyperlinks and backlinks
 \providecommand*{\DUfootnotemark}[3]{%
@@ -108,13 +112,15 @@
 }
 
 % legend environment (in figures and formal tables)
-\ifthenelse{\isundefined{\DUlegend}}{
+\ifdefined\DUlegend
+\else
   \newenvironment{DUlegend}{\small}{}
-}{}
+\fi
 
 % line block environment
 \DUprovidelength{\DUlineblockindent}{2.5em}
-\ifthenelse{\isundefined{\DUlineblock}}{
+\ifdefined\DUlineblock
+\else
   \newenvironment{DUlineblock}[1]{%
     \list{}{\setlength{\partopsep}{\parskip}
             \addtolength{\partopsep}{\baselineskip}
@@ -125,12 +131,13 @@
     \raggedright
   }
   {\endlist}
-}{}
+\fi
 
 % list of command line options
 \providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
 \DUprovidelength{\DUoptionlistindent}{3cm}
-\ifthenelse{\isundefined{\DUoptionlist}}{
+\ifdefined\DUoptionlist
+\else
   \newenvironment{DUoptionlist}{%
     \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
             \setlength{\rightmargin}{1cm}
@@ -140,7 +147,7 @@
             \renewcommand{\makelabel}{\DUoptionlistlabel}}
   }
   {\endlist}
-}{}
+\fi
 
 % informal heading
 \providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
@@ -174,11 +181,12 @@
   \vskip 0.5\baselineskip
 }
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdftitle={reStructuredText Test Document},
   pdfkeywords={reStructuredText, test, parser},

Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -1,11 +1,10 @@
 \documentclass[a4paper]{article}
 % generated by Docutils <https://docutils.sourceforge.io/>
 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
-\usepackage{ifthen}
 \usepackage[T1]{fontenc}
 \usepackage{alltt}
 \usepackage{amsmath}
-\usepackage[british,french,ngerman,english]{babel}
+\usepackage[british,french,ngerman,main=english]{babel}
 % Prevent side-effects if French hyphenation patterns are not loaded:
 \frenchbsetup{StandardLayout}
 \AtBeginDocument{\selectlanguage{english}\noextrasfrench}
@@ -34,17 +33,21 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 
 % Provide a length variable and set default, if it is new
-\providecommand*{\DUprovidelength}[2]{
-  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+\providecommand*{\DUprovidelength}[2]{%
+  \ifdefined#1
+  \else
+    \newlength{#1}\setlength{#1}{#2}%
+  \fi
 }
 
 \providecommand*{\DUCLASSabstract}{
@@ -52,18 +55,19 @@
 }
 
 % admonition environment (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}
-  }
+\ifdefined\DUadmonition
+\else % 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
 
 % special topic for dedications
@@ -81,11 +85,12 @@
 \providecommand*{\DUCLASSerror}{\color{red}}
 
 % field list environment (for separate configuration of `field lists`)
-\ifthenelse{\isundefined{\DUfieldlist}}{
+\ifdefined\DUfieldlist
+\else
   \newenvironment{DUfieldlist}%
     {\quote\description}
     {\enddescription\endquote}
-}{}
+\fi
 
 % numerical or symbol footnotes with hyperlinks and backlinks
 \providecommand*{\DUfootnotemark}[3]{%
@@ -111,13 +116,15 @@
 }
 
 % legend environment (in figures and formal tables)
-\ifthenelse{\isundefined{\DUlegend}}{
+\ifdefined\DUlegend
+\else
   \newenvironment{DUlegend}{\small}{}
-}{}
+\fi
 
 % line block environment
 \DUprovidelength{\DUlineblockindent}{2.5em}
-\ifthenelse{\isundefined{\DUlineblock}}{
+\ifdefined\DUlineblock
+\else
   \newenvironment{DUlineblock}[1]{%
     \list{}{\setlength{\partopsep}{\parskip}
             \addtolength{\partopsep}{\baselineskip}
@@ -128,12 +135,13 @@
     \raggedright
   }
   {\endlist}
-}{}
+\fi
 
 % list of command line options
 \providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
 \DUprovidelength{\DUoptionlistindent}{3cm}
-\ifthenelse{\isundefined{\DUoptionlist}}{
+\ifdefined\DUoptionlist
+\else
   \newenvironment{DUoptionlist}{%
     \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
             \setlength{\rightmargin}{1cm}
@@ -143,7 +151,7 @@
             \renewcommand{\makelabel}{\DUoptionlistlabel}}
   }
   {\endlist}
-}{}
+\fi
 
 % informal heading
 \providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
@@ -172,11 +180,12 @@
 }
 
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdftitle={reStructuredText Test Document},
   pdfkeywords={reStructuredText, test, parser},

Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -8,7 +8,6 @@
   \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
     {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%
 \fi
-\usepackage{ifthen}
 \usepackage{alltt}
 \usepackage{amsmath}
 \usepackage{polyglossia}
@@ -48,11 +47,12 @@
     {\end{list}}%
 }
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdftitle={reStructuredText Test Document},
   pdfkeywords={reStructuredText, test, parser},

Modified: trunk/docutils/test/functional/expected/xetex-cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/xetex-cyrillic.tex	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/functional/expected/xetex-cyrillic.tex	2024-09-23 22:36:38 UTC (rev 9937)
@@ -8,7 +8,6 @@
   \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
     {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%
 \fi
-\usepackage{ifthen}
 \usepackage{polyglossia}
 \setdefaultlanguage{russian}
 \setotherlanguages{english}
@@ -24,11 +23,12 @@
 
 %%% Fallback definitions for Docutils-specific commands
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 \hypersetup{
   pdflang={ru},
 }

Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/test_writers/test_latex2e.py	2024-09-23 22:36:38 UTC (rev 9937)
@@ -124,8 +124,7 @@
 parts = {
 'head_prefix': r"""\documentclass[a4paper]{article}
 """,
-'requirements': r"""\usepackage{ifthen}
-\usepackage[T1]{fontenc}
+'requirements': r"""\usepackage[T1]{fontenc}
 """,
 'latex_preamble': r"""% PDF Standard Fonts
 \usepackage{mathptmx} % Times
@@ -156,11 +155,12 @@
 """,
 'pdfsetup': r"""
 % hyperlinks:
-\ifthenelse{\isundefined{\hypersetup}}{
+\ifdefined\hypersetup
+\else
   \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
   \usepackage{bookmark}
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
-}{}
+\fi
 """,
 'titledata': ''}
 
@@ -227,9 +227,8 @@
 samples_default['spanish_quote'] = [
 [".. role:: language-es\n\nUnd damit :language-es:`basta`!",
 head_template.substitute(dict(parts,
-requirements=r"""\usepackage{ifthen}
-\usepackage[T1]{fontenc}
-\usepackage[spanish,english]{babel}
+requirements=r"""\usepackage[T1]{fontenc}
+\usepackage[spanish,main=english]{babel}
 \AtBeginDocument{\shorthandoff{.<>}}
 """)) + r"""
 Und damit \foreignlanguage{spanish}{basta}!
@@ -269,12 +268,13 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 
 % title for topics, admonitions, unsupported section levels, and sidebar
@@ -989,12 +989,13 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 """
     )
@@ -1101,12 +1102,13 @@
 % 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}
+\ifdefined\DUclass
+\else % 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}%
+    {\csname end\DocutilsClassFunctionName \endcsname}%
 \fi
 """)
 ) + r"""

Modified: trunk/docutils/test/test_writers/test_xetex_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_xetex_misc.py	2024-09-20 08:32:41 UTC (rev 9936)
+++ trunk/docutils/test/test_writers/test_xetex_misc.py	2024-09-23 22:36:38 UTC (rev 9937)
@@ -45,8 +45,11 @@
 
 px_fallback = r"""
 % Provide a length variable and set default, if it is new
-\providecommand*{\DUprovidelength}[2]{
-  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+\providecommand*{\DUprovidelength}[2]{%
+  \ifdefined#1
+  \else
+    \newlength{#1}\setlength{#1}{#2}%
+  \fi
 }
 
 \DUprovidelength{\pdfpxdimen}{1bp}

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.