temando / remark-mermaid

A remark plugin for Markdown that replaces mermaid graphs with rendered SVGs.
MIT License
82 stars 31 forks source link

Configure file save location without a vFile? #8

Open nonprofittechy opened 4 years ago

nonprofittechy commented 4 years ago

I am trying to use remark-mermaid with Docusaurus v2, which seems like it could be a very powerful combination.

However, by default remark-mermaid saves to the current directory. It would work if the remark plugin either ran the initialization script for mermaid.js when you use simple (not easy to insert that into markdown without swizzling, or at least I couldn't see that option in Docusaurus), or allowed you to more easily configure the save location for all images by passing it as an option at config time, just like the simple option.

bgschiller commented 4 years ago

I have a fork (described in #10) that includes an imageDir plugin option, but it's relative to each file's location. Would that work for you, or would you expect such an option to be relative to the package root?

It doesn't matter either way to me, so I'm happy to change it. Much easier to change it before it's merged though.

nonprofittechy commented 4 years ago

I think relative to the package root would work best here. At least for docusaurus, it expects all images to be in the /static/img directory, but you are allowed to put documents in subdirectories.

ambroiseRabier commented 2 years ago

Any update on this issue ? I would love to use mermaid with docusaurus.

I don't know how you figured out, that the problem is with the file save location, all I get is:

Compiled with problems:

ERROR in ./docs/temp/mermaid test.md

Module build failed (from ./node_modules/@docusaurus/mdx-loader/lib/index.js):
SyntaxError: L:\PROJECTS_3\WEB\teaching-support-website\docs\temp\mermaid test.md: Unexpected token (18:2)

  16 | export default function MDXContent({
  17 |   components,
> 18 |   ...props
     |   ^
  19 | }) {
  20 |   return <MDXLayout {...layoutProps} {...props} components={components} mdxType="MDXLayout">
  21 |     <svg {...{
    at instantiate (L:\PROJECTS_3\WEB\teaching-support-website\node_modules\@babel\parser\lib\index.js:72:32)

Edit: Seem like some stuff going on there: https://docusaurus.io/feature-requests/p/add-mermaid-support Edit2: I guess the issue is somewhat resolved with https://github.com/sjwall/mdx-mermaid ?