Skip to content

Commit

Permalink
feat: remove built-in remark-flatten-image
Browse files Browse the repository at this point in the history
  • Loading branch information
zce committed Nov 20, 2023
1 parent c2c149a commit a3d4100
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
7 changes: 1 addition & 6 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ content: s.markdown()
**options**: markdown options

- type: `MarkdownOptions` 👇👇👇
- default: `{ gfm: true, removeComments: true, flattenImage: true }`
- default: `{ gfm: true, removeComments: true }`

#### Types

Expand All @@ -434,11 +434,6 @@ interface MarkdownOptions {
* @default true
*/
removeComments?: boolean
/**
* Flatten image paragraph.
* @default true
*/
flattenImage?: boolean
/**
* Remark plugins.
*/
Expand Down
15 changes: 0 additions & 15 deletions src/plugins/remark-flatten-image.ts

This file was deleted.

9 changes: 1 addition & 8 deletions src/shared/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { unified } from 'unified'
import { z } from 'zod'

import rehypeCopyLinkedFiles from '../plugins/rehype-copy-linked-files'
import remarkFlattenImage from '../plugins/remark-flatten-image'
import remarkRemoveComments from '../plugins/remark-remove-comments'

import type { PluggableList } from 'unified'
Expand All @@ -23,11 +22,6 @@ export interface MarkdownOptions {
* @default true
*/
removeComments?: boolean
/**
* Flatten image paragraph.
* @default true
*/
flattenImage?: boolean
/**
* Remark plugins.
*/
Expand All @@ -38,12 +32,11 @@ export interface MarkdownOptions {
rehypePlugins?: PluggableList
}

export const markdown = ({ gfm = true, removeComments = true, flattenImage = true, remarkPlugins, rehypePlugins }: MarkdownOptions = {}) =>
export const markdown = ({ gfm = true, removeComments = true, remarkPlugins, rehypePlugins }: MarkdownOptions = {}) =>
z.string().transform(async (value, ctx) => {
const file = unified().use(remarkParse) // parse markdown content to a syntax tree
if (gfm) file.use(remarkGfm) // support gfm (autolink literals, footnotes, strikethrough, tables, tasklists).
if (removeComments) file.use(remarkRemoveComments) // remove html comments
if (flattenImage) file.use(remarkFlattenImage) // flatten image paragraph
if (remarkPlugins != null) file.use(remarkPlugins) // apply remark plugins
file.use(remarkRehype, { allowDangerousHtml: true }).use(rehypeRaw) // turn markdown syntax tree to html syntax tree, with raw html support
if (rehypePlugins != null) file.use(rehypePlugins) // apply rehype plugins
Expand Down

0 comments on commit a3d4100

Please sign in to comment.