diff --git a/package.json b/package.json index 1bd1e847..fd165e4c 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "rehype-sanitize": "5.0.1", "rehype-slug": "5.1.0", "rehype-stringify": "9.0.3", + "remark-breaks": "^3.0.2", "remark-directive": "2.0.1", "remark-directive-rehype": "0.4.2", "remark-frontmatter": "4.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 378fcdb1..daf536d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,6 +108,7 @@ specifiers: rehype-sanitize: 5.0.1 rehype-slug: 5.1.0 rehype-stringify: 9.0.3 + remark-breaks: ^3.0.2 remark-directive: 2.0.1 remark-directive-rehype: 0.4.2 remark-frontmatter: 4.0.1 @@ -203,6 +204,7 @@ dependencies: rehype-sanitize: 5.0.1 rehype-slug: 5.1.0 rehype-stringify: 9.0.3 + remark-breaks: 3.0.2 remark-directive: 2.0.1 remark-directive-rehype: 0.4.2 remark-frontmatter: 4.0.1 @@ -11584,6 +11586,14 @@ packages: unified: 10.1.2 dev: false + /remark-breaks/3.0.2: + resolution: {integrity: sha512-x96YDJ9X+Ry0/JNZFKfr1hpcAKvGYWfUTszxY9RbxKEqq6uzPPoLCuHdZsLPZZUdAv3nCROyc7FPrQLWr2rxyw==} + dependencies: + '@types/mdast': 3.0.10 + unified: 10.1.2 + unist-util-visit: 4.1.2 + dev: false + /remark-directive-rehype/0.4.2: resolution: {integrity: sha512-T6e+IG+BwqU4++MK54vFb+KDFjs3a+tHeK6E0T0ctR1FSyngolfDtAEzqxHWlRzQZqGi2sB4DFXry6oqH87D/g==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} diff --git a/src/markdown/index.ts b/src/markdown/index.ts index a84e8e9c..41ab1f73 100644 --- a/src/markdown/index.ts +++ b/src/markdown/index.ts @@ -30,6 +30,7 @@ import { Mention } from "~/components/ui/Mention" import remarkMath from "remark-math" import rehypeKatex from "rehype-katex" import rehypeInferDescriptionMeta from "rehype-infer-description-meta" +import remarkBreaks from "remark-breaks" export type MarkdownEnv = { excerpt: string @@ -72,6 +73,7 @@ export const renderPageContent = ( try { result = unified() .use(remarkParse) + .use(remarkBreaks) .use(remarkFrontmatter, ["yaml"]) .use(() => (tree) => { const yaml = tree.children.find((node) => node.type === "yaml")