Skip to content

Commit 1b19090

Browse files
Fix linkify of unicode identifiers (#832)
* Add testdata that showcases the undesired behavior * fix linking of identifiers that contain unicode characters (#831) * [autofix.ci] apply automated fixes * Fix linter error * Move tests from demo_long to misc --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent b620123 commit 1b19090

File tree

5 files changed

+170
-46
lines changed

5 files changed

+170
-46
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
""",

0 commit comments

Comments
 (0)