fix style insensitivity
Some checks failed
GitHub Pages / build (push) Has been cancelled
GitHub Pages / deploy (push) Has been cancelled

This commit is contained in:
Daylin Morgan 2024-10-02 00:23:40 -05:00
parent 773f393e3d
commit 7e82f7ba5a
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 2 additions and 2 deletions

View file

@ -39,7 +39,7 @@ let bbMode* = checkColorSupport()
let colorSystem* = checkColorSystem() let colorSystem* = checkColorSystem()
func firstCapital(s: string): string = s.toLowerAscii().capitalizeAscii() func firstCapital(s: string): string = s.toLowerAscii().capitalizeAscii()
func normalizeStyle(style: string): string = style.replace("_","").capitalizeAscii() func normalizeStyle(style: string): string = style.replace("_","").toLowerAscii().capitalizeAscii()
func isHex(s: string): bool = (s.startswith "#") and (s.len == 7) func isHex(s: string): bool = (s.startswith "#") and (s.len == 7)
func toCode(style: BbStyle): string = $ord(style) func toCode(style: BbStyle): string = $ord(style)
@ -77,7 +77,6 @@ proc toAnsiCode*(s: string): string =
styles = s.splitWhitespace() styles = s.splitWhitespace()
for style in styles: for style in styles:
let normalizedStyle = normalizeStyle(style) let normalizedStyle = normalizeStyle(style)
if normalizedStyle in ["B", "I", "U"]: if normalizedStyle in ["B", "I", "U"]:
codes.add parseEnum[BbStyleAbbr](normalizedStyle).toCode() codes.add parseEnum[BbStyleAbbr](normalizedStyle).toCode()
elif normalizedStyle in BbStyleNames: elif normalizedStyle in BbStyleNames:

View file

@ -47,6 +47,7 @@ suite "basic":
test "style insensitive": test "style insensitive":
bbCheck "[red]no case sensitivity[/RED]", "\e[38;5;1mno case sensitivity\e[0m" bbCheck "[red]no case sensitivity[/RED]", "\e[38;5;1mno case sensitivity\e[0m"
bbCheck "[bright_red]should be BrightRed[/]", "\e[38;5;9mshould be BrightRed\e[0m" bbCheck "[bright_red]should be BrightRed[/]", "\e[38;5;9mshould be BrightRed\e[0m"
bbCheck "[BrightRed]should be BrightRed[/]", "\e[38;5;9mshould be BrightRed\e[0m"
test "style full": test "style full":
check "[red]Red[/red]".bb == bb("Red", "red") check "[red]Red[/red]".bb == bb("Red", "red")