- commit
- d201269
- parent
- b224595
- author
- Eric Bower
- date
- 2026-01-16 10:39:06 -0500 EST
feat(prose): added horizontal rule to list parser refactor(prose): replace ul/li with custom list impl
2 files changed,
+75,
-53
+70,
-49
1@@ -1,51 +1,72 @@
2 {{define "list"}}
3-{{$indent := 0}}
4-{{$mod := 0}}
5-<ul style="list-style-type: {{.ListType}};">
6- {{range .Items}}
7- {{if lt $indent .Indent}}
8- <ul>
9- {{else if gt $indent .Indent}}
10-
11- {{$mod = minus $indent .Indent}}
12- {{range $y := intRange 1 $mod}}
13- </li></ul>
14- {{end}}
15-
16- {{else}}
17- </li>
18- {{end}}
19- {{$indent = .Indent}}
20-
21- {{if .IsText}}
22- {{if .Value}}
23- <li>{{.Value}}
24- {{end}}
25- {{end}}
26-
27- {{if .IsURL}}
28- <li><a href="{{.URL}}">{{.Value}}</a>
29- {{end}}
30-
31- {{if .IsImg}}
32- <li><img src="{{.URL}}" alt="{{.Value}}" />
33- {{end}}
34-
35- {{if .IsBlock}}
36- <li><blockquote>{{.Value}}</blockquote>
37- {{end}}
38-
39- {{if .IsHeaderOne}}
40- </ul><h2 class="text-xl font-bold">{{.Value}}</h2><ul style="list-style-type: {{$.ListType}};">
41- {{end}}
42-
43- {{if .IsHeaderTwo}}
44- </ul><h3 class="text-lg font-bold">{{.Value}}</h3><ul style="list-style-type: {{$.ListType}};">
45- {{end}}
46-
47- {{if .IsPre}}
48- <li><pre>{{.Value}}</pre>
49- {{end}}
50- {{end}}
51-</ul>
52+ {{$indent := 0}}
53+ {{$mod := 0}}
54+
55+ <div role="list">
56+ {{range .Items}}
57+ {{if lt $indent .Indent}}
58+ <div role="list">
59+ {{else if gt $indent .Indent}}
60+ {{$mod = minus $indent .Indent}}
61+ {{range $y := intRange 1 $mod}}
62+ </div>
63+ {{end}}
64+ {{end}}
65+
66+ {{$indent = .Indent}}
67+
68+ {{if .IsText}}
69+ <div role="listitem">
70+ <div class="listitem-bullet">•</div>
71+ <div class="listitem-text">{{.Value}}</div>
72+ </div>
73+ {{end}}
74+
75+ {{if .IsURL}}
76+ <div role="listitem">
77+ <div class="listitem-bullet">•</div>
78+ <a class="listitem-text" href="{{.URL}}">{{.Value}}</a>
79+ </div>
80+ {{end}}
81+
82+ {{if .IsImg}}
83+ <div role="listitem">
84+ <div class="listitem-bullet">•</div>
85+ <img class="listeitem-text" src="{{.URL}}" alt="{{.Value}}" />
86+ </div>
87+ {{end}}
88+
89+ {{if .IsBlock}}
90+ <div role="listitem">
91+ <div class="listitem-bullet">•</div>
92+ <blockquote class="listitem-text">{{.Value}}</blockquote>
93+ </div>
94+ {{end}}
95+
96+ {{if .IsPre}}
97+ <div role="listitem">
98+ <div class="listitem-bullet">•</div>
99+ <pre class="listitem-text">{{.Value}}</pre>
100+ </div>
101+ {{end}}
102+
103+ {{if .IsHeaderOne}}
104+ </div>
105+ <h2 class="text-xl font-bold">{{.Value}}</h2>
106+ <div role="list" aria-label="{{.Value}}">
107+ {{end}}
108+
109+ {{if .IsHeaderTwo}}
110+ </div>
111+ <h3 class="text-lg font-bold">{{.Value}}</h3>
112+ <div role="list" aria-label="{{.Value}}">
113+ {{end}}
114+
115+ {{if .IsHr}}
116+ </div>
117+ <hr />
118+ <div role="list" aria-label="{{.Value}}">
119+ {{end}}
120+ {{end}}
121+ </div>
122 {{end}}
1@@ -39,6 +39,7 @@ type ListItem struct {
2 IsHeaderTwo bool
3 IsImg bool
4 IsPre bool
5+ IsHr bool
6 Indent int
7 }
8
9@@ -50,7 +51,6 @@ type ListMetaData struct {
10 Image string
11 ImageCard string
12 Layout string
13- ListType string // https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type
14 PublishAt *time.Time
15 Tags []string
16 Title string
17@@ -69,6 +69,7 @@ var imgToken = "=<"
18 var headerOneToken = "#"
19 var headerTwoToken = "##"
20 var preToken = "```"
21+var hrToken = "=="
22
23 type SplitToken struct {
24 Key string
25@@ -121,8 +122,6 @@ func TokenToMetaField(meta *ListMetaData, token *SplitToken) error {
26 meta.Image = token.Value
27 case "image_card":
28 meta.ImageCard = token.Value
29- case "list_type":
30- meta.ListType = token.Value
31 case "draft":
32 if token.Value == "true" {
33 meta.Hidden = true
34@@ -210,6 +209,9 @@ func parseItem(meta *ListMetaData, li *ListItem, prevItem *ListItem, pre bool, m
35 } else if strings.HasPrefix(li.Value, headerOneToken) {
36 li.IsHeaderOne = true
37 li.Value = strings.Replace(li.Value, headerOneToken, "", 1)
38+ } else if strings.HasPrefix(li.Value, hrToken) {
39+ li.IsHr = true
40+ li.Value = ""
41 } else if reIndent.MatchString(li.Value) {
42 trim := reIndent.ReplaceAllString(li.Value, "")
43 old := len(li.Value)
44@@ -241,7 +243,6 @@ func ListParseText(text string) *ListParsedText {
45 Aliases: []string{},
46 InlineContent: true,
47 Layout: "default",
48- ListType: "disc",
49 PublishAt: &time.Time{},
50 Tags: []string{},
51 Hidden: false,