From 51984d1dba2854e54f76ad3c7458a601baafcf66 Mon Sep 17 00:00:00 2001
From: Klemek
Date: Mon, 19 Aug 2019 13:53:22 +0200
Subject: [PATCH] [skip CI] using TOML instead of YAML
---
README.md | 115 ++++
build_preview.js | 11 +-
docs/index.html | 15 +-
docs/sample.toml | 73 ++
docs/sample.yml | 52 --
docs/toml-parser.js | 1603 +++++++++++++++++++++++++++++++++++++++++++
package-lock.json | 8 +-
package.json | 1 +
8 files changed, 1819 insertions(+), 59 deletions(-)
create mode 100644 docs/sample.toml
delete mode 100644 docs/sample.yml
create mode 100644 docs/toml-parser.js
diff --git a/README.md b/README.md
index 7ce748c..a062ff1 100644
--- a/README.md
+++ b/README.md
@@ -392,6 +392,37 @@ links:
+
+TOML data (click)
+
+
+
+```toml
+[[nodes]]
+name = "node1"
+icon = "laptop-code"
+color = "#4E342E"
+bottom = "my app"
+
+[[nodes]]
+name = "node2"
+icon = "globe"
+color = "#455A64"
+bottom = "world"
+
+[[links]]
+from = "node1"
+to = "node2"
+color = "#333333"
+bottom = '"hello"'
+
+ [links.top]
+ icon = "envelope"
+
+```
+
+
+
### Example 2 : Web App

@@ -549,6 +580,90 @@ links:
type: double
bottom: Sequelize
+```
+
+
+
+
+TOML data (click)
+
+
+
+```toml
+[options.placing]
+diagonals = false
+
+[options.rendering.icons]
+color = "#00695C"
+
+[options.rendering.links]
+color = "#26A69A"
+
+[options.rendering.texts]
+color = "#004D40"
+font = "mono"
+font-size = 12
+margin = 0.25
+
+[options.rendering.sub-icons]
+color = "#004D40"
+
+[[nodes]]
+name = "client"
+icon = "laptop"
+bottom = "user"
+
+[[nodes]]
+name = "page"
+icon = "file-code"
+top = "index.html"
+
+[[nodes]]
+name = "js"
+icon = "js-square"
+bottom = "front-end"
+
+[[nodes]]
+name = "server"
+icon = "node"
+bottom = "back-end"
+
+[[nodes]]
+name = "db"
+icon = "database"
+
+[[links]]
+from = "client"
+to = "page"
+
+[[links]]
+from = "page"
+to = "js"
+type = "double"
+bottom = "VueJS"
+direction = "down"
+
+ [links.top]
+ icon = "vuejs"
+
+[[links]]
+from = "js"
+to = "server"
+type = "split-double"
+direction = "right"
+
+ [links.top]
+ text = "Ajax"
+
+ [links.bottom]
+ text = "JSON"
+
+[[links]]
+from = "db"
+to = "server"
+type = "double"
+bottom = "Sequelize"
+
```
\ No newline at end of file
diff --git a/build_preview.js b/build_preview.js
index 5690bc3..e472755 100644
--- a/build_preview.js
+++ b/build_preview.js
@@ -1,6 +1,7 @@
const fs = require('fs');
const yaml = require('js-yaml');
const svg2img = require('svg2img');
+const toml = require('@iarna/toml');
const rendering = require('./src/rendering')({
'scale': 0.05,
@@ -52,6 +53,7 @@ const generatePreview = (name, exportSample, data) => {
const jsRegex = new RegExp(`\\/\\/ data: ${name}([\\s\\S](?!};))*\n};`, 'm');
const jsonRegex = new RegExp(`\\n\`\`\`json([\\s\\S](?!\`\`\`))*`, 'm');
const yamlRegex = new RegExp(`\\n\`\`\`yaml([\\s\\S](?!\`\`\`))*`, 'm');
+ const tomlRegex = new RegExp(`\\n\`\`\`toml([\\s\\S](?!\`\`\`))*`, 'm');
// JS object
if (jsRegex.test(readme)) {
@@ -73,9 +75,16 @@ ${JSON.stringify(data, null, 2)}`);
\`\`\`yaml
${yaml.safeDump(data)}`);
}
+ // TOML
+ if (tomlRegex.test(readme)) {
+ console.log(`preview ${name}: found TOML definition`);
+ readme = readme.replace(tomlRegex, `
+\`\`\`toml
+${toml.stringify(data)}`);
+ }
if (exportSample)
- fs.writeFileSync('docs/sample.yml', yaml.safeDump(data), {encoding: 'utf-8'});
+ fs.writeFileSync('docs/sample.toml', toml.stringify(data), {encoding: 'utf-8'});
const svg = faDiagrams.compute(data);
fs.writeFileSync(`preview/${name}.svg`, svg, {encoding: 'utf-8'});
svg2img(svg, function(error, buffer) {
diff --git a/docs/index.html b/docs/index.html
index cd2aa1c..d0016f7 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -4,8 +4,8 @@
fa-diagrams example
-
+