aboutsummaryrefslogtreecommitdiff
path: root/markdown/ast_quote.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-12-13 18:09:40 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2025-12-13 18:09:48 +0100
commitaea07c141b3a2448ea367ad80ad5e12d04a78df7 (patch)
tree67031a6cfe4c5b42f9527410045f4d3793f32946 /markdown/ast_quote.go
parentd695b39edf898e056a8de3724a020f15754fcea9 (diff)
refactor(markdown): use new dom package to create html
Diffstat (limited to 'markdown/ast_quote.go')
-rw-r--r--markdown/ast_quote.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/markdown/ast_quote.go b/markdown/ast_quote.go
index fa3a878..96669c5 100644
--- a/markdown/ast_quote.go
+++ b/markdown/ast_quote.go
@@ -1,9 +1,10 @@
package markdown
import (
- "fmt"
"html/template"
"strings"
+
+ "git.anhgelus.world/anhgelus/small-web/dom"
)
type astQuote struct {
@@ -12,15 +13,18 @@ type astQuote struct {
}
func (a *astQuote) Eval(opt *Option) (template.HTML, *ParseError) {
- var quote template.HTML
+ var quoteContent template.HTML
for _, c := range a.quote {
ct, err := c.Eval(opt)
if err != nil {
return "", err
}
- quote += ct
+ quoteContent += ct
}
- quote = template.HTML(fmt.Sprintf("<blockquote>%s</blockquote>", trimSpace(quote)))
+ blockquote := dom.NewLiteralContentElement(
+ "blockquote",
+ template.HTML(strings.TrimSpace(string(quoteContent))),
+ )
var source template.HTML
for _, c := range a.source {
ct, err := c.Eval(opt)
@@ -30,10 +34,13 @@ func (a *astQuote) Eval(opt *Option) (template.HTML, *ParseError) {
source += ct
}
source = template.HTML(strings.TrimSpace(string(source)))
+ quote := dom.NewContentElement("div", make([]dom.Element, 0))
+ quote.ClassList().Add("quote")
+ quote.Contents = append(quote.Contents, blockquote)
if len(source) > 0 {
- return template.HTML(fmt.Sprintf(`<div class="quote">%s<p>%s</p></div>`, quote, source)), nil
+ quote.Contents = append(quote.Contents, dom.NewParagraph(source))
}
- return template.HTML(fmt.Sprintf(`<div class="quote">%s</div>`, quote)), nil
+ return quote.Render(), nil
}
func quote(lxs *lexers) (*astQuote, *ParseError) {