Skip to content

Commit 2111629

Browse files
committed
fix(hooks): render inline {@link URL desc} PHPDoc tags as links
The upstream parser autolinks the URL inside an inline {@link} tag but leaves the surrounding tag as literal text; sanitizeContent then escapes the braces, so pages rendered e.g. '\{@link <a href=URL>URL</a> Read more\}' verbatim (visible on the gravityview_page_links_args filter page). cleanupHookContent now rewrites the escaped inline tag into a single link, using the tag's description as anchor text (falling back to the URL when none is given). Fixes all affected hook pages.
1 parent 34d8523 commit 2111629

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

scripts/generate-hooks.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,21 @@ function cleanupHookContent(outputDir) {
400400
modified = true;
401401
}
402402

403+
// Fix inline {@link URL description} PHPDoc tags inside descriptions.
404+
// The upstream parser autolinks the URL but leaves the surrounding tag as
405+
// literal text, and sanitizeContent then escapes the braces — so the page
406+
// renders e.g. `\{@link <a href="URL">URL</a> Read more\}` verbatim.
407+
// Rewrite it as a single link using the description as the anchor text
408+
// (falling back to the URL when no description was provided).
409+
const inlineLinkPattern = /\\\{@link\s+<a href="([^"]+)">.*?<\/a>\s*(.*?)\s*\\\}/g;
410+
if (inlineLinkPattern.test(content)) {
411+
content = content.replace(inlineLinkPattern, (match, url, description) => {
412+
const linkText = description.trim() || url;
413+
return `<a href="${url}">${linkText}</a>`;
414+
});
415+
modified = true;
416+
}
417+
403418
// Fix double-escaped type shapes inside inline code spans.
404419
// wp-hooks-documentor HTML-escapes `<`/`>` and wraps types in backticks
405420
// (e.g. `array&lt;string,bool&gt;`). Markdown/MDX renders inline-code content

0 commit comments

Comments
 (0)