aboutsummaryrefslogtreecommitdiff
path: root/mardown/ast_list_test.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-10-01 22:32:41 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2025-10-01 22:32:48 +0200
commitce480a18b865acc21eb6c36dea8fc27b08061603 (patch)
treef17625ac33ebde39f7c3188798b6a8fa9c9311eb /mardown/ast_list_test.go
parent1ce93d83321c751265e4207ebf6dc73a280482c6 (diff)
feat(markdown): support list
Diffstat (limited to 'mardown/ast_list_test.go')
-rw-r--r--mardown/ast_list_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/mardown/ast_list_test.go b/mardown/ast_list_test.go
new file mode 100644
index 0000000..895e439
--- /dev/null
+++ b/mardown/ast_list_test.go
@@ -0,0 +1,42 @@
+package mardown
+
+import (
+ "strings"
+ "testing"
+)
+
+var rw = `
+- item A
+- item B
+
+1. item 1
+2. item 2
+`
+
+var expected = `
+<ul>
+<li>item A</li>
+<li>item B</li>
+</ul>
+<ol>
+<li>item 1</li>
+<li>item 2</li>
+</ol>
+`
+
+func TestList(t *testing.T) {
+ lxs := lex(rw)
+ tree, err := ast(lxs)
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := tree.Eval()
+ if err != nil {
+ t.Fatal(err)
+ }
+ exp := strings.ReplaceAll(expected, "\n", "")
+ if string(got) != exp {
+ t.Errorf("invalid value, got %s", got)
+ t.Logf("expected %s", exp)
+ }
+}