From b5d7d7816e9b7c5e3b2598e3a1dc322580aec65b Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 2 Oct 2025 15:25:48 +0200 Subject: feat(markdown): better error indicator --- mardown/error.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'mardown/error.go') 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) } -- cgit v1.2.3