From f8d9a8363fb7e3c5ff2f788e9e267b893f4af955 Mon Sep 17 00:00:00 2001 From: ddddddO Date: Sun, 12 Feb 2023 20:00:31 +0900 Subject: [PATCH] fix --- input_spliter.go | 11 ++++++++++- markdown/parser.go | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/input_spliter.go b/input_spliter.go index cfabf14..add6e1c 100644 --- a/input_spliter.go +++ b/input_spliter.go @@ -6,6 +6,8 @@ import ( "fmt" "io" "strings" + + md "github.com/ddddddO/gtree/markdown" ) func split(ctx context.Context, r io.Reader) (<-chan string, <-chan error) { @@ -27,7 +29,7 @@ func split(ctx context.Context, r io.Reader) (<-chan string, <-chan error) { block := "" for sc.Scan() { l := sc.Text() - if strings.HasPrefix(l, "-") { + if isRootBlockBeginning(l) { if len(block) != 0 { blockc <- block } @@ -47,3 +49,10 @@ func split(ctx context.Context, r io.Reader) (<-chan string, <-chan error) { return blockc, errc } + +func isRootBlockBeginning(l string) bool { + if len(l) == 0 { + return false + } + return strings.ContainsRune(md.ListSymbolsLine, rune(l[0])) +} diff --git a/markdown/parser.go b/markdown/parser.go index 8f1d261..0eba0a4 100644 --- a/markdown/parser.go +++ b/markdown/parser.go @@ -27,6 +27,8 @@ func NewParser(spaces int) *Parser { } } +const ListSymbolsLine = "#-*+" // TODO: もっといいやり方ないか + const ( sharp = "#"