mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
* feat: simple markdown parser * chore: rename test file name * feat: add plain text link parser * chore: update style
24 lines
472 B
TypeScript
24 lines
472 B
TypeScript
export const IMAGE_REG = /!\[.*?\]\((.+?)\)/;
|
|
|
|
const match = (rawStr: string): number => {
|
|
const matchResult = rawStr.match(IMAGE_REG);
|
|
if (!matchResult) {
|
|
return 0;
|
|
}
|
|
|
|
const matchStr = matchResult[0];
|
|
return matchStr.length;
|
|
};
|
|
|
|
const renderer = (rawStr: string): string => {
|
|
const parsedStr = rawStr.replace(IMAGE_REG, "<img class='img' src='$1' />");
|
|
return parsedStr;
|
|
};
|
|
|
|
export default {
|
|
name: "image",
|
|
regex: IMAGE_REG,
|
|
match,
|
|
renderer,
|
|
};
|