Skip to content

Commit ef8f5b7

Browse files
author
Matthias Koeppe
committed
sage -fixdoctests: Do not remove comments that precede annotations
1 parent f01b0c2 commit ef8f5b7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/sage/doctest/parsing.py

+11
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ def parse_optional_tags(string):
141141
# strip_string_literals replaces comments
142142
comment = "#" + (literals[comment]).lower()
143143

144+
if return_string_sans_tags:
145+
# skip non-tag comments that precede the first tag comment
146+
if m := optional_regex.search(comment):
147+
sharp_index = comment[:m.start(0)].rfind('#')
148+
if sharp_index >= 0:
149+
first_line += comment[:sharp_index]
150+
comment = comment[sharp_index:]
151+
else:
152+
# no non-tag comment
153+
return set(), string
154+
144155
tags = []
145156
for m in optional_regex.finditer(comment):
146157
cmd = m.group(1)

0 commit comments

Comments
 (0)