add another escape pattern

This commit is contained in:
Daylin Morgan 2024-09-24 11:53:44 -05:00
parent c1738c9504
commit 653b51184f
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 3 additions and 2 deletions

View file

@ -86,7 +86,7 @@ proc bb*(s: string): BbString =
while i < s.len:
case s[i]
of '\\':
if i < s.len and s[i + 1] == '[':
if i < s.len and (s[i + 1] == '[' or s[i+1] == '\\'):
inc i
next
of '[':
@ -163,7 +163,7 @@ proc `&`*(x: BbString, y: BbString): Bbstring =
bb(x.raw & y.raw)
proc bbEscape*(s: string): string {.inline.} =
s.replace("[", "[[")
s.replace("[", "[[").replace("\\", "\\\\")
proc bbEcho*(args: varargs[string, `$`]) {.sideEffect.} =
for x in args:

View file

@ -28,6 +28,7 @@ suite "basic":
test "escaped":
bbCheck "[[red] ignored pattern", "[red] ignored pattern"
bbCheck "\\[red] ignored pattern","[red] ignored pattern"
test "newlines":
bbCheck "[red]Red Text[/]\nNext Line", "\e[38;5;1mRed Text\e[0m\nNext Line"