Skip to content

[palette-] prevent interpretation of markup in go-col-name#2959

Open
midichef wants to merge 3 commits intosaulpw:developfrom
midichef:palette_markup
Open

[palette-] prevent interpretation of markup in go-col-name#2959
midichef wants to merge 3 commits intosaulpw:developfrom
midichef:palette_markup

Conversation

@midichef
Copy link
Contributor

The palette choosers for & + and gc have some minor display inconsistencies with the way longnames are displayed in exec-longname. The first two commits in this PR fix those inconsistencies.

The third commit fixes a bug in gc where a column name had markup interpreted, so 'Customer[:5]' was shown as Customer, and cell contents had markup interpreted, so a cell of [:bold]asdf[/] was drawn as asdf in bold. However, to properly display the column name as a literal with no markup, I had to turn off the bolding of the column name that was just added in the first commit (40d4243).

to match how longnames are bolded in inputLongname
Fixes a bug where go-col-name would interpret text as markup
in column names and in cell contents.
For go-col-name, turns off bold display of the column name,
because drawing it in bold would also cause nonmarkup substrings
like "[:5]" to be interpreted as markup.
@midichef
Copy link
Contributor Author

midichef commented Jan 31, 2026

Hmm. Turning off formatting in go-col-name was a bad idea. Now it fails to interpret the coloring of the match. So for a colname like Customer. When I type C I see: [:match]C[/]ustomer. So we have to trade off between: coloring matches, vs. correctness for column names that contain pseudomarkup like [:text].

What would be a good way to escape visidata markup?

@midichef
Copy link
Contributor Author

midichef commented Feb 1, 2026

Perhaps we can escape vd markup by wrapping every open bracket [ between some no-op markup that has no color bound to it, like: [:literal] and [:]. I think it should work, judging by the working of iterchunks() and internal_markup_re. But the idea needs to be double-checked for validity, in case I have missed any important case.

def escape_vdcode(s:str) -> str:
    return re.sub(r'\[', '[:literal][[:]', s)

def unescape_vdcode(s:str) -> str:
    return re.sub(r'\[:literal\]\[\[:\]', '[', s)

If this works, I would discard the changes in f19d7ba and change go-col-name to escape the colname and the cell contents.

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.

1 participant