From 94dceb4f7c1740de9215b36ec183f93ca4337ee7 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 2 Oct 2025 19:52:38 +0200 Subject: style(markdown): fix typo in package name --- mardown/ast_code.go | 66 ----------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 mardown/ast_code.go (limited to 'mardown/ast_code.go') diff --git a/mardown/ast_code.go b/mardown/ast_code.go deleted file mode 100644 index f029df2..0000000 --- a/mardown/ast_code.go +++ /dev/null @@ -1,66 +0,0 @@ -package mardown - -import ( - "errors" - "fmt" - "html/template" -) - -var ( - ErrUnknownCodeType = errors.New("unkown code type") - ErrInvalidCodeFormat = errors.New("invalid code format") - ErrInvalidCodeBlockPosition = errors.Join(ErrInvalidParagraph, errors.New("invalid code block position")) -) - -type codeType uint - -const ( - codeOneLine codeType = 1 - codeMultiLine codeType = 2 -) - -type astCode struct { - content string - before string - codeType codeType -} - -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 "", &ParseError{lxs: lexers{}, internal: ErrUnknownCodeType} - } -} - -func code(lxs *lexers) (*astCode, *ParseError) { - tree := new(astCode) - current := lxs.Current().Value - if len(current) == 3 { - tree.codeType = codeMultiLine - } else if len(current) == 1 { - tree.codeType = codeOneLine - } else { - 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, &ParseError{lxs: *lxs, internal: ErrInvalidCodeFormat} - } - if !started { - started = true - } - } - if started || tree.codeType == codeOneLine { - tree.content += lxs.Current().Value - } else { - tree.before += lxs.Current().Value - } - } - return tree, nil -} -- cgit v1.2.3