From 2bdb4bbbdbd93e60296efc97a51854aaf3928140 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 14 Nov 2023 16:52:49 -0600 Subject: [PATCH] Revert "Fix expressions within td exitLiteralIM tracking (#885)" (#889) --- .changeset/stupid-rats-cough.md | 5 ++++ internal/parser.go | 3 +- internal/printer/printer_test.go | 51 +++++++++++++++++++++++++++----- 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 .changeset/stupid-rats-cough.md diff --git a/.changeset/stupid-rats-cough.md b/.changeset/stupid-rats-cough.md new file mode 100644 index 000000000..e72dde879 --- /dev/null +++ b/.changeset/stupid-rats-cough.md @@ -0,0 +1,5 @@ +--- +'@astrojs/compiler': patch +--- + +Revert table related parsing change as it resulted in a regression diff --git a/internal/parser.go b/internal/parser.go index 1236b5671..6f6b3da0b 100644 --- a/internal/parser.go +++ b/internal/parser.go @@ -2176,10 +2176,9 @@ func inRowIM(p *parser) bool { func inCellIM(p *parser) bool { switch p.tok.Type { case StartExpressionToken: - p.exitLiteralIM = getExitLiteralFunc(p) p.addExpression() p.afe = append(p.afe, &scopeMarker) - p.originalIM = inCellIM + p.originalIM = inBodyIM p.im = inExpressionIM return true case EndExpressionToken: diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index d56d0328e..dd3bfce20 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -1959,6 +1959,50 @@ const value = 'test'; code: `${bool && $$render` + BACKTICK + `${$$maybeRenderHead($$result)}` + BACKTICK + `} ${!bool && $$render` + BACKTICK + `` + BACKTICK + `}`, }, }, + { + name: "table simple case", + source: `--- +const content = "lol"; +--- + + + + + + + + { + ( + + + + ) + } +
{content}
1
Hello + + +`, + want: want{ + frontmatter: []string{"", `const content = "lol";`}, + // TODO: This output is INCORRECT, but we're testing a regression + // The trailing text (`Hello`) shouldn't be consumed by the element! + code: ` + ${$$maybeRenderHead($$result)} +
+ + + + ${ + ( + $$render` + BACKTICK + ` + + ` + BACKTICK + ` + ) + } Hello +
${content}
1
+`, + }, + }, { name: "table expressions (no implicit tbody)", source: `--- @@ -1977,13 +2021,6 @@ const items = ["Dog", "Cat", "Platipus"]; code: `${$$maybeRenderHead($$result)}
${title}
Hello
`, }, }, - { - name: "table expression with trailing div", - source: `
{title}
Div
`, - want: want{ - code: `${$$maybeRenderHead($$result)}
${title}
Div
`, - }, - }, { name: "tbody expressions", source: `---