Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: remove table syntax (#669)
boojack1ea74dfd0d3b
diff --git a/web/src/labs/marked/marked.test.ts b/web/src/labs/marked/marked.test.tsindex 04414fea9..fb9f5e5a7 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: `<p>text above the table</p>-<table>- <thead>- <tr>- <th>a</th><th>b</th><th>c</th>- </tr>- </thead>- <tbody>- <tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr>- </tbody>-</table>-<p>text below the table</p>-`,- },- {- markdown: `| a | b | c |-| 1 | 2 | 3 |-| 4 | 5 | 6 |`,- want: `<p>| a | b | c |</p>-<p>| 1 | 2 | 3 |</p>-<p>| 4 | 5 | 6 |</p>`,- },- ];- 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.tsdeleted file mode 100644index e267a3cd1..000000000--- 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 `<table>- <thead>- <tr>- ${tableHeader.map((str) => `<th>${str}</th>`).join("")}- </tr>- </thead>- <tbody>- ${tableBody.map((row) => `<tr>${row.map((str) => `<td>${str}</td>`).join("")}</tr>`).join("")}- </tbody>-</table>${matchResult[3]}`;-};--export default {- name: "table",- regex: TABLE_REG,- renderer,-};diff --git a/web/src/labs/marked/parser/index.ts b/web/src/labs/marked/parser/index.tsindex 89434adf7..fcf28d828 100644--- a/web/src/labs/marked/parser/index.ts+++ b/web/src/labs/marked/parser/index.ts@@ -12,7 +12,6 @@ import Emphasis from "./Emphasis";import PlainLink from "./PlainLink";import InlineCode from "./InlineCode";import PlainText from "./PlainText";-import Table from "./Table";import BoldEmphasis from "./BoldEmphasis";import Blockquote from "./Blockquote";import HorizontalRules from "./HorizontalRules";@@ -24,20 +23,9 @@ export { DONE_LIST_REG } from "./DoneList";export { TAG_REG } from "./Tag";export { IMAGE_REG } from "./Image";export { LINK_REG } from "./Link";-export { TABLE_REG } from "./Table";export { HORIZONTAL_RULES_REG } from "./HorizontalRules";// The order determines the order of execution.-export const blockElementParserList = [- HorizontalRules,- Table,- CodeBlock,- Blockquote,- TodoList,- DoneList,- OrderedList,- UnorderedList,- Paragraph,-];+export const blockElementParserList = [HorizontalRules, CodeBlock, Blockquote, TodoList, DoneList, OrderedList, UnorderedList, Paragraph];export const inlineElementParserList = [Image, BoldEmphasis, Bold, Emphasis, Link, InlineCode, PlainLink, Strikethrough, Tag, PlainText];export const parserList = [...blockElementParserList, ...inlineElementParserList];