@examind/block-sdk 0.1.9 → 0.1.11
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 +11 -2
- package/dist/index.mjs +11 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -767,12 +767,21 @@ function hasFormat(format, type) {
|
|
|
767
767
|
return (format & formatFlag) !== 0;
|
|
768
768
|
}
|
|
769
769
|
function encodeHTMLEntities(text) {
|
|
770
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
770
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\u00A0/g, " ");
|
|
771
|
+
}
|
|
772
|
+
function preserveSpaces(text) {
|
|
773
|
+
return text.replace(/ {2,}/g, (match) => {
|
|
774
|
+
let result = "";
|
|
775
|
+
for (let i = 0; i < match.length; i++) {
|
|
776
|
+
result += i % 2 === 0 ? " " : " ";
|
|
777
|
+
}
|
|
778
|
+
return result;
|
|
779
|
+
});
|
|
771
780
|
}
|
|
772
781
|
var TextNodeHandler = class extends NodeHandler {
|
|
773
782
|
processNode(node) {
|
|
774
783
|
if (!isSerializedTextNode(node)) return null;
|
|
775
|
-
let result = encodeHTMLEntities(node.text);
|
|
784
|
+
let result = preserveSpaces(encodeHTMLEntities(node.text));
|
|
776
785
|
if (hasFormat(node.format, "subscript")) {
|
|
777
786
|
result = `<sub>${result}</sub>`;
|
|
778
787
|
} else if (hasFormat(node.format, "superscript")) {
|
package/dist/index.mjs
CHANGED
|
@@ -740,12 +740,21 @@ function hasFormat(format, type) {
|
|
|
740
740
|
return (format & formatFlag) !== 0;
|
|
741
741
|
}
|
|
742
742
|
function encodeHTMLEntities(text) {
|
|
743
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
743
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\u00A0/g, " ");
|
|
744
|
+
}
|
|
745
|
+
function preserveSpaces(text) {
|
|
746
|
+
return text.replace(/ {2,}/g, (match) => {
|
|
747
|
+
let result = "";
|
|
748
|
+
for (let i = 0; i < match.length; i++) {
|
|
749
|
+
result += i % 2 === 0 ? " " : " ";
|
|
750
|
+
}
|
|
751
|
+
return result;
|
|
752
|
+
});
|
|
744
753
|
}
|
|
745
754
|
var TextNodeHandler = class extends NodeHandler {
|
|
746
755
|
processNode(node) {
|
|
747
756
|
if (!isSerializedTextNode(node)) return null;
|
|
748
|
-
let result = encodeHTMLEntities(node.text);
|
|
757
|
+
let result = preserveSpaces(encodeHTMLEntities(node.text));
|
|
749
758
|
if (hasFormat(node.format, "subscript")) {
|
|
750
759
|
result = `<sub>${result}</sub>`;
|
|
751
760
|
} else if (hasFormat(node.format, "superscript")) {
|