Skip to content

Commit ad0c343

Browse files
authored
Trim leading whitespace before doctest flags (sphinx-doc#13164)
1 parent 432bc5e commit ad0c343

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sphinx/ext/doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
logger = logging.getLogger(__name__)
3939

4040
blankline_re = re.compile(r'^\s*<BLANKLINE>', re.MULTILINE)
41-
doctestopt_re = re.compile(r'#\s*doctest:.+$', re.MULTILINE)
41+
doctestopt_re = re.compile(r'[ \t]*#\s*doctest:.+$', re.MULTILINE)
4242

4343

4444
def is_allowed_version(spec: str, version: str) -> bool:

tests/test_transforms/test_transforms_post_transforms_code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def test_trim_doctest_flags_html(app):
1515
assert 'QUUX' not in result
1616
assert 'CORGE' not in result
1717
assert 'GRAULT' in result
18+
assert '<span class="n">now</span><span class="p">()</span> \n' not in result
19+
assert '<span class="n">now</span><span class="p">()</span>\n' in result
1820

1921

2022
@pytest.mark.sphinx(

0 commit comments

Comments
 (0)