diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 15:25:48 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 15:25:48 +0200 |
| commit | b5d7d7816e9b7c5e3b2598e3a1dc322580aec65b (patch) | |
| tree | 60da32b330b6ad4ab6cedbf246d0e8e4002d1d77 /mardown/error.go | |
| parent | 4aafb0de729aaf9c8bc2658b4992ac6a3536d471 (diff) | |
feat(markdown): better error indicator
Diffstat (limited to 'mardown/error.go')
| -rw-r--r-- | mardown/error.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/mardown/error.go b/mardown/error.go index bdcd9df..ad279fe 100644 --- a/mardown/error.go +++ b/mardown/error.go @@ -24,14 +24,20 @@ func (e *ParseError) Pretty() string { ind := "" for lxs.Next() && lxs.Current().Type != lexerBreak { contxt += lxs.Current().Value - ln := len(lxs.Current().Value) - if lxs.current == current-1 { - ln-- - ind += "^" - } - for range ln { - ind += "~" + if lxs.current <= current { + ch := "~" + if lxs.current == current { + ch = "^" + } + for range len(lxs.Current().Value) { + ind += ch + } } } + if lxs.current == current { + runes := []rune(ind) + runes[len(runes)-1] = '^' + ind = string(runes) + } return fmt.Sprintf("%v\n\n%s\n%s", e, contxt, ind) } |
