From c9d4a1a204f514dab89c9238a463c96a2d0e0105 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 28 Jul 2023 00:49:53 +0100 Subject: [PATCH] Correctly copy extentionless template files --- sphinx/util/fileutil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py index 5dae51c2a..0d6b77e18 100644 --- a/sphinx/util/fileutil.py +++ b/sphinx/util/fileutil.py @@ -37,13 +37,13 @@ def copy_asset_file(source: str | os.PathLike[str], destination: str | os.PathLi else: destination = str(destination) - if os.path.splitext(source)[1].lower().endswith('_t') and context is not None: + if os.path.basename(source).endswith(('_t', '_T')) and context is not None: if renderer is None: from sphinx.util.template import SphinxRenderer renderer = SphinxRenderer() with open(source, encoding='utf-8') as fsrc: - if destination.lower().endswith('_t'): + if destination.endswith(('_t', '_T')): destination = destination[:-2] with open(destination, 'w', encoding='utf-8') as fdst: fdst.write(renderer.render_string(fsrc.read(), context))