Skip to content

Commit ec1f716

Browse files
committed
fix linking of identifiers that contain unicode characters (#831)
1 parent bac09cd commit ec1f716

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## Unreleased: pdoc next
66

7+
- Fix linking of identifiers that contain unicode characters.
8+
([#831](https://github.com/mitmproxy/pdoc/issues/831), @iFreilicht)
79

810
## 2025-06-04: pdoc 15.0.4
911

pdoc/render_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,23 @@ def linkify_repl(m: re.Match):
408408
# First part of the identifier (e.g. "foo") - this is optional for relative references.
409409
(?:
410410
\b
411-
(?!\d)[a-zA-Z0-9_]+
411+
(?!\d)\w+
412412
|
413413
\.* # We may also start with multiple dots.
414414
)
415415
# Rest of the identifier (e.g. ".bar" or "..bar")
416416
(?:
417417
# A single dot or a dot surrounded with pygments highlighting.
418418
(?:\.|</span><span\ class="o">\.</span><span\ class="n">)
419-
(?!\d)[a-zA-Z0-9_]+
419+
(?!\d)\w+
420420
)+
421421
(?:\(\)|\b(?!\(\))) # we either end on () or on a word boundary.
422422
(?!</a>) # not an existing link
423423
(?![/#]) # heuristic: not part of a URL
424424
425425
| # Part 2: `foo` or `foo()`. `foo.bar` is already covered with part 1.
426426
(?<=<code>)
427-
(?!\d)[a-zA-Z0-9_]+
427+
(?!\d)\w+
428428
(?:\(\))?
429429
(?=</code>(?!</a>))
430430
""",

test/testdata/demo_long.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ <h6 id="be-careful">Be Careful!</h6>
16971697
<div class="docstring"><p>The following link should be created properly:</p>
16981698

16991699
<ul>
1700-
<li><code>MötörCrüe.créer_naïveté</code></li>
1700+
<li><code><a href="#MötörCrüe.créer_naïveté">MötörCrüe.créer_naïveté</a></code></li>
17011701
</ul>
17021702
</div>
17031703

0 commit comments

Comments
 (0)