mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: add blockquote regexp (#366)
This commit is contained in:
18
web/src/labs/marked/parser/Blockquote.ts
Normal file
18
web/src/labs/marked/parser/Blockquote.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { escape } from "lodash";
|
||||
|
||||
export const BLOCKQUOTE_REG = /> ([\S ]+)(\n?)/;
|
||||
|
||||
const renderer = (rawStr: string): string => {
|
||||
const matchResult = rawStr.match(BLOCKQUOTE_REG);
|
||||
if (!matchResult) {
|
||||
return rawStr;
|
||||
}
|
||||
|
||||
return `<blockquote>${escape(matchResult[1])}</blockquote>${matchResult[2]}`;
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "blockqoute",
|
||||
regex: BLOCKQUOTE_REG,
|
||||
renderer,
|
||||
};
|
@ -15,6 +15,7 @@ import InlineCode from "./InlineCode";
|
||||
import PlainText from "./PlainText";
|
||||
import Table from "./Table";
|
||||
import BoldEmphasis from "./BoldEmphasis";
|
||||
import Blockquote from "./Blockquote";
|
||||
|
||||
export { CODE_BLOCK_REG } from "./CodeBlock";
|
||||
export { TODO_LIST_REG } from "./TodoList";
|
||||
@ -26,6 +27,6 @@ export { MARK_REG } from "./Mark";
|
||||
export { TABLE_REG } from "./Table";
|
||||
|
||||
// The order determines the order of execution.
|
||||
export const blockElementParserList = [Table, CodeBlock, TodoList, DoneList, OrderedList, UnorderedList, Paragraph];
|
||||
export const blockElementParserList = [Table, CodeBlock, Blockquote, TodoList, DoneList, OrderedList, UnorderedList, Paragraph];
|
||||
export const inlineElementParserList = [Image, Mark, BoldEmphasis, Bold, Emphasis, Link, InlineCode, PlainLink, Tag, PlainText];
|
||||
export const parserList = [...blockElementParserList, ...inlineElementParserList];
|
||||
|
@ -77,6 +77,10 @@
|
||||
@apply px-4 py-1 text-center border border-gray-300;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote {
|
||||
@apply border-l-4 pl-2 text-gray-400;
|
||||
}
|
||||
}
|
||||
|
||||
> .expand-btn-container {
|
||||
|
Reference in New Issue
Block a user