olova 2.0.73 → 2.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compiler.js CHANGED
@@ -1504,11 +1504,41 @@ function jsxToTemplateHtml(node) {
1504
1504
  return "";
1505
1505
  }
1506
1506
  function replaceTemplateExpressions(input, replacer) {
1507
+ const rawTextTags = /* @__PURE__ */ new Set(["pre", "code", "textarea", "kbd", "samp"]);
1507
1508
  let output = "";
1508
1509
  let index = 0;
1509
1510
  let inTag = false;
1510
1511
  let tagQuote = null;
1511
1512
  let tagBraceDepth = 0;
1513
+ let tagStart = -1;
1514
+ const rawTextStack = [];
1515
+ const updateRawTextStack = (rawTag) => {
1516
+ const trimmed = rawTag.trim();
1517
+ if (!trimmed || trimmed.startsWith("!") || trimmed.startsWith("?")) {
1518
+ return;
1519
+ }
1520
+ const closing = trimmed.startsWith("/");
1521
+ const content = closing ? trimmed.slice(1).trim() : trimmed;
1522
+ const selfClosing = /\/\s*$/.test(content);
1523
+ const nameMatch = content.match(/^([A-Za-z][A-Za-z0-9:-]*)/);
1524
+ if (!nameMatch) {
1525
+ return;
1526
+ }
1527
+ const tagName = nameMatch[1].toLowerCase();
1528
+ if (!rawTextTags.has(tagName)) {
1529
+ return;
1530
+ }
1531
+ if (closing) {
1532
+ const stackIndex = rawTextStack.lastIndexOf(tagName);
1533
+ if (stackIndex >= 0) {
1534
+ rawTextStack.splice(stackIndex, 1);
1535
+ }
1536
+ return;
1537
+ }
1538
+ if (!selfClosing) {
1539
+ rawTextStack.push(tagName);
1540
+ }
1541
+ };
1512
1542
  while (index < input.length) {
1513
1543
  const char = input[index];
1514
1544
  const prev = index > 0 ? input[index - 1] : "";
@@ -1529,12 +1559,19 @@ function replaceTemplateExpressions(input, replacer) {
1529
1559
  tagBraceDepth -= 1;
1530
1560
  } else if (char === ">" && tagBraceDepth === 0) {
1531
1561
  inTag = false;
1562
+ updateRawTextStack(input.slice(tagStart + 1, index));
1532
1563
  }
1533
1564
  index += 1;
1534
1565
  continue;
1535
1566
  }
1536
1567
  if (char === "<") {
1537
1568
  inTag = true;
1569
+ tagStart = index;
1570
+ output += char;
1571
+ index += 1;
1572
+ continue;
1573
+ }
1574
+ if (rawTextStack.length > 0) {
1538
1575
  output += char;
1539
1576
  index += 1;
1540
1577
  continue;