synology_apm_repo.sdk.presentation.markup module

safe(): escape arbitrary text before it reaches a Rich-markup-parsing call (the CLI’s Console.print(), the TUI’s Static/Tree/ DataTable). Unescaped dynamic text can crash a Textual widget or be silently mangled by Rich’s parser.

Every [ is escaped, not just tag-shaped ones as rich.markup.escape() does: Textual’s tokenizer treats any unescaped [ as an open tag and crashes on an ordinary bracketed reference like "[TICKET-1234]".

C0 control characters and DEL (except tab/newline/CR) are stripped, so an escape sequence embedded in repository-derived text (a filename, a chat message) never reaches the terminal.

A value containing a strong right-to-left character is wrapped in a zero-width bidi isolate (FSI/PDI): unisolated, the terminal’s bidi reordering can pull neighbouring table borders into the RTL run and desync the rendered layout from what Rich/Textual drew.

synology_apm_repo.sdk.presentation.markup.safe(value)

str(value) made safe to interpolate into Rich markup beside literal [color] tags: every [ escaped, control characters stripped, and an RTL-containing value wrapped in a bidi isolate.