Skip to content

Commit

Permalink
Improve error message for unclosed shortcode with inner content
Browse files Browse the repository at this point in the history
  • Loading branch information
deining authored Mar 10, 2023
1 parent 34a86e1 commit 9818724
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hugolib/shortcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ Loop:
case currItem.IsDone():
if !currItem.IsError() {
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
Expand Down
2 changes: 1 addition & 1 deletion hugolib/shortcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,5 +1274,5 @@ Inner: {{ .Get 0 }}: {{ len .Inner }}
).BuildE()

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`)
}

0 comments on commit 9818724

Please sign in to comment.