Skip to content

fix: normalize p5 reference links in parameter sections - #1284

Open
rushdarshan wants to merge 3 commits into
processing:v1from
rushdarshan:fix-parameter-links-674
Open

fix: normalize p5 reference links in parameter sections#1284
rushdarshan wants to merge 3 commits into
processing:v1from
rushdarshan:fix-parameter-links-674

Conversation

@rushdarshan

Copy link
Copy Markdown

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.

@ksen0 ksen0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this @rushdarshan and the patience in waiting for review.

I tested:

Similarly with http://localhost:4321/reference/p5/ambientLight/ - the current behavior links p5.Color correctly in both description and parameters. In this PR, the description link works, but parameters link is broken. They use the name relative path in the jsdocs, so this is something the logic should hopefully handle.

If you're still interested in working on this, could you update the logic to cover both cases? Additionally, please check if it is possible to add a unit test for each case so the check can be automated.

Thanks again! and if you're not able to work on this anymore, please also let us know so it can be reassigned.

@rushdarshan

Copy link
Copy Markdown
Author

Thanks for the detailed review — I’ve updated the logic to handle both link formats in parameter sections:

  • #/p5/rectMode → /reference/p5/rectMode/
  • #/p5.Color → /reference/p5/p5.Color/

I also added unit tests for both cases (including lightness/ambientLight style p5.Color links in parameters) so this is now covered automatically.

Could you please re-review when you get a chance?

@rushdarshan
rushdarshan requested a review from ksen0 May 16, 2026 18:01
@ksen0

ksen0 commented Jun 10, 2026

Copy link
Copy Markdown
Member

@Nwakaego-Ego @doradocodes does one of you have capacity to review this please? Would be nice to get it in to both branches if applicable before the website switch, if possible! thanks all

@Nwakaego-Ego

Copy link
Copy Markdown
Contributor

Hi @rushdarshan, thank you for this PR. I tested the fix locally on your branch and can confirm:

The rectMode() link in the Parameters section of the text() reference page now navigates correctly to /reference/p5/rectMode/. The p5.Color link in the Parameters section of the lightness() reference page now navigates correctly to /reference/p5/p5.Color/. I also ran npm test and all three tests in referenceLinkUtils.test.ts passed. Moving the function to its own utility file makes it easier to test and reuse. The logic correctly handles both slash notation and dot notation link formats.

cc @doradocodes @ksen0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushdarshan moving this out of the ReferenceItemLayout.astro file makes sense, but I think it should be moved into the src/utils and rename the file to referenceLink.ts to match the existing pattern of handling util files.

@ksen0

ksen0 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Hi @rushdarshan are you still working on this one to address the review comments? Please let us know in the next ~week (by July 3) thanks in advance!

@rushdarshan
rushdarshan force-pushed the fix-parameter-links-674 branch from 94cfadb to 1645038 Compare July 27, 2026 18:12
Fixes processing#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.
@rushdarshan
rushdarshan force-pushed the fix-parameter-links-674 branch from 1645038 to 4ff0df2 Compare July 27, 2026 18:17
@rushdarshan
rushdarshan requested a review from doradocodes July 27, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Links in Parameters section don't work

4 participants