From 21dd71949b05d84ef6ee2f05610ec7254f1086f0 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 2 Oct 2025 15:06:42 +0200 Subject: feat(markdown): custom error display --- mardown/ast_code.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'mardown/ast_code.go') 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("%s", template.HTMLEscapeString(a.content))), nil case codeMultiLine: return template.HTML(fmt.Sprintf("
%s
", 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 -- cgit v1.2.3