diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-12-13 17:15:47 +0000 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-12-13 17:15:47 +0000 |
| commit | 62fa3f77e8215fdaaf72ddb9df4162e0d65148da (patch) | |
| tree | dbf20dca933996cf253fe2d110d8381b0c407b2d /markdown/ast_paragraph.go | |
| parent | ae297bbd117835304b298e7d8a2f914111940e77 (diff) | |
| parent | 48311424ba2eaac254864c008b6d18e8510f827d (diff) | |
Merge pull request '[Refactor] Replace manual DOM manipulation in markdown by cleaner one' (#2) from refactor/mardown-dom into main
Reviewed-on: https://git.anhgelus.world/anhgelus/small-web/pulls/2
Diffstat (limited to 'markdown/ast_paragraph.go')
| -rw-r--r-- | markdown/ast_paragraph.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/markdown/ast_paragraph.go b/markdown/ast_paragraph.go index a6417e2..eddba0a 100644 --- a/markdown/ast_paragraph.go +++ b/markdown/ast_paragraph.go @@ -2,8 +2,10 @@ package markdown import ( "errors" - "fmt" "html/template" + "strings" + + "git.anhgelus.world/anhgelus/small-web/dom" ) var ( @@ -27,7 +29,9 @@ func (a *astParagraph) Eval(opt *Option) (template.HTML, *ParseError) { if a.oneLine { return content, nil } - return template.HTML(fmt.Sprintf("<p>%s</p>", trimSpace(content))), nil + return dom.NewParagraph( + template.HTML(strings.TrimSpace(string(content))), + ).Render(), nil } func paragraph(lxs *lexers, oneLine bool) (*astParagraph, *ParseError) { @@ -49,7 +53,7 @@ func paragraph(lxs *lexers, oneLine bool) (*astParagraph, *ParseError) { return tree, nil } tree.content = append(tree.content, astLiteral(lxs.Current().Value)) - case lexerLiteral, lexerHeader: + case lexerLiteral, lexerHeading: s := lxs.Current().Value // replace line break by space if n > 0 && len(tree.content) != 0 { |
