feat: integrate goldmark Pos() for better error reporting

This commit is contained in:
Manuel Rüger
2026-03-25 10:13:37 +01:00
parent cad33f5097
commit 5c59e4704b
3 changed files with 25 additions and 6 deletions

19
renderer/util.go Normal file
View File

@@ -0,0 +1,19 @@
package renderer
// GetLineCol returns the 1-based line and column for a given byte offset in the source.
func GetLineCol(source []byte, offset int) (line, col int) {
line = 1
col = 1
if offset > len(source) {
offset = len(source)
}
for i := 0; i < offset; i++ {
if source[i] == '\n' {
line++
col = 1
} else {
col++
}
}
return line, col
}