Browse Source

feat: PlantUML markdown module (#1066)

* initial plantuml work

* got plantuml rendering working

* fix: added plantuml module config order
Ethan Davidson 5 years ago
parent
commit
4f8a28f617

+ 1 - 0
package.json

@@ -100,6 +100,7 @@
     "markdown-it-imsize": "2.0.1",
     "markdown-it-mark": "3.0.0",
     "markdown-it-mathjax": "2.0.0",
+    "markdown-it-plantuml": "1.4.1",
     "markdown-it-sub": "1.0.0",
     "markdown-it-sup": "1.0.0",
     "markdown-it-task-lists": "2.1.1",

+ 37 - 0
server/modules/rendering/markdown-plantuml/definition.yml

@@ -0,0 +1,37 @@
+key: markdownPlantuml
+title: PlantUML
+description: PlantUML Markdown Parser
+author: ethanmdavidson
+icon: mdi-sitemap
+enabledDefault: true
+dependsOn: markdownCore
+props:
+  server:
+    type: String
+    default: http://www.plantuml.com/plantuml
+    title: PlantUML Server
+    hint: PlantUML server used for image generation
+    order: 1
+  openMarker:
+    type: String
+    default: "@startuml"
+    title: Open Marker
+    hint: String to use as opening delimiter
+    order: 2
+  closeMarker:
+    type: String
+    default: "@enduml"
+    title: Close Marker
+    hint: String to use as closing delimiter
+    order: 3
+  imageFormat:
+    type: String
+    default: svg
+    title: Image Format
+    hint: Format to use for rendered PlantUML images
+    enum:
+      - svg
+      - png
+      - latex
+      - ascii
+    order: 4

+ 16 - 0
server/modules/rendering/markdown-plantuml/renderer.js

@@ -0,0 +1,16 @@
+const mdPlantUml = require('markdown-it-plantuml')
+
+// ------------------------------------
+// Markdown - PlantUML Preprocessor
+// ------------------------------------
+
+module.exports = {
+  init (md, conf) {
+    md.use(mdPlantUml, {
+      openMarker: conf.openMarker,
+      closeMarker: conf.closeMarker,
+      imageFormat: conf.imageFormat,
+      server: conf.server
+    })
+  }
+}

+ 5 - 0
yarn.lock

@@ -8181,6 +8181,11 @@ 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-plantuml@1.4.1:
+  version "1.4.1"
+  resolved "https://registry.yarnpkg.com/markdown-it-plantuml/-/markdown-it-plantuml-1.4.1.tgz#3bd5e7d92eaa5c6c68eb29802f7b46a8e05ca998"
+  integrity sha512-13KgnZaGYTHBp4iUmGofzZSBz+Zj6cyqfR0SXUIc9wgWTto5Xhn7NjaXYxY0z7uBeTUMlc9LMQq5uP4OM5xCHg==
+
 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"