diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 15:06:42 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 15:06:42 +0200 |
| commit | 21dd71949b05d84ef6ee2f05610ec7254f1086f0 (patch) | |
| tree | 72f94b52067774eed8264c5468b3b8a32b8553ef /mardown/ast_code.go | |
| parent | be4cea404c15979112653cd4d75784aab527f22c (diff) | |
feat(markdown): custom error display
Diffstat (limited to 'mardown/ast_code.go')
| -rw-r--r-- | mardown/ast_code.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mardown/ast_code.go b/mardown/ast_code.go index 7edd6ba..f029df2 100644 --- a/mardown/ast_code.go +++ b/mardown/ast_code.go @@ -25,18 +25,18 @@ type astCode struct { codeType codeType } -func (a *astCode) Eval() (template.HTML, error) { +func (a *astCode) Eval() (template.HTML, *ParseError) { switch a.codeType { case codeOneLine: return template.HTML(fmt.Sprintf("<code>%s</code>", template.HTMLEscapeString(a.content))), nil case codeMultiLine: return template.HTML(fmt.Sprintf("<pre><code>%s</code></pre>", template.HTMLEscapeString(a.content))), nil default: - return "", ErrUnknownCodeType + return "", &ParseError{lxs: lexers{}, internal: ErrUnknownCodeType} } } -func code(lxs *lexers) (*astCode, error) { +func code(lxs *lexers) (*astCode, *ParseError) { tree := new(astCode) current := lxs.Current().Value if len(current) == 3 { @@ -44,13 +44,13 @@ func code(lxs *lexers) (*astCode, error) { } else if len(current) == 1 { tree.codeType = codeOneLine } else { - return nil, ErrInvalidCodeFormat + return nil, &ParseError{lxs: *lxs, internal: ErrInvalidCodeFormat} } started := false for lxs.Next() && lxs.Current().Value != current { if lxs.Current().Type == lexerBreak { if tree.codeType == codeOneLine { - return nil, ErrInvalidCodeFormat + return nil, &ParseError{lxs: *lxs, internal: ErrInvalidCodeFormat} } if !started { started = true |
