jozovilcek / gitbook-plugin-mermaid Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
This plugin should be published on npm as gitbook-plugin-mermaid
instead of gitbook-mermaid
.
My environment is on windows 7 64bit. When I am using this plugin, error happens:
phantom stdout: ReferenceError: Can't find variable: mermaid
phantom stdout: c:%5CUsers%5CHuangFeng%5Cworkspace-cim2%5Cconnector-doc%5Cnode
_modules%5Cgitbook-plugin-mermaid%5Cconvert%5Cconverter.html:10
phantom stdout: ReferenceError: Can't find variable: mermaid
Then I change this line in converter.html:
<script type="text/javascript" src="./assets/mermaid.min.js"></script>
with
<script type="text/javascript">
"I copy the content of mermaid.min.js to here"
</script>
It works after the change.
I think it's because phantom didn't load the external js file in html correctly.
I wanted to try some other better way to fix this, but I failed. Can you help check this?
If one of the graph nodes has 'dev' as node id (with that exact case and no other letter), gitbook crash with the next error:
phantom stdout: TypeError: 'undefined' is not an object (evaluating 'w[0]')
phantom stdout: file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:11
file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:10
file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:13
file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:13
file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:13
file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:13
file:///home/piranna/Universidad%20Rey%20JuanCarlos/pfc/node_modules/gitbook-plugin-mermaid/convert/converter.html:33 in renderToSvg
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():3
phantomjs://webpage.evaluate():3
Template render error: (/home/piranna/Universidad Rey JuanCarlos/pfc/8. apéndices/2. módulos/1. módulos propios/8. nodeos-mount-filesystems.md)
TypeError: Cannot read property 'replace' of null (In file '8. apéndices/2. módulos/1. módulos propios/8. nodeos-mount-filesystems.md')
npm ERR! Linux 3.19.0-27-generic
npm ERR! argv "node" "/usr/bin/npm" "run" "pdf"
npm ERR! node v0.12.7
npm ERR! npm v2.13.2
npm ERR! code ELIFECYCLE
npm ERR! NodeOS@0.0.0 pdf: `gitbook pdf . NodeOS.pdf`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the NodeOS@0.0.0 pdf script 'gitbook pdf . NodeOS.pdf'.
npm ERR! This is most likely a problem with the NodeOS package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! gitbook pdf . NodeOS.pdf
npm ERR! You can get their info via:
npm ERR! npm owner ls NodeOS
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/piranna/Universidad Rey JuanCarlos/pfc/npm-debug.log
Do you have plan to support 'classDiagram' from office mermaid?
Hi!
This is a good feature and its cool to see mermaid diagrams in generated books!
Would it be possible to have the generated diagrams to be included in a generated pdf or ePub? Or are there some obstacle for that? If it is not pissble to use svgs perhaps one could extract the diagrams as pngs using the mermaid cli in the build step with some naming convention and include the pngs in the conversion to pdf/epub?
Thanks for this work!
it is not npm install gitbook-mermaid-plugin
but npm install gitbook-plugin-mermaid
mermaid now has an offline render that directly returns a SVG image. By using it, we could be able to remove all the dependencies on PhantomJS and make the module a lot more simpler and faster :-)
Allow to give an url as argument of the block to load the graph from a file instead of need to embed it in the book content, similar to the url attribute of the html script tag.
Create a simple graph on a README.md (can be any .md)
{% mermaid %}
graph TD;
A(First Box)
B(Second Box)
A-->B
{% endmermaid %}
Now change any variable to end with 'v' and you'll get errors:
{% mermaid %}
graph TD;
Av(First Box)
B(Second Box)
Av-->B
{% endmermaid %}
errors:
phantom stdout: TypeError: 'undefined' is not an object (evaluating 'w[0]')
phantom stdout: .../node_modules/gitbook-plugin-mermaid/convert/assets/mermaid.min.js:11
phantom stdout: phantomjs://webpage.evaluate():3
Template render error: (/README.md)
TypeError: Cannot read property 'replace' of null
D:\dev\mybook>gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...
info: loading book configuration....OK
info: load plugin gitbook-plugin-mermaid ....OK
info: load plugin gitbook-plugin-highlight ....OK
info: load plugin gitbook-plugin-search ....OK
info: load plugin gitbook-plugin-sharing ....OK
info: load plugin gitbook-plugin-fontsettings ....OK
info: load plugin gitbook-plugin-livereload ....OK
info: >> 6 plugins loaded
info: start generation with website generator
info: clean website generator
info: OK
D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\phantom\
node_modules\dnode\node_modules\weak\node_modules\bindings\bindings.js:91
throw err
^
Error: Could not locate the bindings file. Tried:
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\build\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\build\Debug\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\build\Release\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\out\Debug\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\Debug\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\out\Release\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\Release\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\build\default\weakref.node
→ D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_modules\pha
ntom\node_modules\dnode\node_modules\weak\compiled\0.12.0\win32\x64\weakref.node
at bindings (D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node
_modules\phantom\node_modules\dnode\node_modules\weak\node_modules\bindings\bind
ings.js:88:9)
at Object.<anonymous> (D:\dev\mybook\node_modules\gitbook-plugin-me
rmaid\node_modules\phantom\node_modules\dnode\node_modules\weak\lib\weak.js:7:35
)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at new D (D:\dev\mybook\node_modules\gitbook-plugin-mermaid\node_mo
dules\phantom\node_modules\dnode\index.js:28:20)
at module.exports (D:\dev\mybook\node_modules\gitbook-plugin-mermai
d\node_modules\phantom\node_modules\dnode\index.js:8:12)
D:\dev\mybook>
do you have any suggestions what i should diagnose?
thx
phantomjs module automatically installs PhantomJS so it's not needed to be installed externally, so it would help to make books more autocontained and generated by non-tech people just by doing npm install
.
The plugin injects directly the <svg>
tag on the gitbook content. I propose to allow to add an alt
or title
attribute that will instead return an <img> tag with the
altand/or
title` attibute and the content of the generated svg as indicated at http://stackoverflow.com/questions/29274033/show-svg-with-image-tag-in-inline-html-img-tag. This way not only diagrams will be centered as the other images but also would allow plugins like https://plugins.gitbook.com/plugin/image-captions to operate also on the diagrams. I'm willingly to use this on my thesis.
If I install this plugin using Node 4, everything is ok. While if I install it with Node 5.9.1 or 6, I will receive the following errors:
npm WARN deprecated [email protected]: v1 is no longer maintained, please upgrade to v2.0+ as soon possible.
npm WARN deprecated [email protected]: use [cross-spawn](https://github.com/IndigoUnited/node-cross-spawn) or [cross-spawn-async](https://github.com/IndigoUnited/node-cross-spawn-async) instead.
npm WARN enoent ENOENT: no such file or directory, open '/Users/georgejor/projects/<repo>/node_modules/app/package.json'
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/nvm/0.30.1/versions/node/v6.0.0/bin/node" "/usr/local/opt/nvm/versions/node/v6.0.0/bin/npm" "i" "--save" "gitbook-plugin-mermaid"
npm ERR! node v6.0.0
npm ERR! npm v3.8.6
npm ERR! path /Users/georgejor/projects/<repo>/node_modules/.staging/sockjs-client-48d6b838
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/georgejor/projects/<repo>/node_modules/.staging/sockjs-client-48d6b838' -> '/Users/georgejor/projects/<repo>/node_modules/shoe/node_modules/sockjs-client'
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/georgejor/projects/<repo>/node_modules/.staging/sockjs-client-48d6b838' -> '/Users/georgejor/projects/<repo>/node_modules/shoe/node_modules/sockjs-client'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
Please help add support for such issue, thanks
On gitbook v3.0.0-pre1 they have changed the API, so now the plugin totally crash. Please update it to add support for upcoming versions.
I already upgraded lastest MACOS 10.12, but gitbook-plugin-mermaid isnot used normally. Please help me.
Hi @JozoVilcek,
At @GitbookIO, we have noticed a fragmentation of the mermaid plugins for gitbook (with varying quality) https://plugins.gitbook.com/browse?q=mermaid
We would like to maintain an official mermaid plugin, and you own the name gitbook-plugin-mermaid
. The activity on your plugin seems to slow down. We offer to maintain the plugin for you. In exchange we will keep a proper work attribution, and give appropriate credit to you, as the original author of the plugin.
Let me know if you're interested :)
There should be ways that we can modify config of mermaid.
http://knsv.github.io/mermaid/#configuration35
mermaid.sequenceConfig = {
diagramMarginX:50,
diagramMarginY:10,
boxTextMargin:5,
noteMargin:10,
messageMargin:35,
mirrorActors:true
};
Here is the link to the flow chart rendered by the official mermaid editor
But in this gitbook plugin the flowchart is rendered as:
this gitbook-plugin-mermaid is using version 0.5.6 of mermaid and the official editor is using 0.5.8 of mermaid.
But even upgrading the https://github.com/JozoVilcek/gitbook-plugin-mermaid/tree/master/convert/assets/mermaid.min.js and mermaid.css to 0.5.8 does not solve the problem :(
I use npm to get the newest plugin. However, it's still an old version with usage of "```", not the "block" way in master branch.
According to mermaid-js/mermaid#204 (comment), this is needed to generate graphs as wide as possible on the books.
Hello,
There are 7 Mermaid GItbook plugins. They mostly appear the same. Which one is the official, supported, current, Mermaid plugin?
Thanks
Hi, I installed my mermaid from Gitbook Editor Plugin Store, but it doesn't work. When I want to configure
the mermaid plugin, there come out an error "Expected [K, V] tuple: T".
Would you please help me?
There is some problem after i install gitbook-plugin-mermaid
.
How can i resolve this err?
Here is the Content of README.md
:
# Introduction
{% mermaid %}
{% endmermaid%}
here is load log:
info: loading book configuration....OK
info: load plugin gitbook-plugin-mermaid ....OK
info: load plugin gitbook-plugin-katex ....OK
info: load plugin gitbook-plugin-puml ....OK
info: load plugin gitbook-plugin-todo ....OK
info: load plugin gitbook-plugin-highlight ....OK
info: load plugin gitbook-plugin-search ....OK
info: load plugin gitbook-plugin-sharing ....OK
info: load plugin gitbook-plugin-fontsettings ....OK
info: load plugin gitbook-plugin-livereload ....OK
info: >> 9 plugins loaded
/Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/node_modules/bindings/bindings.js:91
throw err
^
Error: Could not locate the bindings file. Tried:
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/build/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/build/Debug/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/build/Release/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/out/Debug/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/Debug/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/out/Release/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/Release/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/build/default/weakref.node
→ /Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/compiled/6.2.1/darwin/x64/weakref.node
at bindings (/Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/node_modules/bindings/bindings.js:88:9)
at Object.<anonymous> (/Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/lib/weak.js:7:35)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at new D (/Users/iyuqi/Work/Indugration/gitbooks/org.omg/uml/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/index.js:28:20)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.