Skip to content

Commit e159c5d

Browse files
committed
Improve %seealso extraction from HTML content
1 parent 2afb6a5 commit e159c5d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

great_docs/assets/post-render.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,16 @@ def extract_seealso_from_html(html_content):
196196
Returns a list of referenced item names, or empty list if none found.
197197
"""
198198
# Match %seealso in <p> tags (most common after markdown rendering)
199+
# This handles both standalone %seealso and when it follows other directives
199200
p_pattern = re.compile(
200-
r"<p>\s*%seealso\s+([^<]+)</p>",
201+
r"<p>[^<]*%seealso\s+([^<%]+?)(?:%|</p>)",
201202
re.IGNORECASE,
202203
)
203204

204-
# Match standalone %seealso lines
205+
# Match standalone %seealso lines (not in HTML tags)
205206
standalone_pattern = re.compile(
206-
r"^\s*%seealso\s+(.+?)\s*$",
207-
re.MULTILINE | re.IGNORECASE,
207+
r"%seealso\s+([^\n%<]+)",
208+
re.IGNORECASE,
208209
)
209210

210211
# Try <p> pattern first

0 commit comments

Comments
 (0)