Giter Site home page Giter Site logo

gitbook-plugin-mermaid's People

Contributors

jozovilcek avatar piranna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitbook-plugin-mermaid's Issues

Wrong name on npm

This plugin should be published on npm as gitbook-plugin-mermaid instead of gitbook-mermaid.

Phantom can not load mermaid.min.js in converter.html

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?

crash when used 'dev' as node id

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

Include diagrams in generated pdf

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!

use mermaidAPI

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 :-)

Load mermaid graphs from external files

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.

Mermaid breaks when a variable ends in 'v'

Steps to reproduce

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

error when running on windows

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

Use directly phantomjs module instead of phantom

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.

Allow title

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 thealtand/ortitle` 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.

Add support for Node 5 and Node 6

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

Add support for Gitbook 3

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.

Hand over gitbook-plugin-mermaid to GitbookIO

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 :)

launch gitbook throw err "Error: Could not locate the bindings file. "

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.