raghur / mermaid-filter Goto Github PK
View Code? Open in Web Editor NEWPandoc filter for creating diagrams in mermaid syntax blocks in markdown docs
Pandoc filter for creating diagrams in mermaid syntax blocks in markdown docs
Hi. I wanted to use the filter with pandoc on a Windows 10, but got this error:
Error: ENOENT: no such file or directory, open 'C:\Users\Mr\AppData\Local\Temp\tmp-1392pd059WckYir6.tmp.png'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at mermaid (C:\Users\Mr\AppData\Roaming\npm\node_modules\mermaid-filter\index.js:83:27)
at C:\Users\Mr\AppData\Roaming\npm\node_modules\mermaid-filter\index.js:143:12
at C:\Users\Mr\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:52:19
at Array.forEach (<anonymous>)
at walk (C:\Users\Mr\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:50:7)
at C:\Users\Mr\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:74:16
at Array.forEach (<anonymous>)
at walk (C:\Users\Mr\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:73:20) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'C:\\Users\\Mr\\AppData\\Local\\Temp\\tmp-1392pd059WckYir6.tmp.png'
}
The command looks like this:
pandoc test.md --pdf-engine=wkhtmltopdf --metadata title="test" -o test.pdf -F mermaid-filter.cmd
Trying to use mermaid-filter from linux openSuse Tumbleweed using pandoc version 1.19.2.1 and node v6.9.5 and npm 3.10.10. I'm getting the following error:
You had errors in your syntax. Use --help for further information.
Could not find phantomjs at the specified path.
fs.js:809
return binding.rename(pathModule._makeLong(oldPath),
^
Error: ENOENT: no such file or directory, rename 'inline/tmp-21291MMU47r258Sll.tmp.png' -> 'inline/diagram-2.png'
at Error (native)
at Object.fs.renameSync (fs.js:809:18)
at mermaid (/usr/local/lib/node_modules/mermaid-filter/index.js:50:12)
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:50:7)
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:74:16
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:73:20)
at filter (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:36:10)
The only suspicious thing I saw was a warning about phantomjs being old, and that I should use phantomjs-prebuilt package instead which appeared when I installed mermaid-filter from npm.
Any idea why?
Thanks
Would it be possible to configure somehow the mermaid diagram?
I'm thinking specifically about the mirrorActor(s?) option in sequence diagrams
Other useful options that would be nice to be able to configure are the actor box size... See https://github.com/knsv/mermaid/blob/master/src/mermaidAPI.js
Thanks!!
When formatting a node with brackets eg id1(Some Text) Mermaid filter fails and appears to hangs indefinitely.
## Steps to reproduce
Create a node such as
graph
aNode(some text)
I'm using pandoc 2.11.2 with default PDF engine (pdflatex) to get a PDF from
Un diagramme de classe UML
```mermaid
classDiagram
class MaEntité {
+ maCléPrimaire
+ monAttribut1
+ monAttribut2
}
```
pandoc foo.md -o foo.pdf -F mermaid-filter
I'm using [email protected], with all dependencies installed.
Is there a way to improve the image's resolution?
The acute accent is blurred on GitLab CI output
Hi,
the filter works great - for .pdf or .html output. When using .tex as output, the figure does not get generated, though. I have a pipeline that cannot let pandoc do all the work, but rely on pandoc to output .tex and finalize with a normal xetex/latexmk step.
I guess it would involve to keep the generated graph image around and pandoc would generate \figure{... \includegraphics{/path/to/mermaid/graphs/graph1.png} ...} or something like that. currently, I get either no \figure at all, or a \figure with no content, while the same thing works when converting to .pdf.
Could you tell me if that is something this filter could do, and I am just missing a simple thing? If this is not the goal of this filter, to keep generated stuff around after the filter has run -- could you tell me if there is some other approach to make it happen like I described?
Running a file with your test snippet in the readme, I get the following:
Message:
pandoc exited with code 83: (node:17947) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to launch chrome!
[1203/152112.372882:FATAL:zygote_host_impl_linux.cc(123)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x560c4fcd0857 base::debug::StackTrace::StackTrace()
#1 0x560c4fce7041 logging::LogMessage::~LogMessage()
#2 0x560c4ee94711 content::ZygoteHostImpl::Init()
#3 0x560c4eb28da0 content::BrowserMainLoop::EarlyInitialization()
#4 0x560c4eb2f2de content::BrowserMainRunnerImpl::Initialize()
#5 0x560c53916dd6 headless::HeadlessContentMainDelegate::RunProcess()
#6 0x560c4fa1c9e7 content::RunNamedProcessTypeMain()
#7 0x560c4fa1d421 content::ContentMainRunnerImpl::Run()
#8 0x560c4fa2619d service_manager::Main()
#9 0x560c4fa1bf52 content::ContentMain()
#10 0x560c53916075 headless::(anonymous namespace)::RunContentMain()
#11 0x560c539160ea headless::HeadlessBrowserMain()
#12 0x560c4fa231b1 headless::HeadlessShellMain()
#13 0x560c4e4851bd ChromeMain
#14 0x7f6fea60ff6a __libc_start_main
#15 0x560c4e485029 <unknown>
Received signal 6
#0 0x560c4fcd0857 base::debug::StackTrace::StackTrace()
#1 0x560c4fcd03bf base::debug::(anonymous namespace)::StackDumpSignalHandler()
#2 0x7f6ff0a2ada0 <unknown>
#3 0x7f6fea6238a0 __GI_raise
#4 0x7f6fea624f09 __GI_abort
#5 0x560c4fccf402 base::debug::BreakDebugger()
#6 0x560c4fce742a logging::LogMessage::~LogMessage()
#7 0x560c4ee94711 content::ZygoteHostImpl::Init()
#8 0x560c4eb28da0 content::BrowserMainLoop::EarlyInitialization()
#9 0x560c4eb2f2de content::BrowserMainRunnerImpl::Initialize()
#10 0x560c53916dd6 headless::HeadlessContentMainDelegate::RunProcess()
#11 0x560c4fa1c9e7 content::RunNamedProcessTypeMain()
#12 0x560c4fa1d421 content::ContentMainRunnerImpl::Run()
#13 0x560c4fa2619d service_manager::Main()
#14 0x560c4fa1bf52 content::ContentMain()
#15 0x560c53916075 headless::(anonymous namespace)::RunContentMain()
#16 0x560c539160ea headless::HeadlessBrowserMain()
#17 0x560c4fa231b1 headless::HeadlessShellMain()
#18 0x560c4e4851bd ChromeMain
#19 0x7f6fea60ff6a __libc_start_main
#20 0x560c4e485029 <unknown>
r8: 0000000000000000 r9: 00007fff89d89710 r10: 0000000000000008 r11: 0000000000000246
r12: 00007fff89d89e30 r13: 0000000000000161 r14: 00007fff89d89e28 r15: 00007fff89d89e20
di: 0000000000000002 si: 00007fff89d89710 bp: 00007fff89d899d0 bx: 0000000000000006
dx: 0000000000000000 ax: 0000000000000000 cx: 00007f6fea6238a0 sp: 00007fff89d89710
ip: 00007f6fea6238a0 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
(node:17947) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
fs.js:648
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/tmp/tmp-17905UFHHhEDJTzoS.tmp.png'
at Object.fs.openSync (fs.js:648:18)
at Object.fs.readFileSync (fs.js:553:33)
at mermaid (/home/haozeke/.config/yarn/global/node_modules/mermaid-filter/index.js:63:27)
at /home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (<anonymous>)
at walk (/home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:50:7)
at /home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:74:16
at Array.forEach (<anonymous>)
at walk (/home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:73:20)
at filter (/home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:36:10)
Error running filter mermaid-filter:
Filter returned error status 1
Details:
domainEmitter: [object Object]
domain: [object Object]
domainThrown: false
Stack:
Error: pandoc exited with code 83: (node:17947) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to launch chrome!
[1203/152112.372882:FATAL:zygote_host_impl_linux.cc(123)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x560c4fcd0857 base::debug::StackTrace::StackTrace()
#1 0x560c4fce7041 logging::LogMessage::~LogMessage()
#2 0x560c4ee94711 content::ZygoteHostImpl::Init()
#3 0x560c4eb28da0 content::BrowserMainLoop::EarlyInitialization()
#4 0x560c4eb2f2de content::BrowserMainRunnerImpl::Initialize()
#5 0x560c53916dd6 headless::HeadlessContentMainDelegate::RunProcess()
#6 0x560c4fa1c9e7 content::RunNamedProcessTypeMain()
#7 0x560c4fa1d421 content::ContentMainRunnerImpl::Run()
#8 0x560c4fa2619d service_manager::Main()
#9 0x560c4fa1bf52 content::ContentMain()
#10 0x560c53916075 headless::(anonymous namespace)::RunContentMain()
#11 0x560c539160ea headless::HeadlessBrowserMain()
#12 0x560c4fa231b1 headless::HeadlessShellMain()
#13 0x560c4e4851bd ChromeMain
#14 0x7f6fea60ff6a __libc_start_main
#15 0x560c4e485029 <unknown>
Received signal 6
#0 0x560c4fcd0857 base::debug::StackTrace::StackTrace()
#1 0x560c4fcd03bf base::debug::(anonymous namespace)::StackDumpSignalHandler()
#2 0x7f6ff0a2ada0 <unknown>
#3 0x7f6fea6238a0 __GI_raise
#4 0x7f6fea624f09 __GI_abort
#5 0x560c4fccf402 base::debug::BreakDebugger()
#6 0x560c4fce742a logging::LogMessage::~LogMessage()
#7 0x560c4ee94711 content::ZygoteHostImpl::Init()
#8 0x560c4eb28da0 content::BrowserMainLoop::EarlyInitialization()
#9 0x560c4eb2f2de content::BrowserMainRunnerImpl::Initialize()
#10 0x560c53916dd6 headless::HeadlessContentMainDelegate::RunProcess()
#11 0x560c4fa1c9e7 content::RunNamedProcessTypeMain()
#12 0x560c4fa1d421 content::ContentMainRunnerImpl::Run()
#13 0x560c4fa2619d service_manager::Main()
#14 0x560c4fa1bf52 content::ContentMain()
#15 0x560c53916075 headless::(anonymous namespace)::RunContentMain()
#16 0x560c539160ea headless::HeadlessBrowserMain()
#17 0x560c4fa231b1 headless::HeadlessShellMain()
#18 0x560c4e4851bd ChromeMain
#19 0x7f6fea60ff6a __libc_start_main
#20 0x560c4e485029 <unknown>
r8: 0000000000000000 r9: 00007fff89d89710 r10: 0000000000000008 r11: 0000000000000246
r12: 00007fff89d89e30 r13: 0000000000000161 r14: 00007fff89d89e28 r15: 00007fff89d89e20
di: 0000000000000002 si: 00007fff89d89710 bp: 00007fff89d899d0 bx: 0000000000000006
dx: 0000000000000000 ax: 0000000000000000 cx: 00007f6fea6238a0 sp: 00007fff89d89710
ip: 00007f6fea6238a0 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
(node:17947) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
fs.js:648
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/tmp/tmp-17905UFHHhEDJTzoS.tmp.png'
at Object.fs.openSync (fs.js:648:18)
at Object.fs.readFileSync (fs.js:553:33)
at mermaid (/home/haozeke/.config/yarn/global/node_modules/mermaid-filter/index.js:63:27)
at /home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (<anonymous>)
at walk (/home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:50:7)
at /home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:74:16
at Array.forEach (<anonymous>)
at walk (/home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:73:20)
at filter (/home/haozeke/.config/yarn/global/node_modules/pandoc-filter/index.js:36:10)
Error running filter mermaid-filter:
Filter returned error status 1
at ChildProcess.<anonymous> (/home/haozeke/Github/Pandoc/grimoire/node_modules/metalsmith-pandoc/index.js:90:21)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:927:16)
at Socket.stream.socket.on (internal/child_process.js:348:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at Pipe._handle.close [as _onclose] (net.js:557:12)
I can't get mermaid filter to work on Windows 10.
pandoc --version: 2.2.1
Installed with npm: npm install --global mermaid-filter
What does that mean:
WINDOWS - you need mermaid-filter.cmd in the line above
By running AppData\Roaming\npm\mermaid-filter.cmd nothing happens.
Thx
I setup pandoc
with mermaid-filter
in a docker machine.
Chrome has various issues to run in docker image. I need to pass a config value --no-sandbox
to chrome
via puppeteer
and mermaid.cli
.
mermaid.cli
supports a config file value -p --puppeteerConfigFile [puppeteerConfigFile] JSON configuration file for puppeteer. Optional
. But mermaid-filter does not.
Allow to pass the configuration file option.
When use autonumber option in a sequenceDiagram Mermaid filter fails and appears to hangs indefinitely.
use a markdown file such as
~~~mermaid
sequenceDiagram
autonumber
Alice->>John: Hello John, how are you?
~~~
Can be fixed by adding quotes to return value of function externalTool (index.js).
Hi ragbur,
I followed your comment #27 (comment), change the following part
var options = {
width: process.env.MERMAID_FILTER_WIDTH || 800,
format: process.env.MERMAID_FILTER_FORMAT || 'png',
loc: process.env.MERMAID_FILTER_LOC || 'inline',
theme: process.env.MERMAID_FILTER_THEME || 'forest',
caption: process.env.MERMAID_FILTER_CAPTION || '',
filename: process.env.MERMAID_FILTER_FILENAME || ''
};
to
format: process.env.MERMAID_FILTER_FORMAT || 'svg',
but pandoc doesn't generate any diagram. Do I have to change MERMAID_FILTER_WIDTH
, too, since number of pixels certainly doesn't make sense to svg.
Using the example from the documentation:
~~~ {.mermaid}
graph LR;
A-->B;
click B "http://www.github.com" "This is a link"
~~~
and the compilation command:
pandoc -s -o test-mermaidFilter-node-links.html -F mermaid-filter test-mermaidFilter-node-links.md
it creates the expected graph, but the nodes can't be clicked. Clicking works for PDF output. Is this implemented for HTML?
Because pandoc pdf generation converts markdown figure as \includegraphics{}
, which doesn't support svg format as input.
It will be very useful that mermaid-filter adds the support to generate pdf format, like
sequenceDiagram
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
The current fliter can still output pdf if I set format=pdf loc=images
. The inline doesn't work.
I've hit this issue on Windows 10 using pandoc to translate to PDF.
I have a workaround which involves replacing line 5 of mermaid-filter\index.js
to use graceful-fs rather than fs.
This 'fixes' the issue...
Is this a change you would consider in a new release...?
I've had a look at index.js about why width is always limited under 500px no matter .mermaid-config.json has width option.
MERMAID_FILTER_WIDTH
or by default, 500: width: process.env.MERMAID_FILTER_WIDTH || '500',
-w
along with configuration file: ${cmd} ${confFileOpts} ${puppeteerOpts} -w ${options.width} -i ${tmpfileObj.name} -t ${options.theme} -o ${savePath}
-w ${options.width}
which explains why generated image's width is < 500 px.MERMAID_FILTER_WIDTH=800 pandoc ... -F mermaid-filter ...
.Hi, thanks for your project which enables me to use markdown for documentation easily. However, I've got an issue with width of mermaid diagram image.
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram functionality to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d
generated by mermaid-filter(recent version) like pandoc -f gfm Markdown.md -F mermaid-filter -t html5 -H header.html --self-contained -o Markdown.html
without any css / json configuration files.
generated by mermaid-cli(recent version) like mmdc -i test.mmd -o test.png
without any command line arguments.
I'm not too sure how I can generate image like mermaid.cli does.
Do you have a new version planned to npmjs?
https://www.npmjs.com/package/mermaid-filter
I saw an interesting option filename: "" in the source file. but it not push to npmjs
Followed installation instructions, and when calling
pandoc -F mermaid-filter -o WORKPLAN.pdf WORKPLAN.md
on a plain md file with
gantt
title TASK - PROJECT, JAN-JUN 2016
section Section
Task1 :a1, 2014-01-01, 30d
Task2 :after a1 , 20d
section Another
Task in sec :2014-01-12 , 12d
anther task : 24d
I get
pandoc -F mermaid-filter -o WORKPLAN.pdf WORKPLAN.md
/usr/local/lib/node_modules/mermaid-filter/index.js:23
attrs[2].map(item => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
pandoc: Error running filter mermaid-filter
Filter returned error status 8
I am using pandoc 1.15.0.6 on Ubuntu 14.04. Any idea what the problem can be?
I am running pandoc v.2.0.5 (Compiled with pandoc-types 1.17.3, texmath 0.10, skylighting 0.5) on Debian.
If I run
pandoc -t html -F mermaid-filter -o something.html test.md
on the example file in the repository, I get
(node:19032) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES
fs.js:1112
return binding.unlink(pathModule._makeLong(path));
^Error: ENOENT: no such file or directory, unlink '/tmp/tmp-19025tExPUzZBsx4v.tmp.png'
at Error (native)
at Object.fs.unlinkSync (fs.js:1112:18)
at mv (/usr/lib/node_modules/mermaid-filter/index.js:102:8)
at mermaid (/usr/lib/node_modules/mermaid-filter/index.js:73:9)
at /usr/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (native)
at walk (/usr/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:50:7)
at /usr/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:74:16
at Array.forEach (native)
at walk (/usr/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:73:20)
Error running filter mermaid-filter:
Filter returned error status 1
Any idea where the trouble could come from?
Version 1.4.3 seems to be the latest ( https://www.npmjs.com/package/mermaid-filter?activeTab=versions ) but the tag for that version is missing here on github.
https://www.npmjs.com/package/mermaid-filter
The packaged provided by NPM is outdated. Would you please cut a 1.4.3 release?
How to solve below? (After reinstalled from about last December, I met the below problem)
The cause is mermaid-filter package did not followed dependence of package(package were installed automatically newest)
/usr/local/lib/node_modules/mermaid-filter/index.js:27
if (!_.contains('mermaid', classes)) return null;
^
ReferenceError: _ is not defined
at mermaid (/usr/local/lib/node_modules/mermaid-filter/index.js:27:10)
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:50:7)
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:66:20
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:50:7)
at filter (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:36:10)
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:27:18
at Socket.<anonymous> (/usr/local/lib/node_modules/mermaid-filter/node_modules/get-stdin/index.js:13:3)
pandoc: Error running filter mermaid-filter
Filter returned error status 1
MyEnv.
MacOSX: Yosemite: 10.10.5
node 5.5.0 (installed by brew)
pandoc 1.6 (installed by brew)
mermaid 0.5.8 (npm install --global mermaid)
phantomjs 1.9.0-6 (npm install --global [email protected])
mermaid-filter 0.0.1(date:16.01.28) (npm install --global raghur/mermaid-filter)
[email protected] (npm install --global lodash)
Took me a while to figure out why pandoc-crossref wasn't working with mermaid-filter. Suggest updating the documentation.
It doesn't work with {.mermaid caption="reference-name"}
It doesn't work with {.mermaid #fig:reference-name}
It does work when they're combined: {.mermaid caption="Caption" #fig:reference-name}
It would be nice if I could use this when I am writing papers. Most of the time I use RestructuredText, since that is also what I have to use at work for documentation, and since it allows a lot prettier latex usage.
I'm willing to contribute a PR, but haven't made a pandoc filter before, so don't know what that entails.
I can't run pandoc on ubuntu 18.04
pandoc --version: 2.9.2.1
Installed with: sudo npm install -g mermaid-filter --unsafe-perm=true
Because I can't install with sudo npm install -g mermaid-filter
or npm install -g mermaid-filter
When I run: pandoc -F pandoc-mermaid -o readme.pdf readme.md
Error running filter pandoc-mermaid:
Could not find executable pandoc-mermaid
Thx
Example:
```{.mermaid caption="Example" loc=generated}
sequenceDiagram
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
```
Expected result: file is saved in .\generated\
Actual result: A file is there in .\generated\
, but it has no contents, and an error message is shown in the console:
events.js:183
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open 'C:\Users\moshe\AppData\Local\Temp\tmp-24436bl73Au0XPsB7.tmp.png'
Error running filter mermaid-filter.cmd:
Filter returned error status 1
The problem is in the mv
function - the file is removed using fs.unlinkSync
before the copy to the new location is complete. (On *nix systems this is not an issue because an open file handle remains valid after the file is gone, but that is not the case on Windows - there an open file handle is invalidated immediately when the file is deleted.)
The fix for this is very simple:
function mv(from, to) {
var readStream = fs.createReadStream(from)
var writeStream = fs.createWriteStream(to);
readStream.on('close', () => {
fs.unlinkSync(from);
});
readStream.pipe(writeStream)
}
This way the original is only unlinked once the pipe
operation is complete.
Got this error when running pandoc -t html -F mermaid-filter.cmd -o something.html test.md
.
I'm on Windows 10. Pandoc version is 1.15.1.1.
At job https://gitlab.com/VincentTam/test_pandoc/-/jobs/704713047, I'm working with a newer image
https://gitlab.com/VincentTam/pandoc-mermaid-docker/tree/1c1971477ddb5dd62eedd6d3c34228fe97194434
with necessary node.js packages installed globally.
The linked job shows that I have /usr/bin/mmdc
, and /usr/bin
is in the PATH, so I couldn't understand what happened.
In my Dockerfile I am running this command:
RUN npm install --global mermaid-filter
and get this error:
=> ERROR [6/6] RUN npm install --global mermaid-filter 11.0s
------
> [6/6] RUN npm install --global mermaid-filter:
#9 5.375 npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
#9 5.501 npm WARN deprecated [email protected]: this library is no longer supported
#9 10.90 /usr/local/bin/mermaid-filter -> /usr/local/lib/node_modules/mermaid-filter/index.js
#9 10.92
#9 10.92 > [email protected] install /usr/local/lib/node_modules/mermaid-filter/node_modules/puppeteer
#9 10.92 > node install.js
#9 10.92
#9 10.93
------
executor failed running [/bin/sh -c npm install --global mermaid-filter]: exit code: 1
Just a friendly reminder, so that I do not forget telling you in a few days.
Today I checked mermaid's latest developments and saw that mermaid.cli version 0.4.3 comes with new and better options.
It relies currently on mermaid v 8.0.beta.9 so it might make sense to just monitor it until core mermaid 8.0 is released.
Beware of potential breaking changes (I haven't read them in-depth)
Quotes are admited by mermaid to escape characters like stated here:
https://mermaidjs.github.io/#/flowchart?id=entity-codes-to-escape-characters
Unfortunately, using them inside a mermaid block, makes mermaid filter and pandoc to hang forever.
Example .md
to reproduce the problem:
graph LR; A-->B; click A callback "Tooltip for a callback" click B "http://www.github.com" "This is a tooltip for a link"
Command used:
MERMAID_FILTER_FORMAT='svg' pandoc --verbose -V geometry:margin=1in --highlight-style haddock --standalone --self-contained --toc --top-level-division=chapter -f markdown -t latex -F mermaid-filter -o .artifacts/my-pdf.pdf rfc/my-md.md
Pandoc version:
pandoc 2.7.3
Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.8.1
Default user data directory: /Users/my.user/.local/share/pandoc or /Users/my.user/.pandoc
Copyright (C) 2006-2019 John MacFarlane
Web: http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
I love this filter, but I have a feature request.
I'm using it to create a gantt chart as an appendix to my document. The output filetype of the document is always PDF.
I use pdf as output type for the gantt chart as well, because it has superior quality compared to the png output. But when including the pdf using includegraphics (which is what this filter does by returning pandoc.image) you get Latex complaints about the graphic being too large for the textbody, resulting in weird page breaks (it tries to fit the image on the following page)
Is there a possibility to force this filter to use includepdf (assuming the pdfpages package is installed)?
I'm getting a permission denied when running: mermaid-filter.cmd
on windows.
Any idea why?
Hi,
As explained in the mermaid's documentation, you can describe your graphs by chaining nodes:
graph LR
A -- text --> B -- text2 --> C
Unfortunately it doesn't work with the pandoc filter, the command never ends...
due to issue in mermaid CLI (as referred), arrow head in flow chart disappears in output images.
for now up to [email protected]
is confirmed working
Could it be possible to limit package dependency up to [email protected]
?
fix is just remove ^
from package.json
.
mermaid-cli allows you to set the background of the generated svg (https://github.com/mermaidjs/mermaid.cli#options) and defaults to white. mermaid-filter currently does not allow to set that option. This should probably change and could make mermaid-filter a lot more flexible and helpful in certain scenarios.
happy to create a pull request if necessary, but looking at the code - implementing this feature would be easy.
I've installed your latest version (the not tagged one) and the Node cylindrical shape and stadium-shaped doesn't work:
graph LR
data[Data anywhere]
beta(Data anywhere)
graph LR
data[(Data anywhere)]
graph LR
data([Data anywhere])
It really looks like a parsing error to me.
I get the following error if I try to use this filter in a path that contains spaces. It probably occurs because the path to the .mermaid.css file is unqoted in some process call.
Error: Command failed: "C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\.bin\mmdc" -C C:\Users\User\Path\with spaces\.mermaid.css -w 800 -f -i C:\Users\User\AppData\Local\Temp\tmp-8644XHAnI8v4XjvC.tmp -t default -o C:\Users\User\AppData\Local\Temp\tmp-8644XHAnI8v4XjvC.tmp.png
at checkExecSyncError (child_process.js:616:11)
at execSync (child_process.js:652:15)
at mermaid (C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\index.js:81:5)
at C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\index.js:145:12
at C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:52:19
at Array.forEach (<anonymous>)
at walk (C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:50:7)
at C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:74:16
at Array.forEach (<anonymous>)
at walk (C:\Users\User\AppData\Roaming\npm\node_modules\mermaid-filter\node_modules\pandoc-filter\index.js:73:20)
The first one was generated by typora and the second was generator by mermaid-filter.
Here are two iusses:
Hi,
I tried to convert your test.md to PDF using
pandoc test.md --pdf-engine=xelatex -o test.pdf --filter=mermaid-filter
Got the error below.
Using pandoc 2.2.3.2, but it also broke with older version (1.19 something).
It seems like the pandoc used is installed via anaconda: Maybe this can be a problem?
Any ideas?
Your's
Felix
internal/util.js:206
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'original', 'function');
^
TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function
at promisify (internal/util.js:206:11)
at Object.<anonymous> (/usr/local/lib/node_modules/mermaid-filter/node_modules/extract-zip/index.js:11:18)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/mermaid-filter/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:48:39)
at checkExecSyncError (child_process.js:591:13)
at execSync (child_process.js:631:13)
at mermaid (/usr/local/lib/node_modules/mermaid-filter/index.js:76:5)
at /usr/local/lib/node_modules/mermaid-filter/index.js:143:12
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (<anonymous>)
at walk (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:50:7)
at /usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:74:16
at Array.forEach (<anonymous>)
at walk (/usr/local/lib/node_modules/mermaid-filter/node_modules/pandoc-filter/index.js:73:20)'
Build Docker Container Registry with GitLab CI/CD (my sample GitLab repo)
Dockerfile: https://gitlab.com/VincentTam/pandoc-mermaid-docker/-/blob/18f4950dfe5ef1ce3b438c98d97d1dd767414e59/Dockerfile, mainly copied from https://github.com/time-machine-project/requests-for-comments/blob/470b0c5fdb8c1375ab8726c86b453cb9945e4be2/build/Dockerfile, aims at installing the necessary dependencies without unrelated stuff like bash, python, etc.
GitLab CI/CD config: https://gitlab.com/VincentTam/pandoc-mermaid-docker/-/blob/18f4950dfe5ef1ce3b438c98d97d1dd767414e59/.gitlab-ci.yml, copied from https://gist.github.com/florentchauveau/2dc4da0299d42258606fc3b0e148fc07#file-gitlab-ci-yml, with some modifications to circumvent issue https://gitlab.com/gitlab-org/gitlab-foss/-/issues/65511
job succeeded: https://gitlab.com/VincentTam/pandoc-mermaid-docker/-/jobs/704412168
Step 9/9 : RUN npm install eslint mermaid @mermaid-js/mermaid-cli mermaid-filter
---> Running in 108c4c485814
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
> [email protected] install /data/node_modules/puppeteer
> node install.js
**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.
npm WARN saveError ENOENT: no such file or directory, open '/data/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/data/package.json'
npm WARN data No description
npm WARN data No repository field.
npm WARN data No README data
npm WARN data No license field.
+ [email protected]
+ [email protected]
+ @mermaid-js/[email protected]
+ [email protected]
added 284 packages from 245 contributors and audited 286 packages in 17.171s
14 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Compile a minimal sample Markdown file (my sample GitLab repo) with a minimal GitLab CI config file.
image:
name: registry.gitlab.com/vincenttam/pandoc-mermaid-docker
entrypoint: [""]
build:
script:
- mkdir public
- pandoc README.md -o public/README.pdf -F mermaid-filter
artifacts:
paths:
- public
Executing "step_script" stage of the job script
00:01
$ mkdir public
$ pandoc README.md -o public/README.pdf -F mermaid-filter
internal/fs/utils.js:269
throw err;
^
Error: ENOENT: no such file or directory, open '/tmp/tmp-15k64lpMLghB1y.tmp.png'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at mermaid (/data/node_modules/mermaid-filter/index.js:83:27)
at /data/node_modules/mermaid-filter/index.js:143:12
at /data/node_modules/pandoc-filter/index.js:52:19
at Array.forEach (<anonymous>)
at walk (/data/node_modules/pandoc-filter/index.js:50:7)
at /data/node_modules/pandoc-filter/index.js:74:16
at Array.forEach (<anonymous>)
at walk (/data/node_modules/pandoc-filter/index.js:73:20) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/tmp/tmp-15k64lpMLghB1y.tmp.png'
}
Error running filter mermaid-filter:
Filter returned error status 1
ERROR: Job failed: exit code 83
Would be nice, if mermaid-filter supported generating EPS files.
I tried and it works, put something like
var epsPath = path.join(outdir, `${prefix}-${counter}.eps`);
...
exec(`inkscape --export-eps=${epsPath} ${newPath}`);
before the function return
You can probably do it better.
as the title, what I advise is chaning the efault format from png to svg.
because the dpi of png is too low and there is no way to set the dpi of png
I'm getting this even if I use your copy of pandoc-filter:
pandoc: When expecting a product of 3 values, encountered an Array of 2 elements instead
Hi there,
I wish to use this filter on a Windows machine but am having some trouble using it. I was able to install all the required modules using npm.
After running the given command, I get the following error:
pandoc.exe: Filter mermaid-filter not found
I think this may not be actually related to the plugin itself, but some help would be appreciated.
Thanks for your time.
there is the log
npm install --global mermaid-filter
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\shixuguo\AppData\Roaming\npm-cache\_logs\2018-09-03T14_11_30_389Z-debug.log
how can i solve the problem?
I guess this issue is more like that i didn't install something properly but i don't know what i have to install. after this command:
pandoc -t html -F mermaid-filter -o output.html test.md
The error message is the following:
External tool not found: mermaid
pandoc: Error running filter mermaid-filter
i tried to install mermaid from npm:
npm install -g mermaid
but it does not change my situation.
I am on os x 10.10.4
many thanks
olaf
When I try this in pdf output, I don't see a diagram, just the code block I entered parsed as markdown. Actually, I see that also in html output.
Hi,
Just FYI; as far as I know, it is not possible to search for the package @ npmjs. I suspect that this is caused by the package being a scoped package (which is weird, because it's public and installable).
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.