From 0b2ae5cbbee6637d5afe0a891f203f7eb7502c1e Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 22 Apr 2023 19:29:36 +0200 Subject: Remove markup.go Markup parsing is not needed anymore since recipes are now modeled as JSON text. --- markup.go | 79 --------------------------------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 markup.go (limited to 'markup.go') diff --git a/markup.go b/markup.go deleted file mode 100644 index b86d685..0000000 --- a/markup.go +++ /dev/null @@ -1,79 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "strings" -) - -type Markup []byte -type LineType int8 - -const ( - TextLine LineType = iota - HeadingLine - UnorderedListItem -) - -func getLineType(line string) LineType { - if strings.HasPrefix(line, "#") { - return HeadingLine - } - if strings.HasPrefix(line, "* ") { - return UnorderedListItem - } - return TextLine -} - -func (m Markup) title() string { - text := string(m) - scanner := bufio.NewScanner(strings.NewReader(text)) - for scanner.Scan() { - line := scanner.Text() - if strings.HasPrefix(line, "# ") { - return strings.TrimPrefix(line, "# ") - } - } - return "No title dtected" -} - -func (m Markup) html() string { - retval := "" - var line string - var lineType LineType - var lastType LineType = -1 - - text := string(m) - scanner := bufio.NewScanner(strings.NewReader(text)) - for scanner.Scan() { - line = scanner.Text() - lineType = getLineType(line) - if lineType != UnorderedListItem && lastType == UnorderedListItem { - retval += "\n" - } - if line == "" { - continue - } - switch lineType { - case HeadingLine: - retval += fmt.Sprintf("\n

%s

", line) - case UnorderedListItem: - if lastType != UnorderedListItem { - retval += "\n" - } - - retval = strings.TrimPrefix(retval, "\n") - - return retval -} -- cgit v1.2.3-70-g09d2