You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
memos/web/src/labs/marked/parser/Mark.ts

19 lines
409 B
TypeScript

import { escape } from "lodash-es";
export const MARK_REG = /@\[(.+?)\]\((\S+?)\)/;
const renderer = (rawStr: string): string => {
const matchResult = rawStr.match(MARK_REG);
if (!matchResult) {
return rawStr;
}
return `<span class='memo-link-text' data-value='${escape(matchResult[2])}'>${escape(matchResult[1])}</span>`;
};
export default {
name: "mark",
regex: MARK_REG,
renderer,
};