2
0
Эх сурвалжийг харах

feat: support MultiMarkdown tables (#2126)

Regev Brody 4 жил өмнө
parent
commit
41327dd1e8

+ 2 - 0
client/components/editor/editor-markdown.vue

@@ -228,6 +228,7 @@ import mdAbbr from 'markdown-it-abbr'
 import mdSup from 'markdown-it-sup'
 import mdSub from 'markdown-it-sub'
 import mdMark from 'markdown-it-mark'
+import mdMultiTable from 'markdown-it-multimd-table'
 import mdFootnote from 'markdown-it-footnote'
 import mdImsize from 'markdown-it-imsize'
 import katex from 'katex'
@@ -287,6 +288,7 @@ const md = new MarkdownIt({
   .use(mdAbbr)
   .use(mdSup)
   .use(mdSub)
+  .use(mdMultiTable, {multiline: true, rowspan: true, headerless: true})
   .use(mdMark)
   .use(mdFootnote)
   .use(mdImsize)

+ 1 - 0
package.json

@@ -114,6 +114,7 @@
     "markdown-it-imsize": "2.0.1",
     "markdown-it-mark": "3.0.0",
     "markdown-it-mathjax": "2.0.0",
+    "markdown-it-multimd-table": "4.0.2",
     "markdown-it-sub": "1.0.0",
     "markdown-it-sup": "1.0.0",
     "markdown-it-task-lists": "2.1.1",

+ 23 - 0
server/modules/rendering/markdown-multi-table/definition.yml

@@ -0,0 +1,23 @@
+key: markdownMultiTable
+title: MultiMarkdown Table
+description: Add MultiMarkdown table support
+author: requarks.io
+icon: mdi-table
+enabledDefault: false
+dependsOn: markdownCore
+props:
+  multilineEnabled:
+    type: Boolean
+    title: Multiline
+    hint: Enable multiple lines rows
+    default: true
+  headerlessEnabled:
+    type: Boolean
+    title: Headerless
+    hint: Enable ommited table headers
+    default: true
+  rowspanEnabled:
+    type: Boolean
+    title: Rowspan
+    hint: Enable table row spans
+    default: true

+ 11 - 0
server/modules/rendering/markdown-multi-table/renderer.js

@@ -0,0 +1,11 @@
+const multiTable = require('markdown-it-multimd-table')
+
+module.exports = {
+  init (md, conf) {
+    md.use(multiTable, {
+      multiline: conf.multilineEnabled,
+      rowspan: conf.rowspanEnabled,
+      headerless: conf.headerlessEnabled
+    })
+  }
+}

+ 25 - 0
yarn.lock

@@ -11163,6 +11163,13 @@ lines-and-columns@^1.1.6:
   resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
   integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
 
+linkify-it@^2.0.0:
+  version "2.2.0"
+  resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf"
+  integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==
+  dependencies:
+    uc.micro "^1.0.1"
+
 linkify-it@^3.0.1:
   version "3.0.2"
   resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.2.tgz#f55eeb8bc1d3ae754049e124ab3bb56d97797fb8"
@@ -11596,6 +11603,13 @@ markdown-it-mathjax@2.0.0:
   resolved "https://registry.yarnpkg.com/markdown-it-mathjax/-/markdown-it-mathjax-2.0.0.tgz#ae2b4f4c5c719a03f9e475c664f7b2685231d9e9"
   integrity sha1-ritPTFxxmgP55HXGZPeyaFIx2ek=
 
+markdown-it-multimd-table@4.0.2:
+  version "4.0.2"
+  resolved "https://registry.yarnpkg.com/markdown-it-multimd-table/-/markdown-it-multimd-table-4.0.2.tgz#3dfbdb35356fa5e3de85e6868985dddcd1051e17"
+  integrity sha512-SlcssTj7FoYstVQ7MsM8A46/lhbN1K6/q0e9v56o/5kaWmTheXZXQX3nuZgw7WQocn+3nyQGcoO7ovcqeFxaAw==
+  dependencies:
+    markdown-it "^8.4.2"
+
 markdown-it-sub@1.0.0:
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/markdown-it-sub/-/markdown-it-sub-1.0.0.tgz#375fd6026eae7ddcb012497f6411195ea1e3afe8"
@@ -11622,6 +11636,17 @@ markdown-it@11.0.0:
     mdurl "^1.0.1"
     uc.micro "^1.0.5"
 
+markdown-it@^8.4.2:
+  version "8.4.2"
+  resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
+  integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==
+  dependencies:
+    argparse "^1.0.7"
+    entities "~1.1.1"
+    linkify-it "^2.0.0"
+    mdurl "^1.0.1"
+    uc.micro "^1.0.5"
+
 math-expression-evaluator@^1.2.14:
   version "1.2.17"
   resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac"