mirror of
https://gitlab.com/MisterBiggs/brain-quartz.git
synced 2025-08-18 11:24:56 +00:00
.github
content
quartz
components
plugins
emitters
filters
transformers
description.ts
frontmatter.ts
gfm.ts
index.ts
lastmod.ts
latex.ts
links.ts
ofm.ts
syntax.ts
toc.ts
index.ts
types.ts
vfile.ts
processors
static
styles
bootstrap-cli.mjs
bootstrap-worker.mjs
build.ts
cfg.ts
log.ts
path.test.ts
path.ts
perf.ts
resources.tsx
theme.ts
trace.ts
worker.ts
.gitignore
.prettierrc
CODE_OF_CONDUCT.md
LICENSE.txt
README.md
globals.d.ts
index.d.ts
package-lock.json
package.json
quartz.config.ts
tsconfig.json
38 lines
989 B
TypeScript
38 lines
989 B
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 []
|
|
}
|
|
}
|
|
}
|
|
}
|