feat: remove remark-pangu

This commit is contained in:
DIYgod 2023-06-15 19:55:11 +01:00
parent b4935f7037
commit edff400905
No known key found for this signature in database
2 changed files with 0 additions and 62 deletions

View File

@ -46,7 +46,6 @@ import { rehypeWrapCode } from "./rehype-wrap-code"
import { rehypeExternalLink } from "./rehyper-external-link"
import { remarkCallout } from "./remark-callout"
import { remarkMermaid } from "./remark-mermaid"
import { remarkPangu } from "./remark-pangu"
import { remarkYoutube } from "./remark-youtube"
import sanitizeScheme from "./sanitize-schema"
@ -124,7 +123,6 @@ export const renderPageContent = (
.use(remarkMath, {
singleDollarTextMath: false,
})
.use(remarkPangu)
.use(() => (tree) => {
env.toc = toc(tree, { tight: true, ordered: true })
})

View File

@ -1,60 +0,0 @@
import pangu from "pangu"
import type { Root } from "remark-gfm"
import type { Plugin } from "unified"
import { visit } from "unist-util-visit"
interface Options {
text?: boolean
inlineCode?: boolean
link?: boolean
image?: boolean
definition?: boolean
imageReference?: boolean
}
const defaultOptions: Options = {
text: true,
inlineCode: false,
link: true,
image: true,
definition: true,
imageReference: true,
}
function format(value: string) {
if (!value) return value
return pangu.spacing(value)
}
export const remarkPangu: Plugin<Array<Options>, Root> =
(options = {}) =>
(tree, _) => {
const settings = Object.assign({}, defaultOptions, options)
const subset = (Object.keys(settings) as Array<keyof Options>).filter(
(k) => settings[k],
) as string[]
visit(tree, (node) => {
if (subset.includes(node.type)) {
if (node.type === "text" || node.type === "inlineCode") {
node.value = format(node.value)
}
if (
(node.type === "link" ||
node.type === "image" ||
node.type === "definition") &&
node.title
) {
node.title = format(node.title)
}
if (
(node.type === "image" || node.type === "imageReference") &&
node.alt
) {
node.alt = format(node.alt)
}
}
})
}