Unverified Commit abcd3cfa authored by boojack's avatar boojack Committed by GitHub

feat: add `Strikethrough` syntax (#557)

feat: add `Strikethrough` rule
parent 50d41c45
import { inlineElementParserList } from "."; import { inlineElementParserList } from ".";
import { marked } from ".."; import { marked } from "..";
export const DONE_LIST_REG = /^- \[x\] (.+)(\n?)/; export const DONE_LIST_REG = /^- \[[xX]\] (.+)(\n?)/;
const renderer = (rawStr: string): string => { const renderer = (rawStr: string): string => {
const matchResult = rawStr.match(DONE_LIST_REG); const matchResult = rawStr.match(DONE_LIST_REG);
......
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"; ...@@ -16,6 +16,7 @@ import Table from "./Table";
import BoldEmphasis from "./BoldEmphasis"; import BoldEmphasis from "./BoldEmphasis";
import Blockquote from "./Blockquote"; import Blockquote from "./Blockquote";
import HorizontalRules from "./HorizontalRules"; import HorizontalRules from "./HorizontalRules";
import Strikethrough from "./Strikethrough";
export { CODE_BLOCK_REG } from "./CodeBlock"; export { CODE_BLOCK_REG } from "./CodeBlock";
export { TODO_LIST_REG } from "./TodoList"; export { TODO_LIST_REG } from "./TodoList";
...@@ -38,5 +39,5 @@ export const blockElementParserList = [ ...@@ -38,5 +39,5 @@ export const blockElementParserList = [
UnorderedList, UnorderedList,
Paragraph, 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]; export const parserList = [...blockElementParserList, ...inlineElementParserList];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment