diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index a0d1f65ea..63455562f 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -1,6 +1,7 @@ """Glue code for the jinja2 templating engine.""" from os import path +import os from pprint import pformat from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Tuple, Union @@ -117,6 +118,9 @@ class SphinxFileSystemLoader(FileSystemLoader): def get_source(self, environment: Environment, template: str) -> Tuple[str, str, Callable]: for searchpath in self.searchpath: filename = path.join(searchpath, template) + # Repalce '/' by os.sep if The searchpath is an extended-length path. + if filename.startswith("\\\\?\\"): + filename = filename.replace('/', os.sep) f = open_if_exists(filename) if f is None: continue