Giter Club home page Giter Club logo

mermaid-filter's People

Contributors

dependabot[bot] avatar evanpjensen avatar fiurthorn avatar fkurz avatar garf1242 avatar glerchundi avatar kennymac70 avatar kohenkatz avatar mblawrence avatar montaro avatar raghur avatar redx2501 avatar remche avatar skinner927 avatar subnomo avatar szaliszali avatar vincenttam avatar ynohat 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  avatar

mermaid-filter's Issues

Windows 10 file not found error

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

Could not find phantomjs at the specified path

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

Fails with Bracket formatting

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)

poor image quality with pandoc

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?

Screenshot from 2020-12-08 15-05-46

The acute accent is blurred on GitLab CI output

image

  1. repo for my sample file: https://gitlab.com/VincentTam/test_pandoc
  2. my pandoc+LuaLaTeX+mermaid+TeX Gyre+Noto Emoji Docker image: https://gitlab.com/VincentTam/pandoc-mermaid-docker/

Generate figures for .tex 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?

Add full Unicode support

If add an unicode character then the filter fails to render in pandoc and I have to manually stop the compilation

Example:

graph LR;

I0 --> I1(✋);

This does not render

But if instead I do:

graph LR;

I0 --> I1(A);

I get

image

Breaks on Linux with Pandoc 2

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)

Windows: Could not find executable pandoc-mermaid

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

Allow to configure puppeteer

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.

fails with autonumber for sequenceNumbers

When use autonumber option in a sequenceDiagram Mermaid filter fails and appears to hangs indefinitely.

Steps to reproduce

use a markdown file such as

~~~mermaid
sequenceDiagram
    autonumber
    Alice->>John: Hello John, how are you?
~~~

Change 'png' to 'svg' in index.js not working

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.

Clickable nodes in HTML output

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?

Support output format=pdf for pandoc/pdf with high quality figure

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.

EMFILE too many files when running on Windows 10

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...?

PNG file width is too small compared to mermaid.cli

Update

I've had a look at index.js about why width is always limited under 500px no matter .mermaid-config.json has width option.

  • Width is populated from environmental variable MERMAID_FILTER_WIDTH or by default, 500: width: process.env.MERMAID_FILTER_WIDTH || '500',
  • The width is used in command with a separate argument -w along with configuration file: ${cmd} ${confFileOpts} ${puppeteerOpts} -w ${options.width} -i ${tmpfileObj.name} -t ${options.theme} -o ${savePath}
  • So, the value in .mermaid-config.json seems to be always overriden by -w ${options.width} which explains why generated image's width is < 500 px.
  • A workaround would be setting MERMAID_FILTER_WIDTH before run pandoc with mermaid-filter like MERMAID_FILTER_WIDTH=800 pandoc ... -F mermaid-filter ....

Original

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.

Tested mermaid diagram

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

Comparison

image

The first one

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.

The second one

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.

SyntaxError: Unexpected token >

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?

Unhandled promise rejection (rejection id: 1): Error: spawn EACCES fs.js:1112

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?

I counl'd use mermaid-filter by reinstall.

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)

#fig:reference doesn't work if caption isn't provided

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}

Support RestructuredText as well as Markdown

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.

Could not find executable pandoc-mermaid on Linux

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

Saving image file breaks on Windows

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.

Cannot install on Ubuntu

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

Use newer mermaid.cli version

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 make mermaid-filter hang forever

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.

Option to use includepdf instead of includegraphics?

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

cannot configure graph background

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.

Path to .mermaid.css is unquoted

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)

Image quality enhance

The first one was generated by typora and the second was generator by mermaid-filter.
Here are two iusses:

  1. The second image quality is much more poor than the first.
  2. typora provide automargins and the size of the image is proportionate.

screen shot 2017-05-30 at 3 52 40 pm

breaks on macos

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

Breaks with GitLab CI/CD Docker Container Registry

Steps to reproduce error

  1. Build Docker Container Registry with GitLab CI/CD (my sample GitLab repo)

  2. 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

Error received

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

Support SVG->EPS conversion

Would be nice, if mermaid-filter supported generating EPS files.

  1. mermaid can output SVG (although some diagram types are not rendered correctly)
  2. Inkscape could be used for converting the SVG files to EPS files
  3. EPS files can be used by PanDoc for generating PDF output with diagrams included

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.

Trouble running on Windows

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 a problem on installing mermaid-filter on win 10

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?

mermaid not found

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

Does this work for pdf output?

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.

Scoped NPM package - no visibility @ npmjs

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

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.