Skip to content

Handle independent OSC8 hyperlink sequences - #443

Open
Spidy092 wants to merge 1 commit into
astanin:masterfrom
Spidy092:codex/fix-osc8-escape-sequences
Open

Handle independent OSC8 hyperlink sequences#443
Spidy092 wants to merge 1 commit into
astanin:masterfrom
Spidy092:codex/fix-osc8-escape-sequences

Conversation

@Spidy092

@Spidy092 Spidy092 commented Sep 3, 2026

Copy link
Copy Markdown

Fixes #273.

Colored text inside an OSC8 hyperlink leaves control sequences in the text used to calculate table widths. For example, a hyperlink containing a red red followed by link should occupy eight columns, but the existing parser counts the hyperlink controls when wide-character handling is disabled. It also misses valid direct transitions between hyperlinks and standalone closing sequences.

Recognize each OSC8 control sequence independently and strip only the controls, preserving the displayed text. Update the word wrapper to consume complete control sequences and keep hyperlink state separate from color state; close hyperlinks at cell boundaries and reopen them on continuation lines.

Add regression coverage for colored link text, direct URI changes, standalone opening and closing controls, link IDs containing punctuation, string and byte inputs, table alignment, and wrapped hyperlink text. Update the parser comments and stripping/wrapping docstrings to describe the behavior.

Validation on Linux with Python 3.14.4:

  • Unchanged baseline: 382 tests passed, 1 skipped.
  • Before implementation, the initial regression tests produced 11 failures and 1 pass.
  • Final full suite, including doctests, NumPy, Pandas, and wcwidth: 398 passed, 1 skipped.
  • Ruff 0.15.4, as pinned in the project's pre-commit configuration: lint and formatting passed.
  • Source distribution and wheel build passed with python3 -m build --no-isolation.
  • git diff --check passed.

Tests ran offline in an isolated filesystem without GitHub credentials. Other Python versions and operating systems have not been tested locally; upstream CI has not run. The build used a shallow checkout, so its generated development version is not release metadata.

Prepared with Codex assistance.

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.

Escape sequences in OSC8 "link text" don't get detected

1 participant