From 70b8f7489a0da34cc625e9af848a8e052ddec33e Mon Sep 17 00:00:00 2001 From: Andrew Arrow Date: Mon, 7 Nov 2022 04:24:12 -0800 Subject: [PATCH] testing easy case of no style --- style_parser.go | 6 ++++++ style_parser_test.go | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/style_parser.go b/style_parser.go index 2004b84..8cc26b8 100644 --- a/style_parser.go +++ b/style_parser.go @@ -89,6 +89,12 @@ func processToken(token, previous string) (string, string) { func PrepareStyles(s string) []PreparedStyle { items := []PreparedStyle{} + tokens := strings.Split(s, "](") + if len(tokens) == 1 { + // easy case, not styled string + ps := PreparedStyle{s, ""} + return []PreparedStyle{ps} + } return items } diff --git a/style_parser_test.go b/style_parser_test.go index c89eaf4..c71e473 100644 --- a/style_parser_test.go +++ b/style_parser_test.go @@ -6,7 +6,11 @@ import ( ) func TestPrepareStyles(t *testing.T) { - items := PrepareStyles("test [blue](fg:blue,bg:white,mod:bold) and [red](fg:red)") + items := PrepareStyles("test no style") + if len(items) != 1 { + t.Fatal("wrong length", len(items)) + } + items = PrepareStyles("test [blue](fg:blue,bg:white,mod:bold) and [red](fg:red)") if len(items) != 4 { t.Fatal("wrong length", len(items)) }