mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
@@ -1,7 +1,7 @@
|
||||
import { inlineElementParserList } from ".";
|
||||
import { marked } from "..";
|
||||
|
||||
export const DONE_LIST_REG = /^- \[x\] (.+)(\n?)/;
|
||||
export const DONE_LIST_REG = /^- \[[xX]\] (.+)(\n?)/;
|
||||
|
||||
const renderer = (rawStr: string): string => {
|
||||
const matchResult = rawStr.match(DONE_LIST_REG);
|
||||
|
19
web/src/labs/marked/parser/Strikethrough.ts
Normal file
19
web/src/labs/marked/parser/Strikethrough.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { marked } from "..";
|
||||
|
||||
export const STRIKETHROUGH_REG = /~~(.+?)~~/;
|
||||
|
||||
const renderer = (rawStr: string): string => {
|
||||
const matchResult = rawStr.match(STRIKETHROUGH_REG);
|
||||
if (!matchResult) {
|
||||
return rawStr;
|
||||
}
|
||||
|
||||
const parsedContent = marked(matchResult[1], [], []);
|
||||
return `<del>${parsedContent}</del>`;
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "Strikethrough",
|
||||
regex: STRIKETHROUGH_REG,
|
||||
renderer,
|
||||
};
|
@@ -16,6 +16,7 @@ import Table from "./Table";
|
||||
import BoldEmphasis from "./BoldEmphasis";
|
||||
import Blockquote from "./Blockquote";
|
||||
import HorizontalRules from "./HorizontalRules";
|
||||
import Strikethrough from "./Strikethrough";
|
||||
|
||||
export { CODE_BLOCK_REG } from "./CodeBlock";
|
||||
export { TODO_LIST_REG } from "./TodoList";
|
||||
@@ -38,5 +39,5 @@ export const blockElementParserList = [
|
||||
UnorderedList,
|
||||
Paragraph,
|
||||
];
|
||||
export const inlineElementParserList = [Image, BoldEmphasis, Bold, Emphasis, Link, InlineCode, PlainLink, Tag, PlainText];
|
||||
export const inlineElementParserList = [Image, BoldEmphasis, Bold, Emphasis, Link, InlineCode, PlainLink, Strikethrough, Tag, PlainText];
|
||||
export const parserList = [...blockElementParserList, ...inlineElementParserList];
|
||||
|
Reference in New Issue
Block a user