Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix(markdown): render single newlines as line breaks

Steven5a16f8009fa7
diff --git a/web/package.json b/web/package.json
index afc1d6ab9..27eaaf077 100644
--- a/web/package.json
+++ b/web/package.json
@@ -56,6 +56,7 @@
"react-simple-pull-to-refresh": "^1.3.3",
"react-use": "^17.6.0",
"rehype-raw": "^7.0.0",
+ "remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.4.0",
"tailwindcss": "^4.1.17",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index 5b60d9a82..81b389a65 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -146,6 +146,9 @@ importers:
rehype-raw:
specifier: ^7.0.0
version: 7.0.0
+ remark-breaks:
+ specifier: ^4.0.0
+ version: 4.0.0
remark-gfm:
specifier: ^4.0.1
version: 4.0.1
@@ -2258,6 +2261,9 @@ packages:
resolution: {integrity: sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==}
+ resolution: {integrity: sha512-MbgeFca0hLYIEx/2zGsszCSEJJ1JSCdiY5xQxRcLDDGa8EPvlLPupJ4DSajbMPAnC0je8jfb9TiUATnxxrHUog==}
+
resolution: {integrity: sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==}
@@ -2611,6 +2617,9 @@ packages:
resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==}
+ resolution: {integrity: sha512-IjEjJOkH4FuJvHZVIW0QCDWxcG96kCq7An/KVH2NfJe6rKZU2AsHeB3OEjPNRxi4QC34Xdx7I2KGYn6IpT7gxQ==}
+
resolution: {integrity: sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==}
@@ -5022,6 +5031,11 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-find-and-replace: 3.0.2
+
dependencies:
'@types/mdast': 4.0.4
@@ -5548,6 +5562,12 @@ snapshots:
hast-util-raw: 9.1.0
vfile: 6.0.3
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-newline-to-break: 2.0.0
+ unified: 11.0.5
+
dependencies:
'@types/mdast': 4.0.4
diff --git a/web/src/components/MemoContent/index.tsx b/web/src/components/MemoContent/index.tsx
index a1483fe9e..0e5a18f8e 100644
--- a/web/src/components/MemoContent/index.tsx
+++ b/web/src/components/MemoContent/index.tsx
@@ -2,6 +2,7 @@ import { observer } from "mobx-react-lite";
import { memo, useEffect, useRef, useState } from "react";
import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";
+import remarkBreaks from "remark-breaks";
import remarkGfm from "remark-gfm";
import useCurrentUser from "@/hooks/useCurrentUser";
import { cn } from "@/lib/utils";
@@ -98,7 +99,7 @@ const MemoContent = observer((props: Props) => {
onDoubleClick={onMemoContentDoubleClick}
>
<ReactMarkdown
- remarkPlugins={[remarkGfm, remarkTag, remarkPreserveType]}
+ remarkPlugins={[remarkGfm, remarkBreaks, remarkTag, remarkPreserveType]}
rehypePlugins={[rehypeRaw]}
components={{
// Conditionally render custom components based on AST node type