mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
fix(ansi): allow usage of < and > in text with overrides
This commit is contained in:
parent
4fb18aaac7
commit
011a4ab8f5
|
@ -54,7 +54,7 @@ const (
|
||||||
// Foreground takes the current segment's foreground color
|
// Foreground takes the current segment's foreground color
|
||||||
Foreground = "foreground"
|
Foreground = "foreground"
|
||||||
|
|
||||||
AnchorRegex = `^(?P<ANCHOR><(?P<FG>[^,>]+)?,?(?P<BG>[^>]+)?>)`
|
AnchorRegex = `^(?P<ANCHOR><(?P<FG>[^,<>]+)?,?(?P<BG>[^<>]+)?>)`
|
||||||
colorise = "\x1b[%sm"
|
colorise = "\x1b[%sm"
|
||||||
transparent = "\x1b[0m\x1b[%s;49m\x1b[7m"
|
transparent = "\x1b[0m\x1b[%s;49m\x1b[7m"
|
||||||
transparentEnd = "\x1b[27m"
|
transparentEnd = "\x1b[27m"
|
||||||
|
|
|
@ -206,6 +206,12 @@ func TestWriteANSIColors(t *testing.T) {
|
||||||
Expected: "\x1b[47m\x1b[30mhome\x1b[0m\x1b[37;49m\x1b[7m / \x1b[27m\x1b[47m\x1b[30mcode\x1b[0m\x1b[37;49m\x1b[7m / \x1b[27m\x1b[47m\x1b[30msrc \x1b[0m",
|
Expected: "\x1b[47m\x1b[30mhome\x1b[0m\x1b[37;49m\x1b[7m / \x1b[27m\x1b[47m\x1b[30mcode\x1b[0m\x1b[37;49m\x1b[7m / \x1b[27m\x1b[47m\x1b[30msrc \x1b[0m",
|
||||||
Colors: &Colors{Foreground: "black", Background: "white"},
|
Colors: &Colors{Foreground: "black", Background: "white"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Case: "Larger than and less than symbols",
|
||||||
|
Input: "<red><</><orange>></><yellow><</>",
|
||||||
|
Expected: "\x1b[47m\x1b[31m<\x1b[30m>\x1b[33m<\x1b[0m",
|
||||||
|
Colors: &Colors{Foreground: "black", Background: "white"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|
Loading…
Reference in a new issue