The bug
Text.from_ansi exposes OSC 8 payload text and loses the link when the sequence ends with BEL. The equivalent ST-terminated sequence works.
from rich.text import Text
for terminator in ("\x1b\\", "\x07"):
source = f"\x1b]8;;https://example.com{terminator}hello\x1b]8;;{terminator}"
text = Text.from_ansi(source)
print(repr(text.plain), [(s.start, s.end, str(s.style)) for s in text.spans])
Actual output:
'hello' [(0, 5, 'link https://example.com')]
'8;;https://example.comhello8;;' []
Expected: both inputs produce plain text hello with the same link span. Xterm documents both BEL and ST as OSC terminators: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
re_ansi in rich/ansi.py currently recognizes ST for its OSC branch, but not BEL. This is distinct from #3561, which measures raw ANSI strings without converting them first.
Platform
Current main commit 9d8f9a3, Python 3.14.6, macOS arm64. Reproduced from the checkout with markdown-it-py and Pygments installed via uv. No terminal rendering is needed to reproduce this.
AI assistance (Codex) was used to investigate and prepare this report; the output above was verified locally. No PR is attached.
Text.from_ansiconversion.The bug
Text.from_ansiexposes OSC 8 payload text and loses the link when the sequence ends with BEL. The equivalent ST-terminated sequence works.Actual output:
Expected: both inputs produce plain text
hellowith the same link span. Xterm documents both BEL and ST as OSC terminators: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commandsre_ansiinrich/ansi.pycurrently recognizes ST for its OSC branch, but not BEL. This is distinct from #3561, which measures raw ANSI strings without converting them first.Platform
Current main commit
9d8f9a3, Python 3.14.6, macOS arm64. Reproduced from the checkout with markdown-it-py and Pygments installed via uv. No terminal rendering is needed to reproduce this.AI assistance (Codex) was used to investigate and prepare this report; the output above was verified locally. No PR is attached.