instant-markdown / instant-markdown-d

Small instant Markdown preview server
https://instant-markdown.github.io
Other
189 stars 103 forks source link

Can't preview mermaid #77

Closed ACupofAir closed 3 years ago

ACupofAir commented 3 years ago

Problem summary

Can't preview mermaid when I had config my .vimrc with let g:instant_markdown_mermaid = 1

Expected

Environment Information

Steps to reproduce the issue (required)

Start with command you used to install instant-markdown-d. Use a minimal.vimrc to reproduce the issue and open your markdown file as:

vim -u minimal.vimrc my_markdown_file.md

my markdown file test.md:

```mermaid
graph TD
    A-->B
    A-->C
    B-->D
    C-->D
graph LR
    A[Square Rect] -- Link text --> B((Circle))
    A --> C(Round Rect)
    B --> D{Rhombus}
    C --> D

![image](https://user-images.githubusercontent.com/58850527/113016082-b7de4180-91b0-11eb-9a41-c3db348ae225.png)

## Provide the debug output (required)

Run `cat my_markdown_file.md | instant-markdown-d --mathjax --debug`. It
generates a `debug.html` file - attach it here. Also, paste the console output
here:
The sh make my terminal blocked.
It only put the nodejs version then it is blocked

## Screen shot (if possible)
ashwinvis commented 3 years ago

Did you install instant-markdown-d from the git repository? The one on NPM does not have mermaid support.

danjenson commented 3 years ago

Same problem here, and attempting to install from github throws an error:

λ npm i -g https://github.com/instant-markdown/instant-markdown-d.git
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mathjax-node-page@3.2.0: This package has been archived. MathJax v3 provides equivalent functionality.
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/danj/.npm/lib/node_modules/instant-markdown-d/node_modules/mathjax/jax'
npm WARN tar ENOENT: Cannot cd into '/home/danj/.npm/lib/node_modules/instant-markdown-d/node_modules/mathjax'
npm ERR! code 128
npm ERR! git dep preparation failed
npm ERR! command /usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/danj/.npm/cache --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 128
npm ERR! npm ERR! path /home/danj/.npm/cache/_cacache/tmp/git-clone-fc2bdf3c
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c genversion ./src/version.js; git clean -f;
npm ERR! npm ERR! sh: line 1: genversion: command not found
npm ERR! npm ERR! fatal: not a git repository (or any parent up to mount point /)
npm ERR! npm ERR! Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /home/danj/.npm/cache/_logs/2021-04-14T19_27_24_982Z-debug.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/danj/.npm/cache/_logs/2021-04-14T19_27_28_595Z-debug.log

using npm version 7.9.0

ashwinvis commented 3 years ago

@danjenson Can you check node --version?

danjenson commented 3 years ago

v15.14.0

ashwinvis commented 3 years ago

As indicated in #79 it seems the tool does not work as expected in Node v14+ can you try to use Node v12 and see if it helps?

danjenson commented 3 years ago

Same error with node v12.22.0

danjenson commented 3 years ago

And if you try to do it with sudo:

λ sudo npm i -g https://github.com/instant-markdown/instant-markdown-d.git
npm ERR! code 128
npm ERR! command failed
npm ERR! command git clone ssh://git@github.com/instant-markdown/instant-markdown-d.git /root/.npm/_cacache/tmp/git-clone-2eb7b7fe --recurse-submodules --depth=1
npm ERR! /bin/bash: /root/.bashrc: Permission denied
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-2eb7b7fe': Permission denied

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-04-14T22_19_05_188Z-debug.log

While sudo npm i -g instant-markdown-d works fine.

ACupofAir commented 3 years ago

Did you install instant-markdown-d from the git repository? The one on NPM does not have mermaid support.

Yes, I installed it with sudo npm i -g https://github.com/instant-markdown/instant-markdown-d.git, and it succeed. But the mermaid can't preview.

ashwinvis commented 3 years ago

Looking at the logs, atleast for your environment @danjenson :

npm ERR! npm ERR! code 128
npm ERR! npm ERR! path /home/danj/.npm/cache/_cacache/tmp/git-clone-fc2bdf3c
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c genversion ./src/version.js; git clean -f;
npm ERR! npm ERR! sh: line 1: genversion: command not found
npm ERR! npm ERR! fatal: not a git repository (or any parent up to mount point /)
npm ERR! npm ERR! Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /home/danj/.npm/cache/_logs/2021-04-14T19_27_24_982Z-debug.log

It seems the npm package genversion fails to execute in your environment. I don't know if this is a know issue with genversion. We will leave that for later

What you could do is do it one-by-one

git clone https://github.com/instant-markdown/instant-markdown-d
cd instant-markdown-d
npm run prepare  # runs genversion
npm install -g .
ashwinvis commented 3 years ago

For mermaid.js diagrams you need the instant-markdown-d --mermaid command line argument or equivalent in Vim. The new version is out on npm and is well tested. Do try it out.

I will close this for now, but feel free to reply if anything is broken.