diff options
author | xengineering <me@xengineering.eu> | 2023-04-22 19:29:36 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-04-22 19:29:36 +0200 |
commit | 0b2ae5cbbee6637d5afe0a891f203f7eb7502c1e (patch) | |
tree | 970f13d834af24d247d8365007256f4203f82994 | |
parent | 7bb54a56e993723b2867efbafddd1b9abfebcd9e (diff) | |
download | ceres-0b2ae5cbbee6637d5afe0a891f203f7eb7502c1e.tar ceres-0b2ae5cbbee6637d5afe0a891f203f7eb7502c1e.tar.zst ceres-0b2ae5cbbee6637d5afe0a891f203f7eb7502c1e.zip |
Remove markup.go
Markup parsing is not needed anymore since recipes are now modeled as
JSON text.
-rw-r--r-- | markup.go | 79 |
1 files changed, 0 insertions, 79 deletions
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</ul>" - } - if line == "" { - continue - } - switch lineType { - case HeadingLine: - retval += fmt.Sprintf("\n<h3>%s</h3>", line) - case UnorderedListItem: - if lastType != UnorderedListItem { - retval += "\n<ul>" - } - item := strings.TrimPrefix(line, "*") - retval += fmt.Sprintf("\n\t<li>%s</li>", item) - default: - retval += fmt.Sprintf("\n<p>%s</p>", line) - } - lastType = lineType - } - - if lineType == UnorderedListItem { - retval += "\n</ul>" - } - - retval = strings.TrimPrefix(retval, "\n") - - return retval -} |