Giter Club home page Giter Club logo

Comments (17)

raghur avatar raghur commented on July 20, 2024

https://mermaidjs.github.io/sequenceDiagram.html says

Is it possible to adjust the margins for rendering the sequence diagram.

This is done by defining mermaid.sequenceConfig or by the CLI to use a json file with the configuration. How to use the CLI is described in the mermaidCLI page.

but the new CLI tool project doesn't expose a way to pass in the config object/json. I currently depend on the CLI tool to call mermaid (not using the api).

Will check later if the cli has an undocumented arg to give a config json.

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

I opened mermaidjs/mermaid.cli#9 in order to track it.

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Version 0.3.1 of mermaid.cli now supports configuration via json file (and css file for extra config!)

from mermaid-filter.

raghur avatar raghur commented on July 20, 2024

Great... How do you think this should be supported on mermaid-filter? We could do additional options on the mermaid class - but this means that every diagram on the markdown file needs the class to be specified.
Also, reduces portability - for ex if you render on a different machine where the config files arent available.

I think having .mermaid-filter-config.json and .mermaid-filter.css files in the folder from where pandoc is run might be better?

Thoughts?

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Mmmm, thinking aloud here.

I'm not sure if having the config files where the pandoc binary is run is a good idea. I guess it would be ok if a default configuration set of files was installed in the right place when doing the npm install --global mermaid-filter

Another option would be having a couple of vscode configuration entries pointing to where the mermaid-filter-config.json and .css are. This would allow you to have self-contained pandoc projects, with the configuration files in it. In case these configuration entries are empty, you could have the pandoc directory as default...

Any of these would make all your diagrams render the same way, or at least all your project diagrams (since vscode config can change at the project level, right?), but I think this could be an acceptable compromise.

from mermaid-filter.

raghur avatar raghur commented on July 20, 2024

Another option would be having a couple of vscode configuration entries pointing to where the mermaid-filter-config.json and .css are. This would allow you to have self-contained pandoc projects, with the configuration files in it. In case these configuration entries are empty, you could have the pandoc directory as default...

I don't want to tie mermaid-filter to vscode specific configuration (though I'm not sure if that's what you mean)

What I meant is that if you have ~/folderA which has a bunch of markdown files, and assuming most people run pandoc inside ~/folderA, then look for the default config files in folderA - which seems pretty much what you're suggesting in the latter part.

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

I don't want to tie mermaid-filter to vscode specific configuration (though I'm not sure if that's what you mean)

Yes, that's what I meant, and you are completely right. The filter should stand on its own. Forget what I said about vscode.

What I meant is that if you have ~/folderA which has a bunch of markdown files, and assuming most people run pandoc inside ~/folderA, then look for the default config files in folderA - which seems pretty much what you're suggesting in the latter part.

Sounds reasonable. I'd go for this one.

Can filters receive parameters to specify alternate locations?

from mermaid-filter.

raghur avatar raghur commented on July 20, 2024

I just pushed a branch - jsonconfig - can you pull from there and give it a go?

Can filters receive parameters to specify alternate locations?

AFAICR, not if you specify the the filtername as -F to pandoc. You have to write out the entire command like
pandoc -t json -i somefile.md | node index.js -opta --opt | pandoc -t html -o whatever.html

and that's quite cumbersome.

You could wrap the filter command in a batch/shell script and then call pandoc of course... that should work

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Certainly.

After I grab the jsonconfig branch, any recommendation on how to install the devel version so that I can use it as a filter for pandoc?

from mermaid-filter.

raghur avatar raghur commented on July 20, 2024

you can install it with npm - like so

user/project#branch - so npm i -g raghur/mermaid-filter#jsonconfig

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Thanks!

Testing...

I'll update this post after the tests.

UPDATE

It seems to be working great!

I tested conversion to docx with and without the config files and it worked as expected.

I also tested converting a .md file in a subdirectory and it went well also.

image

I'd like to test it also with pandocomatic but I'm sure it will go fine also

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Pandocomatic works fine also.

I must say this is a fantastic improvement, I will finally be able to use mermaid for generating docx documents, and have them look great.

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Now that I review mermaid.cli, the only thing that is missing is the --theme option (the background one can be simulated with the css config).

Maybe the theme option can also be replicated with the css+json config, but it would be nice to have it also in the filter.

Should I open a separate issue for it?

from mermaid-filter.

raghur avatar raghur commented on July 20, 2024

Just pushed to jsonconfig branch with support for --theme. README has been updated as well - so take a look there.

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

It works great!

It has even allowed me to find a couple of bugs in mermaid.cli (I made a new PR there to fix them mermaidjs/mermaid.cli#21 )

Thanks @raghur

from mermaid-filter.

raghur avatar raghur commented on July 20, 2024

Great... thanks for testing. Have merged and pushed out v1.1.0 to npm

from mermaid-filter.

agusmba avatar agusmba commented on July 20, 2024

Only one question.

The PR above is trying to fix mermaid.cli when no theme is specified in the commandline, but a theme is present in the json config (right now default theme is always used).

I fear the same would happen in this filter.

Would it be possible to only specify -t default if the theme was explicitly entered as an attribute to the figure?

It could be done by setting a default value different from "default" (like "theme-default") and only issuing the -t commandline when the value was different from this "theme-default".

I was writing this as you closed the issue.

No worries, we could revisit this if/when my PR is merged in mermaid.cli

Thanks for pushing 1.1.0 !!!!

from mermaid-filter.

Related Issues (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.