Skip to content

PageText: drop sentence punctuation left behind by an unmatched closing bracket (#102) - #108

Open
dhruv1220 wants to merge 1 commit into
CopilotKit:mainfrom
dhruv1220:fix/page-text-punctuation-behind-bracket-102
Open

dhruv1220 wants to merge 1 commit into
CopilotKit:mainfrom
dhruv1220:fix/page-text-punctuation-behind-bracket-102

Conversation

@dhruv1220

Copy link
Copy Markdown

Fixes #102.

PageText trimmed trailing sentence punctuation once, before removing unmatched closing brackets. When a source URL sat at the end of a parenthetical sentence, the bracket removal exposed punctuation that then became part of the link destination: "(See https://example.com/pricing.)" linked to "https://example.com/pricing." instead of "https://example.com/pricing".

The trim/strip now repeats until the suffix is stable, so punctuation hidden behind an unmatched closer is dropped on the next pass. Balanced parentheses inside a URL (e.g. wiki links) are still preserved, and the visible paragraph text is unchanged — only the href changes.

Test: added "source links drop punctuation left behind by an unmatched closing bracket" to openbot/app/tests/pages.test.tsx, covering the two reported cases plus a balanced-parens URL with a trailing period. Verified the new test fails on pristine code (hrefs came back with the trailing "." and ",") and passes with the fix. Full pages.test.tsx: 47/47 pass. App typecheck and biome format/lint clean.

@STiFLeR7 STiFLeR7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I ran the same citation cases against this PR and #104 on Windows with Bun 1.4.3. Both passed all six focused tests. The shared comparison failed on main (b32ec10) with five wrong destinations. Both patches preserve the visible paragraph text, and their runtime code is identical.

I recommend merging this PR for #102 because its regression test combines a balanced parenthesis inside the URL with sentence punctuation inside the outer parentheses: (See https://example.com/wiki/Project_(software).). It checks that the same link keeps (software) while dropping the sentence period and unmatched closer. #104 also fixes the reported bug and has a useful control for a period outside the parentheses. One of the two PRs is enough.

@dhruv1220

Copy link
Copy Markdown
Author

Thanks for verifying this on Windows with Bun 1.4.3 — really helpful to have the cross-platform check, and the comparison against #104 makes the case for this one clearly. The balanced-parens-inside-URL case was the one I most wanted covered, so glad it holds up there too.

@STiFLeR7

Copy link
Copy Markdown

Thanks, Dhruv. The balanced-parentheses case passed on Windows with Bun 1.4.3. I still recommend #108 for #102 because its regression checks that the same link keeps (software) and drops the trailing period and unmatched closing parenthesis.

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.

Saved research citations include punctuation inside closing brackets

2 participants