@braze/sanity-plugin-ai-translation 0.2.59 → 0.2.61
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/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1700,7 +1700,8 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
1700
1700
|
stack.push(node);
|
|
1701
1701
|
continue;
|
|
1702
1702
|
}
|
|
1703
|
-
|
|
1703
|
+
const closeMatch = trimmed.match(/^<\/(field|block|span)>/);
|
|
1704
|
+
if (closeMatch && stack.length > 0) {
|
|
1704
1705
|
matchedPatternCount++;
|
|
1705
1706
|
const node = stack.pop();
|
|
1706
1707
|
if (node)
|
|
@@ -1709,6 +1710,47 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
1709
1710
|
parent && parent.children.push(node);
|
|
1710
1711
|
} else
|
|
1711
1712
|
root.push(node);
|
|
1713
|
+
let afterClosingTag = trimmed.substring(closeMatch[0].length).trim();
|
|
1714
|
+
if (afterClosingTag = afterClosingTag.replace(/<!--[\s\S]*?-->/g, "").trim(), afterClosingTag) {
|
|
1715
|
+
const remainingOpenMatch = afterClosingTag.match(/^<(field|block|span)([^>]*)>(.*)$/);
|
|
1716
|
+
if (remainingOpenMatch) {
|
|
1717
|
+
const [, tagName, attrsStr, content] = remainingOpenMatch, attributes = parseAttributes(attrsStr), remainingNode = {
|
|
1718
|
+
type: tagName,
|
|
1719
|
+
name: attributes.name,
|
|
1720
|
+
text: content ? unescapeXml(content) : void 0,
|
|
1721
|
+
attributes,
|
|
1722
|
+
children: []
|
|
1723
|
+
}, remainingClosingTag = `</${tagName}>`;
|
|
1724
|
+
if (content.includes(remainingClosingTag))
|
|
1725
|
+
if (remainingNode.text = unescapeXml(content.replace(remainingClosingTag, "")), stack.length > 0) {
|
|
1726
|
+
const parent = stack[stack.length - 1];
|
|
1727
|
+
parent && parent.children.push(remainingNode);
|
|
1728
|
+
} else
|
|
1729
|
+
root.push(remainingNode);
|
|
1730
|
+
else if (attributes.type === "string" && content)
|
|
1731
|
+
if (remainingNode.text = unescapeXml(content), stack.length > 0) {
|
|
1732
|
+
const parent = stack[stack.length - 1];
|
|
1733
|
+
parent && parent.children.push(remainingNode);
|
|
1734
|
+
} else
|
|
1735
|
+
root.push(remainingNode);
|
|
1736
|
+
else if (attributes.type === "string" && !content) {
|
|
1737
|
+
const contentLines = [];
|
|
1738
|
+
for (i++; i < lines.length; ) {
|
|
1739
|
+
const currentLine = lines[i];
|
|
1740
|
+
if (currentLine.trim() === `</${tagName}>` || currentLine.trim().startsWith(`</${tagName}>`))
|
|
1741
|
+
break;
|
|
1742
|
+
contentLines.push(currentLine), i++;
|
|
1743
|
+
}
|
|
1744
|
+
if (remainingNode.text = contentLines.join(`
|
|
1745
|
+
`).trim(), stack.length > 0) {
|
|
1746
|
+
const parent = stack[stack.length - 1];
|
|
1747
|
+
parent && parent.children.push(remainingNode);
|
|
1748
|
+
} else
|
|
1749
|
+
root.push(remainingNode);
|
|
1750
|
+
} else
|
|
1751
|
+
stack.push(remainingNode);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1712
1754
|
continue;
|
|
1713
1755
|
}
|
|
1714
1756
|
processedLineCount <= 20 && devLog.debug("Line did not match any pattern", {
|