Improve error message for unclosed shortcode with inner content

This commit is contained in:
Andreas Deininger 2023-03-10 18:41:17 +01:00 committed by GitHub
parent 34a86e13f6
commit 9818724b5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -689,7 +689,7 @@ Loop:
case currItem.IsDone(): case currItem.IsDone():
if !currItem.IsError() { if !currItem.IsError() {
if !closed && sc.needsInner() { if !closed && sc.needsInner() {
return sc, fmt.Errorf("%s: unclosed shortcode %q", errorPrefix, sc.name) return sc, fmt.Errorf("%s: shortcode %q must be closed or self-closed", errorPrefix, sc.name)
} }
} }
// handled by caller // handled by caller

View file

@ -1274,5 +1274,5 @@ Inner: {{ .Get 0 }}: {{ len .Inner }}
).BuildE() ).BuildE()
b.Assert(err, qt.Not(qt.IsNil)) b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, `p1.md:5:1": failed to extract shortcode: unclosed shortcode "sc"`) b.Assert(err.Error(), qt.Contains, `p1.md:5:1": failed to extract shortcode: shortcode "sc" must be closed or self-closed`)
} }