aboutsummaryrefslogtreecommitdiff
path: root/mardown/ast_list.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-10-02 19:52:38 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2025-10-02 19:52:38 +0200
commit94dceb4f7c1740de9215b36ec183f93ca4337ee7 (patch)
tree5ad184efb0b74dd3aa4da7585f88a3e3f6cb4ecc /mardown/ast_list.go
parent8b249c9ce8bd1c351daf80c6c9b095fb1bccafe2 (diff)
style(markdown): fix typo in package name
Diffstat (limited to 'mardown/ast_list.go')
-rw-r--r--mardown/ast_list.go79
1 files changed, 0 insertions, 79 deletions
diff --git a/mardown/ast_list.go b/mardown/ast_list.go
deleted file mode 100644
index 39f0178..0000000
--- a/mardown/ast_list.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package mardown
-
-import (
- "fmt"
- "html/template"
- "regexp"
-)
-
-var regexOrdered = regexp.MustCompile(`\d+\.`)
-
-type listType string
-
-const (
- listUnordered listType = "ul"
- listOrdered listType = "ol"
-)
-
-type astList struct {
- tag listType
- content []*astParagraph
-}
-
-func (a *astList) Eval() (template.HTML, *ParseError) {
- var content template.HTML
- for _, c := range a.content {
- ct, err := c.Eval()
- if err != nil {
- return "", err
- }
- content += template.HTML(fmt.Sprintf("<li>%s</li>", trimSpace(ct)))
- }
- return template.HTML(fmt.Sprintf("<%s>%s</%s>", a.tag, content, a.tag)), nil
-}
-
-func list(lxs *lexers) (block, *ParseError) {
- tree := new(astList)
- tree.tag = detectListType(lxs.Current().Value)
- if len(tree.tag) == 0 {
- return paragraph(lxs, false)
- }
- n := 0
- for lxs.Next() && n < 2 {
- switch lxs.Current().Type {
- case lexerBreak:
- n += len(lxs.Current().Value)
- case lexerList:
- n = 0
- tp := detectListType(lxs.Current().Value)
- if tp != tree.tag {
- lxs.Before() // because we dit not use it
- return tree, nil
- }
- default:
- n = 0
- c, err := paragraph(lxs, true)
- if err != nil {
- return nil, err
- }
- lxs.Before() // because we must parse the last char
- tree.content = append(tree.content, c)
- }
- }
- lxs.Before() // because we did not use it
- return tree, nil
-}
-
-func detectListType(val string) listType {
- first := []rune(val)[0]
- if first == '-' || first == '*' {
- if len(val) > 1 {
- return ""
- }
- return listUnordered
- }
- if !regexOrdered.MatchString(val) {
- return ""
- }
- return listOrdered
-}