8000 fix: Only replace CSS class in first *highlighting* span · mkdocstrings/python@d57740f · GitHub
[go: up one dir, main page]

Skip to content

Commit d57740f

Browse files
committed
fix: Only replace CSS class in first *highlighting* span
When `pymdownx.highlight` sets `auto_title: true`, another span is rendered before the highlighted code. If we replace its CSS class, we mess its final display. Our solution is not very robust: we only look for spans with CSS classes of 1 or 2 characters instead of 1 or more characters. Issue-281: #281
1 parent 5d2ba0a commit d57740f
D272

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mkdocstrings_handlers/python/_internal/rendering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def do_format_signature(
190190
# To fix this, we replace the CSS class in the first span with `nf`,
191191
# unless we already found an `nf` span.
192192
if not re.search(r'<span class="nf">', signature):
193-
signature = re.sub(r'<span class="[a-z]+">', '<span class="nf">', signature, count=1)
193+
signature = re.sub(r'<span class="[a-z]{1,2}">', '<span class="nf">', signature, count=1)
194194

195195
if stash := env.filters["stash_crossref"].stash:
196196
for key, value in stash.items():

0 commit comments

Comments
 (0)
0