From dbf0ea2dd53b88a26ab7e3cc12a06344022d57ec Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 8 Apr 2023 21:30:11 +0200 Subject: Move title parsing to new markup.go file The new recipe markup which replaces Markdown will need an own file to be implemented. --- markup.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 markup.go (limited to 'markup.go') diff --git a/markup.go b/markup.go new file mode 100644 index 0000000..c0a6d45 --- /dev/null +++ b/markup.go @@ -0,0 +1,18 @@ +package main + +import ( + "bufio" + "strings" +) + +func titleFromMarkup(markup string) string { + scanner := bufio.NewScanner(strings.NewReader(markup)) + for scanner.Scan() { + line := scanner.Text() + cut, found := strings.CutPrefix(line, "# ") + if found { + return cut + } + } + return "no title detected" +} -- cgit v1.2.3-70-g09d2