]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
parser/pageparser: Fix shortcode nesting regression
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 16 Oct 2025 14:42:49 +0000 (16:42 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 16 Oct 2025 16:50:02 +0000 (18:50 +0200)
This reverts commit a133393edab5aca89b60fae44e445bc527095c6a.

While that commit fixed a bug, it introduced a worse one.

Closes #14054

parser/pageparser/pagelexer_shortcode.go
parser/pageparser/pageparser_shortcode_test.go

index 3a656263a9b604a2a53f7a8c29441f1284803a1b..5d3c55eeb8570c5fad2bd30f977cafaf2f121895 100644 (file)
@@ -263,12 +263,11 @@ Loop:
                                }
                                l.openShortcodes[word] = false
                                lookForEnd = true
-                       } else {
-                               l.openShortcodes[word] = true
                        }
 
                        l.closingState = 0
                        l.currShortcodeName = word.Value()
+                       l.openShortcodes[word] = true
                        l.elementStepNum++
                        if l.isInline {
                                l.emit(tScNameInline)
index 7d14b15e85d137f0ebb63f73730569bc71f3f486..29626b6adfeade0370f36c6854a18fd57581b9e7 100644 (file)
@@ -27,7 +27,6 @@ var (
        tstRightMD   = nti(tRightDelimScWithMarkup, "%}}")
        tstSCClose   = nti(tScClose, "/")
        tstSC1       = nti(tScName, "sc1")
-       tstSCAnother = nti(tScName, "another")
        tstSC1Inline = nti(tScNameInline, "sc1.inline")
        tstSC2Inline = nti(tScNameInline, "sc2.inline")
        tstSC2       = nti(tScName, "sc2")
@@ -75,10 +74,6 @@ var shortCodeLexerTests = []lexerTest{
                tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose,
                nti(tError, "closing tag for shortcode 'another' does not match start tag"),
        }, nil},
-       {"close wrong, repeated", `{{< sc1 >}}{{< another >}}{{< /another >}}{{< /another >}}`, []typeText{
-               tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCAnother, tstRightNoMD, tstLeftNoMD, tstSCClose, tstSCAnother, tstRightNoMD, tstLeftNoMD, tstSCClose,
-               nti(tError, "closing tag for shortcode 'another' does not match start tag"),
-       }, nil},
        {"close, but no open, more", `{{< sc1 >}}{{< /sc1 >}}{{< /another >}}`, []typeText{
                tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose,
                nti(tError, "closing tag for shortcode 'another' does not match start tag"),