mirror of
https://github.com/usememos/memos.git
synced 2025-10-18 10:16:00 +08:00
12 lines
298 B
TypeScript
12 lines
298 B
TypeScript
export const CODE_BLOCK_REG = /^```(\S*?)\s([\s\S]*?)```(\n?)/;
|
|
|
|
const renderer = (rawStr: string): string => {
|
|
const parsedStr = rawStr.replace(CODE_BLOCK_REG, "<pre lang='$1'>\n$2</pre>$3");
|
|
return parsedStr;
|
|
};
|
|
|
|
export default {
|
|
name: "code block",
|
|
regex: CODE_BLOCK_REG,
|
|
renderer,
|
|
};
|