memos/web/src/labs/marked/parser/Paragraph.ts
boojack eaf89aa2f2
feat: update marked parsers (#260)
* chore: remove external match functions

* chore: update parsers
2022-10-04 10:44:16 +08:00

20 lines
481 B
TypeScript

import { inlineElementParserList } from ".";
import { marked } from "..";
export const PARAGRAPH_REG = /^([\S ]*)(\n?)/;
const renderer = (rawStr: string): string => {
const matchResult = rawStr.match(PARAGRAPH_REG);
if (!matchResult) {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], inlineElementParserList);
return `<p>${parsedContent}</p>${matchResult[2]}`;
};
export default {
name: "ordered list",
regex: PARAGRAPH_REG,
renderer,
};