Skip to content

Leave sentence punctuation out of bracketed citation links - #104

Open
MaxWang007 wants to merge 1 commit into
CopilotKit:mainfrom
MaxWang007:fix/citation-trailing-punctuation
Open

MaxWang007 wants to merge 1 commit into
CopilotKit:mainfrom
MaxWang007:fix/citation-trailing-punctuation

Conversation

@MaxWang007

Copy link
Copy Markdown

Fixes #102

What was wrong

On a saved research page, a source URL at the end of a bracketed phrase kept the sentence punctuation in its link destination. The paragraph text was already right.

Citation Expected destination Actual destination
(See https://example.com/pricing.) https://example.com/pricing https://example.com/pricing.
[See https://example.org/plans,] https://example.org/plans https://example.org/plans,

PageText trimmed trailing punctuation once, then removed an unmatched closing bracket. The period or comma sat just inside that bracket, so once the bracket was peeled off it ended up back on the URL.

The fix

Trim again after unmatched closers are peeled, and repeat until the suffix stops changing. Balanced parentheses inside a URL stay, including Wikipedia-style Project_(software), and the existing control (https://example.org/plans). still links to https://example.org/plans.

PageText renders page text, headings and slide text, so all three pick this up.

Testing

bun test app/tests/pages.test.tsx

  • Before the fix, the new case failed with https://example.com/pricing. and https://example.org/plans,.
  • After the fix, all 47 tests in the file pass.

bunx biome check on the changed files and bun run typecheck in openbot/app both pass.

PageText trimmed trailing punctuation once, then removed an unmatched
closing bracket. When a source URL sat at the end of a bracketed phrase,
the period or comma left behind stayed in the href. (See
https://example.com/pricing.) linked to https://example.com/pricing. and
[See https://example.org/plans,] linked to https://example.org/plans,.

Trim again after peeling unmatched closers, and repeat until the suffix
stops changing. Balanced parentheses in a URL, such as Project_(software),
and a period that already sits outside the brackets stay as they were.
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

1 participant