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

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

22 lines
463 B
TypeScript

import { marked } from "..";
import Emphasis from "./Emphasis";
import Link from "./Link";
export const BOLD_REG = /\*\*([\S ]+)\*\*/;
const renderer = (rawStr: string): string => {
const matchResult = rawStr.match(BOLD_REG);
if (!matchResult) {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], [Emphasis, Link]);
return `<strong>${parsedContent}</strong>`;
};
export default {
name: "bold",
regex: BOLD_REG,
renderer,
};