diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-09-30 21:29:07 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-09-30 21:29:07 +0200 |
| commit | c4ba44b1c3e066f98ccc406c15a8c1de170e4709 (patch) | |
| tree | b4974a5acdf11c0aaddb0d5d9526bfa62e35b9c9 /mardown/ast.go | |
| parent | 3d3ccdec245b5a5d1c1f01d0b6972959332c882e (diff) | |
fix(markdown): bad condition in finished lexer and missing return value in ast
Diffstat (limited to 'mardown/ast.go')
| -rw-r--r-- | mardown/ast.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/mardown/ast.go b/mardown/ast.go index d9d2b1d..298b313 100644 --- a/mardown/ast.go +++ b/mardown/ast.go @@ -1,6 +1,7 @@ package mardown import ( + "encoding/json" "errors" "fmt" "html/template" @@ -17,7 +18,20 @@ type tree struct { } func (t *tree) Eval() (template.HTML, error) { - return "", nil + var content template.HTML + for _, c := range t.blocks { + ct, err := c.Eval() + if err != nil { + return "", err + } + content += ct + } + return content, nil +} + +func (t *tree) String() string { + b, _ := json.MarshalIndent(t, "", " ") + return string(b) } func ast(lxs *lexers) (*tree, error) { @@ -29,7 +43,9 @@ func ast(lxs *lexers) (*tree, error) { return nil, err } tr.blocks = append(tr.blocks, b) - newLine = lxs.Current().Type == lexerBreak + if !lxs.Finished() { + newLine = lxs.Current().Type == lexerBreak + } } return tr, nil } |
