pretty-toc 0.1.6 → 0.1.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/README.md +2 -2
- package/dist/index.mjs +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ processor: satteri({
|
|
|
80
80
|
|lightThemeHighlightColor|string|eg. "oklch(0.75 0.1229 12.71)"|
|
|
81
81
|
|darkThemeHighlightColor|string|eg. "oklch(0.81 0.1004 305.04)"|
|
|
82
82
|
|class|{summary?: string, ul?: string, li?: string, a?: string}|eg. {summary: "pb-2", li: "py-1"}|
|
|
83
|
-
|globalStyle|string
|
|
84
|
-
|style|Object{summary?: string, ul?: string, li?: string, a?: string}
|
|
83
|
+
|globalStyle|string|eg. "summary {background-color: yellow;}"|
|
|
84
|
+
|style|Object{summary?: string, ul?: string, li?: string, a?: string}|eg. {a: "font-style: italic;"}|
|
|
85
85
|
|locale|string|eg. "zh-CN" // **Note: The case of the locale variable should match the locale in your page URL.**|
|
|
86
86
|
|languageMap|Record<string, string>|eg. {"en-US": "Table of Contents", "ja-JP": "目次"}|
|
package/dist/index.mjs
CHANGED
|
@@ -82,7 +82,9 @@ function prettyToc(option) {
|
|
|
82
82
|
break;
|
|
83
83
|
default: marker = "";
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const tagSignal = `<span data-depth='${depth}' style="display: none;"></span>`;
|
|
86
|
+
const tagSignalLength = tagSignal.length;
|
|
87
|
+
const nodeStr = `<li id="li-${contentSlug}" class="${opt.class?.li ?? ""}" style="${opt.style?.li ?? ""}" data-depth=${depth}><div class="li-row">${marker}<a href="#${contentSlug}" class="${opt.class?.a ?? ""}" style="${opt.style?.a ?? ""}">${content}</a></div>${tagSignal}</li>`;
|
|
86
88
|
ctx.setProperty(node, "id", contentSlug);
|
|
87
89
|
let parent = ctx.parent(node);
|
|
88
90
|
while (parent.type !== "root" && parent !== void 0) {
|
|
@@ -220,8 +222,8 @@ function prettyToc(option) {
|
|
|
220
222
|
content: counters(toc-counter, ".");
|
|
221
223
|
}` : "")}</style><summary data-satteri-toc-title="${opt.languageMap?.[opt.locale ?? "en-US"] ?? defaultTitle}" class="${opt.class?.summary ?? ""}" style="${opt.style?.summary ?? ""}">${opt.languageMap?.[opt.locale ?? "en-US"] ?? defaultTitle}</summary><ul class="${opt.class?.ul ?? ""}" style="${opt.style?.ul ?? ""}">${nodeStr}</ul>${iframeContent}</details>`;
|
|
222
224
|
} else {
|
|
223
|
-
const indexA = ctx.data.nodeStr?.lastIndexOf(
|
|
224
|
-
if (indexA !== -1) ctx.data.nodeStr = ctx.data.nodeStr?.slice(0, indexA +
|
|
225
|
+
const indexA = ctx.data.nodeStr?.lastIndexOf(tagSignal);
|
|
226
|
+
if (indexA !== -1) ctx.data.nodeStr = ctx.data.nodeStr?.slice(0, indexA + tagSignalLength + 5) + nodeStr + ctx.data.nodeStr?.slice(indexA + tagSignalLength + 5);
|
|
225
227
|
else if (depth > 1) {
|
|
226
228
|
let indexB = -1;
|
|
227
229
|
for (let i = depth; i > 0; i--) {
|