mirror of
https://gitlab.com/MisterBiggs/brain-quartz.git
synced 2025-08-17 02:45:04 +00:00
.github
content
docs
quartz
cli
components
plugins
emitters
filters
transformers
description.ts
frontmatter.ts
gfm.ts
index.ts
lastmod.ts
latex.ts
linebreaks.ts
links.ts
ofm.ts
oxhugofm.ts
syntax.ts
toc.ts
index.ts
types.ts
vfile.ts
processors
static
styles
util
bootstrap-cli.mjs
bootstrap-worker.mjs
build.ts
cfg.ts
worker.ts
.gitattributes
.gitignore
.npmrc
.prettierignore
.prettierrc
CODE_OF_CONDUCT.md
Dockerfile
LICENSE.txt
README.md
globals.d.ts
index.d.ts
package-lock.json
package.json
quartz.config.ts
quartz.layout.ts
tsconfig.json
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import remarkGfm from "remark-gfm"
|
|
import smartypants from "remark-smartypants"
|
|
import { QuartzTransformerPlugin } from "../types"
|
|
import rehypeSlug from "rehype-slug"
|
|
import rehypeAutolinkHeadings from "rehype-autolink-headings"
|
|
|
|
export interface Options {
|
|
enableSmartyPants: boolean
|
|
linkHeadings: boolean
|
|
}
|
|
|
|
const defaultOptions: Options = {
|
|
enableSmartyPants: true,
|
|
linkHeadings: true,
|
|
}
|
|
|
|
export const GitHubFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = (
|
|
userOpts,
|
|
) => {
|
|
const opts = { ...defaultOptions, ...userOpts }
|
|
return {
|
|
name: "GitHubFlavoredMarkdown",
|
|
markdownPlugins() {
|
|
return opts.enableSmartyPants ? [remarkGfm, smartypants] : [remarkGfm]
|
|
},
|
|
htmlPlugins() {
|
|
if (opts.linkHeadings) {
|
|
return [
|
|
rehypeSlug,
|
|
[
|
|
rehypeAutolinkHeadings,
|
|
{
|
|
behavior: "append",
|
|
content: {
|
|
type: "text",
|
|
value: " §",
|
|
},
|
|
},
|
|
],
|
|
]
|
|
} else {
|
|
return []
|
|
}
|
|
},
|
|
}
|
|
}
|