Skip to content

BEL-terminated OSC 8 hyperlinks inflate table column widths #460

Description

@GreedyC

Summary

BEL-terminated OSC 8 hyperlinks are treated as visible text when calculating column widths. The equivalent ST-terminated link is handled correctly.

Environment

Current master 268615a, Python 3.14.6, macOS arm64. Imported directly from the checkout (version is unknown).

Reproduction

from tabulate import tabulate

for terminator in ("\x1b\\", "\x07"):
    label = f"\x1b]8;;https://example.com{terminator}docs\x1b]8;;{terminator}"
    result = tabulate([[label, "ok"]], headers=["name", "state"], tablefmt="grid")
    print(result.splitlines()[0])

Actual:

+--------+---------+
+-------------------------------------+---------+

Expected: both tables use the first width; both links display the same four-character label. Terminal tables containing hyperlinks generated with BEL otherwise have unnecessarily wide borders and misaligned cell separators.

The hyperlink specification linked in the source explicitly describes BEL as an alternative OSC terminator: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence . _st currently recognizes only ESC \\.

I checked #39 and the merged #184, and #273 (escape sequences within link text / directly adjacent links). This reproduction has plain link text and a closing sequence; only the terminator differs.

AI assistance: Codex helped analyze and draft this report. The reproduction was executed locally. No PR is attached.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions