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_header.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_header.go')
| -rw-r--r-- | markdown/ast_header.go | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/markdown/ast_header.go b/markdown/ast_header.go deleted file mode 100644 index 716a4a6..0000000 --- a/markdown/ast_header.go +++ /dev/null @@ -1,39 +0,0 @@ -package markdown - -import ( - "errors" - "fmt" - "html/template" -) - -var ErrInvalidHeader = errors.New("invalid header") - -type astHeader struct { - level uint - content *astParagraph -} - -func (a *astHeader) Eval(opt *Option) (template.HTML, *ParseError) { - if a.level > 6 { - return "", &ParseError{lxs: lexers{}, internal: ErrInvalidCodeFormat} - } - var content template.HTML - content, err := a.content.Eval(opt) - if err != nil { - return "", err - } - return template.HTML(fmt.Sprintf("<h%d>%s</h%d>", a.level, trimSpace(content), a.level)), nil -} - -func header(lxs *lexers) (*astHeader, *ParseError) { - b := &astHeader{level: uint(len(lxs.Current().Value))} - if !lxs.Next() { - return nil, &ParseError{lxs: *lxs, internal: ErrInvalidHeader} - } - var err *ParseError - b.content, err = paragraph(lxs, true) - if err != nil { - return nil, err - } - return b, nil -} |
