@scrider/formatter 1.3.6 → 1.3.7
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.cjs +19 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2502,7 +2502,11 @@ function resolveDocumentPresentation(presentation) {
|
|
|
2502
2502
|
return { lineSpacing, textIndentCm };
|
|
2503
2503
|
}
|
|
2504
2504
|
var LINE_HEIGHT_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
|
|
2505
|
-
var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"
|
|
2505
|
+
var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"]);
|
|
2506
|
+
function documentPresentationListWrapperStyleParts(resolved) {
|
|
2507
|
+
if (!resolved?.textIndentCm) return [];
|
|
2508
|
+
return [`padding-left:calc(1.5em + ${resolved.textIndentCm}cm)`];
|
|
2509
|
+
}
|
|
2506
2510
|
function documentPresentationStyleParts(tag, resolved) {
|
|
2507
2511
|
if (!resolved) return [];
|
|
2508
2512
|
const parts = [];
|
|
@@ -2627,7 +2631,13 @@ function deltaToHtml(delta, options = {}) {
|
|
|
2627
2631
|
continue;
|
|
2628
2632
|
}
|
|
2629
2633
|
if (isList) {
|
|
2630
|
-
html += handleListOpen(
|
|
2634
|
+
html += handleListOpen(
|
|
2635
|
+
listStack,
|
|
2636
|
+
listType,
|
|
2637
|
+
indent,
|
|
2638
|
+
pretty,
|
|
2639
|
+
resolvedDocumentPresentation
|
|
2640
|
+
);
|
|
2631
2641
|
if (hierarchicalNumbers && listType === "ordered") {
|
|
2632
2642
|
if (counters.length > indent + 1) {
|
|
2633
2643
|
counters = counters.slice(0, indent + 1);
|
|
@@ -2906,9 +2916,13 @@ function renderCodeBlock(codeLines, language, embedRenderers, pretty, blockHandl
|
|
|
2906
2916
|
</code></pre>`;
|
|
2907
2917
|
return pretty ? html + "\n" : html;
|
|
2908
2918
|
}
|
|
2909
|
-
function handleListOpen(stack, listType, indent, pretty) {
|
|
2919
|
+
function handleListOpen(stack, listType, indent, pretty, resolvedDocumentPresentation) {
|
|
2910
2920
|
let html = "";
|
|
2911
2921
|
const wrapperTag = LIST_WRAPPER_TAGS[listType] || "ul";
|
|
2922
|
+
const openWrapperTag = () => {
|
|
2923
|
+
const styleAttr = stack.length === 0 ? joinStyleParts(documentPresentationListWrapperStyleParts(resolvedDocumentPresentation)) : "";
|
|
2924
|
+
return `<${wrapperTag}${styleAttr}>`;
|
|
2925
|
+
};
|
|
2912
2926
|
while (stack.length > 0) {
|
|
2913
2927
|
const last = stack[stack.length - 1];
|
|
2914
2928
|
if (!last || last.indent <= indent) break;
|
|
@@ -2935,7 +2949,7 @@ function handleListOpen(stack, listType, indent, pretty) {
|
|
|
2935
2949
|
const currentIndent = last ? last.indent + 1 : 0;
|
|
2936
2950
|
if (currentIndent > indent) break;
|
|
2937
2951
|
if (pretty) html += getIndent(stack.length);
|
|
2938
|
-
html +=
|
|
2952
|
+
html += openWrapperTag();
|
|
2939
2953
|
if (pretty) html += "\n";
|
|
2940
2954
|
stack.push({ type: listType, indent: currentIndent });
|
|
2941
2955
|
if (currentIndent >= indent) break;
|
|
@@ -2943,7 +2957,7 @@ function handleListOpen(stack, listType, indent, pretty) {
|
|
|
2943
2957
|
const current = stack[stack.length - 1];
|
|
2944
2958
|
if (!current || current.indent < indent) {
|
|
2945
2959
|
if (pretty) html += getIndent(stack.length);
|
|
2946
|
-
html +=
|
|
2960
|
+
html += openWrapperTag();
|
|
2947
2961
|
if (pretty) html += "\n";
|
|
2948
2962
|
stack.push({ type: listType, indent });
|
|
2949
2963
|
}
|