Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server side mermaid with jsdom #559

Closed
tylerlong opened this issue Aug 16, 2017 · 8 comments
Closed

server side mermaid with jsdom #559

tylerlong opened this issue Aug 16, 2017 · 8 comments
Assignees
Labels
Type: Enhancement New feature or request Type: New Shape Request for new shape

Comments

@tylerlong
Copy link
Collaborator

tylerlong commented Aug 16, 2017

Here is an interesting example for D3 to work together with jsdom:
https://bl.ocks.org/tomgp/c99a699587b5c5465228

PhantomJS is heavyweight. And it is discontinued: http://carstenwindler.de/software-testing/phantomjs-is-discontinued/

Chrome headless sounds promising but it's heavyweight too. It required the installation of Chrome browser.

I think it is best if we could make mermaid work with jsdom. It is lightweight(compared to PhantomJS and Chrome headless). And it works with Node.js out of the box.

@tylerlong tylerlong self-assigned this Aug 16, 2017
@tylerlong tylerlong added the Type: Enhancement New feature or request label Aug 16, 2017
@dead-horse
Copy link

is there any progress?

I'm trying to do server side rendering of mermaid, but just like you said, puppeteer is too heavyweight. I just tried to use mermaid with JSDOM, but it failed by negative width like width="-37.5".

@tylerlong
Copy link
Collaborator Author

It seems to be impossible. Mostly because jsdom doesn't do text font rendering so we cannot measure the width and height of text nodes. Without these information it is impossible to layout the diagrams properly.

@dead-horse
Copy link

I'm not sure if mathjax solved this problem, it use jsdom to render latex to svg in server side. https://github.com/mathjax/MathJax-node

@tylerlong
Copy link
Collaborator Author

tylerlong commented Mar 14, 2018

@dead-horse maybe mathjax use pre-defined font family, so it could know the width and height of text without rendering?

Update: I think I am correct: https://github.com/mathjax/MathJax-node/blob/89d1e0af912eb2666592195a555f9edaa325f1e5/lib/main.js#L315-L320

But mermaid allow customization font family using CSS, and different font family has different text size.

@agusmba
Copy link

agusmba commented Mar 14, 2018

Removed my comment on SVG option, since it referenced an also edited comment ;-)

@stale
Copy link

stale bot commented Jun 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Type: New Shape Request for new shape label Jun 29, 2019
@kilgarenone
Copy link

Has anyone managed to server-render mermaid without puppeteer ?

@PeterWone
Copy link

@dead-horse maybe mathjax use pre-defined font family, so it could know the width and height of text without rendering?

Update: I think I am correct: https://github.com/mathjax/MathJax-node/blob/89d1e0af912eb2666592195a555f9edaa325f1e5/lib/main.js#L315-L320

But mermaid allow customization font family using CSS, and different font family has different text size.

So stop allowing font-family and font-size to be controlled by the user. There's no need for it. Once SVG has been rendered they can scale that if they don't like the font size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request Type: New Shape Request for new shape
Projects
None yet
Development

No branches or pull requests

5 participants