mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-21 17:00:44 -06:00
add support for /
escape pattern
This commit is contained in:
parent
e6639f1669
commit
2abf49541d
2 changed files with 6 additions and 3 deletions
|
@ -27,7 +27,7 @@ proc bb*(s: string): string =
|
||||||
if noColor:
|
if noColor:
|
||||||
inc i
|
inc i
|
||||||
continue
|
continue
|
||||||
if pattern == "reset":
|
if pattern in ["reset","/"]:
|
||||||
result.add bbReset
|
result.add bbReset
|
||||||
addReset = false
|
addReset = false
|
||||||
else:
|
else:
|
||||||
|
@ -51,4 +51,4 @@ when isMainModule:
|
||||||
echo bb"[bold red]bold red"
|
echo bb"[bold red]bold red"
|
||||||
echo bb"[bold red]bold red[reset] no more red"
|
echo bb"[bold red]bold red[reset] no more red"
|
||||||
echo bb"[unknown]this text is red no?"
|
echo bb"[unknown]this text is red no?"
|
||||||
echo bb"\[red] <- not a pattern [[red] <- also not a pattern"
|
echo bb"\[red] <- not a pattern "
|
||||||
|
|
|
@ -14,5 +14,8 @@ test "basic":
|
||||||
check "Unknown Style" == bb"[unknown]Unknown Style"
|
check "Unknown Style" == bb"[unknown]Unknown Style"
|
||||||
check "\e[1m\e[31mBold Red Text\e[0m" == bb"[bold red]Bold Red Text"
|
check "\e[1m\e[31mBold Red Text\e[0m" == bb"[bold red]Bold Red Text"
|
||||||
check "\e[1m\e[31mBold Red Text\e[0mPlain Text" == bb"[bold red]Bold Red Text[reset]Plain Text"
|
check "\e[1m\e[31mBold Red Text\e[0mPlain Text" == bb"[bold red]Bold Red Text[reset]Plain Text"
|
||||||
|
check "\e[1mBold\e[0m Not Bold" == bb"[bold]Bold[/] Not Bold"
|
||||||
# not sure how rich handles this
|
# not sure how rich handles this
|
||||||
check "[red] ignored pattern" == bb"[[red] ignored pattern"
|
|
||||||
|
test "escaped":
|
||||||
|
check "[red] ignored pattern" == bb"\[red] ignored pattern"
|
||||||
|
|
Loading…
Reference in a new issue