mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
28 lines
577 B
TypeScript
28 lines
577 B
TypeScript
import { marked } from "..";
|
|
import Link from "./Link";
|
|
import PlainText from "./PlainText";
|
|
|
|
export const BOLD_REG = /\*\*(.+?)\*\*/;
|
|
|
|
const matcher = (rawStr: string) => {
|
|
const matchResult = rawStr.match(BOLD_REG);
|
|
return matchResult;
|
|
};
|
|
|
|
const renderer = (rawStr: string): string => {
|
|
const matchResult = matcher(rawStr);
|
|
if (!matchResult) {
|
|
return rawStr;
|
|
}
|
|
|
|
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
|
|
return `<strong>${parsedContent}</strong>`;
|
|
};
|
|
|
|
export default {
|
|
name: "bold",
|
|
regex: BOLD_REG,
|
|
matcher,
|
|
renderer,
|
|
};
|