mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-22 01:10:44 -06:00
feat add helper to style a full string
This commit is contained in:
parent
6b79b0de07
commit
bcc70173b5
2 changed files with 9 additions and 6 deletions
|
@ -122,6 +122,9 @@ proc bb*(s: string): BbString =
|
||||||
next
|
next
|
||||||
result.closeFinalSpan
|
result.closeFinalSpan
|
||||||
|
|
||||||
|
proc bb*(s: string, style: string): BbString =
|
||||||
|
bb("[" & style & "]" & s & "[/" & style & "]")
|
||||||
|
|
||||||
proc `&`*(x: BbString, y: BbString): Bbstring =
|
proc `&`*(x: BbString, y: BbString): Bbstring =
|
||||||
# there is probably a more efficient way to do this
|
# there is probably a more efficient way to do this
|
||||||
bb(x.raw & y.raw)
|
bb(x.raw & y.raw)
|
||||||
|
@ -172,8 +175,3 @@ flags:
|
||||||
quit(QuitSuccess)
|
quit(QuitSuccess)
|
||||||
for arg in strArgs:
|
for arg in strArgs:
|
||||||
echo arg.bb
|
echo arg.bb
|
||||||
|
|
||||||
echo "---------->"
|
|
||||||
echo "\e[31mRed Text\e[0m\nNext Line"
|
|
||||||
echo "[red]Red Text[/red]\nNext Line".bb
|
|
||||||
echo "---------->"
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#
|
#
|
||||||
# To run these tests, simply execute `nimble test`.
|
# To run these tests, simply execute `nimble test`.
|
||||||
|
|
||||||
import unittest
|
import std/[strutils,unittest]
|
||||||
|
|
||||||
import bbansi
|
import bbansi
|
||||||
|
|
||||||
|
@ -40,3 +40,8 @@ suite "basic":
|
||||||
check "[red]RED[/]".bb.len == 3
|
check "[red]RED[/]".bb.len == 3
|
||||||
check bb("[blue]Blue[/]") & " " & bb("[red]Red[/]") == "[blue]Blue[/] [red]Red[/]".bb
|
check bb("[blue]Blue[/]") & " " & bb("[red]Red[/]") == "[blue]Blue[/] [red]Red[/]".bb
|
||||||
check "a plain string" & "[blue] a blue string".bb == "a plain string[blue] a blue string".bb
|
check "a plain string" & "[blue] a blue string".bb == "a plain string[blue] a blue string".bb
|
||||||
|
|
||||||
|
test "style full":
|
||||||
|
check "[red]Red[/red]".bb == bb("Red","red")
|
||||||
|
check "[b][yellow]not yellow[/][/b]".bb == bb("[yellow]not yellow[/]","b")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue