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.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix(web): disable setext header syntax (#5314)
Steven48ce4ccc2664
diff --git a/web/src/components/MemoContent/index.tsx b/web/src/components/MemoContent/index.tsxindex 601da30c0..42d95fb2c 100644--- a/web/src/components/MemoContent/index.tsx+++ b/web/src/components/MemoContent/index.tsx@@ -11,6 +11,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";import { cn } from "@/lib/utils";import { memoStore } from "@/store";import { useTranslate } from "@/utils/i18n";+import { remarkDisableSetext } from "@/utils/remark-plugins/remark-disable-setext";import { remarkPreserveType } from "@/utils/remark-plugins/remark-preserve-type";import { remarkTag } from "@/utils/remark-plugins/remark-tag";import { isSuperUser } from "@/utils/user";@@ -59,7 +60,7 @@ const MemoContent = observer((props: MemoContentProps) => {onDoubleClick={onDoubleClick}><ReactMarkdown- remarkPlugins={[remarkGfm, remarkBreaks, remarkMath, remarkTag, remarkPreserveType]}+ remarkPlugins={[remarkDisableSetext, remarkGfm, remarkBreaks, remarkMath, remarkTag, remarkPreserveType]}rehypePlugins={[rehypeRaw, rehypeKatex, [rehypeSanitize, SANITIZE_SCHEMA]]}components={{// Conditionally render custom components based on AST node typediff --git a/web/src/utils/remark-plugins/remark-disable-setext.ts b/web/src/utils/remark-plugins/remark-disable-setext.tsnew file mode 100644index 000000000..5dda7e2d2--- /dev/null+++ b/web/src/utils/remark-plugins/remark-disable-setext.ts@@ -0,0 +1,30 @@+/**+ * Remark plugin to disable setext header syntax.+ *+ * Setext headers use underlines (=== or ---) to create headings:+ * Heading 1+ * =========+ *+ * Heading 2+ * ---------+ *+ * This plugin disables the setext heading construct at the micromark parser level,+ * preventing these patterns from being recognized as headers.+ */+export function remarkDisableSetext(this: any) {+ const data = this.data();++ add("micromarkExtensions", {+ disable: {+ null: ["setextUnderline"],+ },+ });++ /**+ * Add a micromark extension to the parser configuration.+ */+ function add(field: string, value: any) {+ const list = data[field] ? data[field] : (data[field] = []);+ list.push(value);+ }+}