mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 21:22:12 -05:00
parent
96689a5c31
commit
14c35c8a56
2 changed files with 4 additions and 5 deletions
|
@ -312,7 +312,7 @@ func lexShortcodeLeftDelim(l *pagelexer) stateFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func lexShortcodeComment(l *pagelexer) stateFunc {
|
func lexShortcodeComment(l *pagelexer) stateFunc {
|
||||||
posRightComment := strings.Index(l.input[l.pos:], rightComment)
|
posRightComment := strings.Index(l.input[l.pos:], rightComment+l.currentRightShortcodeDelim())
|
||||||
if posRightComment <= 1 {
|
if posRightComment <= 1 {
|
||||||
return l.errorf("comment must be closed")
|
return l.errorf("comment must be closed")
|
||||||
}
|
}
|
||||||
|
@ -324,9 +324,6 @@ func lexShortcodeComment(l *pagelexer) stateFunc {
|
||||||
l.emit(tText)
|
l.emit(tText)
|
||||||
l.pos += pos(len(rightComment))
|
l.pos += pos(len(rightComment))
|
||||||
l.ignore()
|
l.ignore()
|
||||||
if !strings.HasPrefix(l.input[l.pos:], l.currentRightShortcodeDelim()) {
|
|
||||||
return l.errorf("comment ends before the right shortcode delimiter")
|
|
||||||
}
|
|
||||||
l.pos += pos(len(l.currentRightShortcodeDelim()))
|
l.pos += pos(len(l.currentRightShortcodeDelim()))
|
||||||
l.emit(tText)
|
l.emit(tText)
|
||||||
return lexTextOutsideShortcodes
|
return lexTextOutsideShortcodes
|
||||||
|
|
|
@ -145,10 +145,12 @@ var shortCodeLexerTests = []shortCodeLexerTest{
|
||||||
{tError, 0, "got named parameter 'param2'. Cannot mix named and positional parameters"}}},
|
{tError, 0, "got named parameter 'param2'. Cannot mix named and positional parameters"}}},
|
||||||
{"commented out", `{{</* sc1 */>}}`, []item{
|
{"commented out", `{{</* sc1 */>}}`, []item{
|
||||||
{tText, 0, "{{<"}, {tText, 0, " sc1 "}, {tText, 0, ">}}"}, tstEOF}},
|
{tText, 0, "{{<"}, {tText, 0, " sc1 "}, {tText, 0, ">}}"}, tstEOF}},
|
||||||
|
{"commented out, with asterisk inside", `{{</* sc1 "**/*.pdf" */>}}`, []item{
|
||||||
|
{tText, 0, "{{<"}, {tText, 0, " sc1 \"**/*.pdf\" "}, {tText, 0, ">}}"}, tstEOF}},
|
||||||
{"commented out, missing close", `{{</* sc1 >}}`, []item{
|
{"commented out, missing close", `{{</* sc1 >}}`, []item{
|
||||||
{tError, 0, "comment must be closed"}}},
|
{tError, 0, "comment must be closed"}}},
|
||||||
{"commented out, misplaced close", `{{</* sc1 >}}*/`, []item{
|
{"commented out, misplaced close", `{{</* sc1 >}}*/`, []item{
|
||||||
{tText, 0, "{{<"}, {tText, 0, " sc1 >}}"}, {tError, 0, "comment ends before the right shortcode delimiter"}}},
|
{tError, 0, "comment must be closed"}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShortcodeLexer(t *testing.T) {
|
func TestShortcodeLexer(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue