Fixed double quotes, docs, demo and added more examples to run script

This commit is contained in:
Nikolay Rozhkov 2023-06-29 20:16:25 +03:00
parent e24dce10a2
commit 9177350a39
5 changed files with 56 additions and 19 deletions

View File

@ -18,20 +18,48 @@
<h2>Energy flow</h2>
<pre class="mermaid">
sankey-beta
Agricultural 'waste',Bio-conversion,124.729
%% There are leading and trailing spaces, do not crop
Agricultural 'waste',Bio-conversion,124.729
%% line with a comment
%% Normal line
Bio-conversion,Liquid,0.597
%% Line with unquoted sankey keyword
sankey,target,10
%% Quoted sankey keyword
"sankey",target,10
%% Another normal line
Bio-conversion,Losses,26.862
Bio-conversion,Solid,280.322
%% Line with integer amount
Bio-conversion,Solid,280
%% Some blank lines in the middle of CSV
%% Another normal line
Bio-conversion,Gas,81.144
Biofuel imports,Liquid,35
Biomass imports,Solid,35
%% Quoted line
"Biofuel imports",Liquid,35
%% Quoted line with escaped quotes inside
"""Biomass imports""",Solid,35
%% Lines containing commas inside
%% Quoted and unquoted values should be equal in terms of graph
"District heating","Heating and cooling, commercial",22.505
District heating,"Heating and cooling, homes",46.184
%% A bunch of lines, normal CSV
Coal imports,Coal,11.606
Coal reserves,Coal,63.965
Coal,Solid,75.571
District heating,Industry,10.639
District heating,Heating and cooling - commercial,22.505
District heating,Heating and cooling - homes,46.184
Electricity grid,Over generation / exports,104.453
Electricity grid,Heating and cooling - homes,113.726
Electricity grid,H2 conversion,27.14
@ -85,8 +113,12 @@
Thermal generation,District heating,79.329
Tidal,Electricity grid,9.452
UK land based bioenergy,Bio-conversion,182.01
Wave,Electricity grid,19.013
Wind,Electricity grid,289.366
"""Wave""",Electricity grid,19.013
"""Wind""",Electricity grid,289.366
%% lines at the end, do not remove
</pre>
<script type="module">

View File

@ -93,7 +93,7 @@ Thermal generation,District heating,79.329
Tidal,Electricity grid,9.452
UK land based bioenergy,Bio-conversion,182.01
"""Wave""",Electricity grid,19.013
Wind,Electricity grid,289.366
"""Wind""",Electricity grid,289.366
%% lines at the end, do not remove

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -50,8 +50,8 @@ opt_eof: EOF | ;
record
: field\[source] COMMA field\[target] COMMA field\[value] {
const source = yy.findOrCreateNode($source.trim());
const target = yy.findOrCreateNode($target.trim());
const source = yy.findOrCreateNode($source.trim().replaceAll('""', '"'));
const target = yy.findOrCreateNode($target.trim().replaceAll('""', '"'));
const value = parseFloat($value.trim());
yy.addLink(source,target,value);
} // parse only 3 fields, this is not part of CSV standard

View File

@ -230,7 +230,7 @@ Pumped heat,"Heating and cooling ""homes""",193.026
Pumped heat,"Heating and cooling, ""commercial""",70.672
```
### Coloring and Фlignment
### Coloring and Alignment
You can change graph layout by setting `nodeAlignment` to:

17
run
View File

@ -28,13 +28,18 @@ help)
# Alignment of help message must be as it is, it will be nice looking when printed
usage=$(
cat <<EOF
Run commands within docker containers.
Development quick start guide:
Welcome to Mermaid Local Docker Development
Script for runnign commands within docker containers.
__________________________________________________________________________________________
\033[1mDevelopment quick start guide\033[0m:
\033[1m$name pnpm install\033[0m # Install packages
\033[1m$name dev\033[0m # Run dev server with examples, open http://localhost:9000
\033[1m$name docs:dev\033[0m # For docs contributions, open http://localhost:3333
\033[1m$name pnpm build\033[0m # Prepare it for production
\033[1m$name docs:dev\033[0m # Then add documentation, open http://localhost:3333
__________________________________________________________________________________________
Commands:
@ -45,16 +50,16 @@ $name docs:dev # For docs contributions, open http://localhost:33
$name sh # Open 'sh' inside docker container for development
$name help # Show this help
__________________________________________________________________________________________
Examples of frequiently used commands:
$name pnpm add # Add package, 'run add d3-sankey'
$name pnpm prettier --write # Prettify a file 'run prettier <path-to-file>'
# git diff --name-only develop | xargs run pnpm prettier --write
$name pnpm prettier --write # Prettify a file 'run prettier <path-to-file>', e.g.:
# 'git diff --name-only develop | xargs run pnpm prettier --write'
$name pnpm test # Run unit tests
$name pnpm vitest # Run watcher for unit tests
$name pnpm e2e # Run integration tests
$name pnpm -w run lint:fix
EOF
)