memos/web/src/labs/marked/parser/Blockquote.tsx
boojack 0f8ce3dd16
refactor: return jsx element instead of string in marked (#910)
* refactor: return jsx element instead of string in marked

* chore: update
2023-01-07 00:13:49 +08:00

19 lines
409 B
TypeScript

import { escape } from "lodash";
import { matcher } from "../matcher";
export const BLOCKQUOTE_REG = /^> ([^\n]+)/;
const renderer = (rawStr: string) => {
const matchResult = matcher(rawStr, BLOCKQUOTE_REG);
if (!matchResult) {
return <>{rawStr}</>;
}
return <blockquote>{escape(matchResult[1])}</blockquote>;
};
export default {
name: "blockquote",
regexp: BLOCKQUOTE_REG,
renderer,
};