ochre-sdk 1.0.39 → 1.0.40
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/parsers/string.mjs +6 -2
- package/package.json +1 -1
package/dist/parsers/string.mjs
CHANGED
|
@@ -15,6 +15,8 @@ const HEADING_LEVEL_TOKEN = "heading-level";
|
|
|
15
15
|
const RAW_MDX_BLOCK_DELIMITER = "``md``";
|
|
16
16
|
const RAW_MDX_BLOCK_PLACEHOLDER_PREFIX = "\0raw-mdx-block:";
|
|
17
17
|
const RAW_MDX_BLOCK_PLACEHOLDER_SUFFIX = "\0";
|
|
18
|
+
const RICH_LINE_BREAK = "<br />\n";
|
|
19
|
+
const RICH_PARAGRAPH_BREAK = "\n\n";
|
|
18
20
|
const MDX_QUOTED_ATTRIBUTE_ESCAPE_REGEX = /[\n\r"]/;
|
|
19
21
|
const MDX_RENDER_ELEMENTS = {
|
|
20
22
|
bold: "strong",
|
|
@@ -72,7 +74,8 @@ function applyMDXRenderElements(contentString, options) {
|
|
|
72
74
|
function applyNewlineWhitespace(contentString, whitespace, rendering) {
|
|
73
75
|
if (whitespace == null) return contentString;
|
|
74
76
|
if (!hasNewlineWhitespace(whitespace)) return contentString;
|
|
75
|
-
if (
|
|
77
|
+
if (contentString === "" && rendering !== "plain") return RICH_PARAGRAPH_BREAK;
|
|
78
|
+
if (rendering === "rich") return contentString.trim() === "***" ? `${contentString}\n` : `${RICH_LINE_BREAK}${contentString}`;
|
|
76
79
|
return `\n${contentString}`;
|
|
77
80
|
}
|
|
78
81
|
/**
|
|
@@ -285,7 +288,8 @@ function parseNestedStringItems(items, contentItem, options) {
|
|
|
285
288
|
continue;
|
|
286
289
|
}
|
|
287
290
|
if (rawMDXBlockStartIndex != null) continue;
|
|
288
|
-
|
|
291
|
+
const parsedItem = parseXMLStringItem(item, contentItem, options);
|
|
292
|
+
result += options.rendering === "rich" && result.endsWith("\n") && parsedItem.startsWith(RICH_LINE_BREAK) ? parsedItem.slice(6) : parsedItem;
|
|
289
293
|
}
|
|
290
294
|
if (rawMDXBlockStartIndex != null) for (let index = rawMDXBlockStartIndex; index < items.length; index += 1) {
|
|
291
295
|
const item = items[index];
|