mirror of https://github.com/usememos/memos
feat: add `inline-code` syntax parser
parent
2298ac6ff3
commit
7b29c65f58
@ -0,0 +1,23 @@
|
|||||||
|
export const INLINE_CODE_REG = /`([\S ]+?)`/;
|
||||||
|
|
||||||
|
const match = (rawStr: string): number => {
|
||||||
|
const matchResult = rawStr.match(INLINE_CODE_REG);
|
||||||
|
if (!matchResult) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchStr = matchResult[0];
|
||||||
|
return matchStr.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderer = (rawStr: string): string => {
|
||||||
|
const parsedStr = rawStr.replace(INLINE_CODE_REG, "<code>$1</code>");
|
||||||
|
return parsedStr;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "inline code",
|
||||||
|
regex: INLINE_CODE_REG,
|
||||||
|
match,
|
||||||
|
renderer,
|
||||||
|
};
|
Loading…
Reference in New Issue