Skip to content

Commit 4bd7500

Browse files
committed
fix: normalize p5 reference links in parameter sections
Fixes #674 The regex in normalizeP5ReferenceLinks() was capturing the 'p5' prefix in the capture group, causing duplicate 'p5' in URLs. Before: #/p5/rectMode -> /reference/p5/p5/rectMode/ (broken) After: #/p5/rectMode -> /reference/p5/rectMode/ (fixed) Updated regex to exclude 'p5' from capture group while still handling both dot notation (#/p5.Element) and slash notation (#/p5/rectMode) patterns.
1 parent a505e06 commit 4bd7500

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/layouts/ReferenceItemLayout.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ const { showBanner, englishUrl } = checkTranslationBanner(
9090
Astro.url.pathname,
9191
Astro.url.origin
9292
);
93-
// Normalizes malformed p5.* reference anchors (e.g. "#/p5.Element")
94-
// to proper reference routes ("/reference/p5/p5.Element/")
93+
// Normalizes malformed p5.* reference anchors (e.g. "#/p5.Element" or "#/p5/rectMode")
94+
// to proper reference routes ("/reference/p5/p5.Element/" or "/reference/p5/rectMode/")
9595
function normalizeP5ReferenceLinks(html: string | undefined): string | undefined {
9696
if (!html) return html;
9797
return html.replace(
98-
/href="#\/(p5\.[^"]+)"/g,
99-
'href="/reference/p5/$1/"'
98+
/href="#\/p5([.\/][^"]+)"/g,
99+
'href="/reference/p5$1/"'
100100
);
101101
}
102102
---

0 commit comments

Comments
 (0)