diff --git a/web/src/labs/marked/marked.test.ts b/web/src/labs/marked/marked.test.ts index 04414fea..fb9f5e5a 100644 --- a/web/src/labs/marked/marked.test.ts +++ b/web/src/labs/marked/marked.test.ts @@ -157,43 +157,6 @@ console.log("hello world!") expect(unescape(marked(t.markdown))).toBe(t.want); } }); - test("parse table", () => { - const tests = [ - { - markdown: `text above the table -| a | b | c | -|---|---|---| -| 1 | 2 | 3 | -| 4 | 5 | 6 | -text below the table -`, - want: `
text above the table
-a | b | c | -
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
text below the table
-`, - }, - { - markdown: `| a | b | c | -| 1 | 2 | 3 | -| 4 | 5 | 6 |`, - want: `| a | b | c |
-| 1 | 2 | 3 |
-| 4 | 5 | 6 |
`, - }, - ]; - for (const t of tests) { - expect(unescape(marked(t.markdown))).toBe(t.want); - } - }); test("parse full width space", () => { const tests = [ { diff --git a/web/src/labs/marked/parser/Table.ts b/web/src/labs/marked/parser/Table.ts deleted file mode 100644 index e267a3cd..00000000 --- a/web/src/labs/marked/parser/Table.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Match markdown table - * example: - * | a | b | c | - * |---|---|---| - * | 1 | 2 | 3 | - * | 4 | 5 | 6 | - */ -export const TABLE_REG = /^(\|.*\|)(?:(?:\n(?:\|-*)+\|))((?:\n\|.*\|)+)(\n?)/; - -const renderer = (rawStr: string): string => { - const matchResult = rawStr.match(TABLE_REG); - if (!matchResult) { - return rawStr; - } - const tableHeader = matchResult[1] - .split("|") - .filter((str) => str !== "") - .map((str) => str.trim()); - const tableBody = matchResult[2] - .trim() - .split("\n") - .map((str) => - str - .split("|") - .filter((str) => str !== "") - .map((str) => str.trim()) - ); - return `${str} | `).join("")} -
---|
${str} | `).join("")}