diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 15:14:01 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 15:14:01 +0200 |
| commit | 4aafb0de729aaf9c8bc2658b4992ac6a3536d471 (patch) | |
| tree | 3e0907c21847a944c1699ab7007237291c5927e1 /mardown | |
| parent | 21dd71949b05d84ef6ee2f05610ec7254f1086f0 (diff) | |
fix(markdown): no error on bad code block pos
Diffstat (limited to 'mardown')
| -rw-r--r-- | mardown/ast_paragraph.go | 3 | ||||
| -rw-r--r-- | mardown/error.go | 15 |
2 files changed, 10 insertions, 8 deletions
diff --git a/mardown/ast_paragraph.go b/mardown/ast_paragraph.go index 15d9bb8..21dc1ef 100644 --- a/mardown/ast_paragraph.go +++ b/mardown/ast_paragraph.go @@ -76,6 +76,9 @@ func paragraph(lxs *lexers, oneLine bool) (*astParagraph, *ParseError) { tree.content = append(tree.content, ext) } case lexerCode: + if len(lxs.Current().Value) > 1 { + return nil, &ParseError{lxs: *lxs, internal: ErrInvalidCodeBlockPosition} + } n = 0 b, err := code(lxs) if err != nil { diff --git a/mardown/error.go b/mardown/error.go index f85dfbb..bdcd9df 100644 --- a/mardown/error.go +++ b/mardown/error.go @@ -24,14 +24,13 @@ func (e *ParseError) Pretty() string { ind := "" for lxs.Next() && lxs.Current().Type != lexerBreak { contxt += lxs.Current().Value - if lxs.current < current { - if lxs.current == current-2 { - ind += "^" - } else { - for range len(lxs.Current().Value) { - ind += "~" - } - } + ln := len(lxs.Current().Value) + if lxs.current == current-1 { + ln-- + ind += "^" + } + for range ln { + ind += "~" } } return fmt.Sprintf("%v\n\n%s\n%s", e, contxt, ind) |
