mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-11-16 06:28:32 -06:00
add another escape pattern
This commit is contained in:
parent
c1738c9504
commit
653b51184f
2 changed files with 3 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue