| | |
| | | import remarkGfm from "remark-gfm" |
| | | import smartypants from 'remark-smartypants' |
| | | import smartypants from "remark-smartypants" |
| | | import { QuartzTransformerPlugin } from "../types" |
| | | import rehypeSlug from "rehype-slug" |
| | | import rehypeAutolinkHeadings from "rehype-autolink-headings" |
| | |
| | | |
| | | const defaultOptions: Options = { |
| | | enableSmartyPants: true, |
| | | linkHeadings: true |
| | | linkHeadings: true, |
| | | } |
| | | |
| | | export const GitHubFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => { |
| | | export const GitHubFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = ( |
| | | userOpts, |
| | | ) => { |
| | | const opts = { ...defaultOptions, ...userOpts } |
| | | return { |
| | | name: "GitHubFlavoredMarkdown", |
| | |
| | | }, |
| | | htmlPlugins() { |
| | | if (opts.linkHeadings) { |
| | | return [rehypeSlug, [rehypeAutolinkHeadings, { |
| | | behavior: 'append', content: { |
| | | type: 'text', |
| | | value: ' §', |
| | | } |
| | | }]] |
| | | return [ |
| | | rehypeSlug, |
| | | [ |
| | | rehypeAutolinkHeadings, |
| | | { |
| | | behavior: "append", |
| | | content: { |
| | | type: "text", |
| | | value: " §", |
| | | }, |
| | | }, |
| | | ], |
| | | ] |
| | | } else { |
| | | return [] |
| | | } |
| | | } |
| | | }, |
| | | } |
| | | } |