pretty-toc-alpha
v1.6.9
Published
A Table of Contents generation plugin for the Satteri markdown parser library. This package serves as a pre-release test for pretty-toc. Please install pretty-toc for the stable version.
Maintainers
Readme
A Table of Contents generation plugin for the Satteri markdown parser library.
[!WARNING] This package serves as a pre-release test for pretty-toc. Please install pretty-toc for the stable version.
Install
// install with npm
npm install pretty-toc-alpha --save-dev
// install with pnpm
pnpm install pretty-toc-alpha --save-dev
// install with yarn
yarn add -D pretty-toc-alpha
// install with bun
bun add -D pretty-toc-alpha
// install with deno
deno add -D pretty-toc-alphaTable of Contents
Example
import prettyToc from 'pretty-toc-alpha';
// Basic example
satteri({
hastPlugins: [prettyToc({title: "Table of Contents", listStyle: "decimal"})]
})
// Full example
satteri({
hastPlugins: [
prettyToc({
title: "Table of Contents",
openedMarker: '🦋',
closedMarker: '🐢',
titleMarkerType: 'icon',
titleMarkerCssSize: '1rem',
listStyle: "image", // disc, circle, decimal, none... icon, image...
icon: ["🐶", "🦁", "🐷", "🐸", "🐥", "🐞"], // or just a string, eg. "🐥"
image: [
"/svg/unjs--automd.svg",
"/svg/unjs--hookable.svg",
"/svg/unjs--knitwork.svg",
"/svg/unjs--mongoz.svg",
"/svg/unjs--ofetch.svg",
"/svg/unjs--uncrypto.svg",
], // or just a string, eg. "/svg/unjs--automd.svg"
liMarkerCssSize: "1rem",
lightThemeHighlightColor: "oklch(0.75 0.1229 12.71)",
darkThemeHighlightColor: "oklch(0.81 0.1004 305.04)",
animation: {
duration: '0.8s',
timingFunction: 'ease-in-out'
},
class: {
title: "",
ul: "",
li: "",
a: "",
},
globalStyle: "",
style: {
title: "",
ul: "",
li: "",
a: "",
},
locale: "zh-CN", // Note: The case of the locale variable should match the locale in your page URL.
languageMap: {
"de-DE": "Inhaltsverzeichnis",
"el-GR": "Περιεχόμενα",
"en-US": "Table of Contents",
"es-ES": "Índice",
"fr-FR": "Sommaire",
"it-IT": "Indice",
"ja-JP": "目次",
"ko-KR": "목차",
"ru-RU": "Оглавление",
"th-TH": "สารบัญ",
"tr-TR": "İçindekiler",
"zh-CN": "目录",
"zh-Hant": "目錄",
},
}),
],
}),Screenshots
Options
| Property | Type | Default Value | Preset Value | Description | | :----------------------- | :--------------------------------------------------------------------------- | :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------- | | title | string | Table of Contents | Table of Contents | - | | openedMarker | string or undefined | undefined | ▼ | Note: titleMarkerType must already be set. | | closedMarker | string or undefined | undefined | ▶︎ | Note: titleMarkerType must already be set. | | titleMarkerType | string or undefined | undefined | icon | Value can only be "icon" or "image". | | titleMarkerCssSize | string or undefined | undefined | fit-content | - | | listStyle | string or undefined | undefined | decimal | eg. disc, circle, decimal, none... or icon and image | | icon | string or string[] or undefined | undefined | decimal | Note: listStyle must already be set. | | image | string or string[] or undefined | undefined | 404 image | Note: listStyle must already be set. | | liMarkerCssSize | string or undefined | undefined | 1rem | CSS property value | | lightThemeHighlightColor | string or undefined | undefined | oklch(0.75 0.1229 12.71) | - | | darkThemeHighlightColor | string or undefined | undefined | oklch(0.81 0.1004 305.04) | - | | animation | boolean or { duration: string, timingFunction: string } or undefined | undefined | { duration: "0.8s", timingFunction: 'ease-in-out' } | - | | class | {title?: string, ul?: string, li?: string, a?: string} or or undefined | undefined | undefined | eg. {li: "py-1"} | | globalStyle | string or or undefined | undefined | undefined | eg. "ul {background-color: yellow;}" | | style | Object{title?: string, ul?: string, li?: string, a?: string} or or undefined | undefined | undefined | eg. {a: "font-style: italic;"} | | locale | string or undefined | undefined | en-US | eg. "zh-CN" // Note: The case of the locale variable should match the locale in your page URL. | | languageMap | Record<string, string> or undefined | undefined | {"de-DE": "Inhaltsverzeichnis","el-GR": "Περιεχόμενα","en-US": "Contents","es-ES": "Índice","fr-FR": "Sommaire","it-IT": "Indice","ja-JP": "目次","ko-KR": "목차","ru-RU": "Оглавление","th-TH": "สารบัญ","tr-TR": "İçindekiler","zh-CN": "目录","zh-Hant": "目錄"} | eg. {"en-US": "Table of Contents", "ja-JP": "目次"} |
Contribution
If you see any errors or room for improvement on this plugin, feel free to open an issues or pull request . Thank you in advance for contributing!
