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

Using Pintora as a library in Node.js #174

Closed
tex0l opened this issue Oct 13, 2023 · 2 comments
Closed

Using Pintora as a library in Node.js #174

tex0l opened this issue Oct 13, 2023 · 2 comments
Assignees

Comments

@tex0l
Copy link

tex0l commented Oct 13, 2023

Hi,
I moved from Mermaid to Pintora for my blog in Astro because I need SSR (see mermaid-js/mermaid#3650), and solutions involving pupeteer end up with a result which is not consistent across browsers, contrary to what I've seen with Pintora.

However, the documentation to use Pintora as a library is really confusing (or non-existent), it's designed to be used in Node.js as a CLI only, not a as a library.

I circumvented the issue to generate an SVG from a string in a Node.js script by importing the render function from '@pintora/cli':

import {render} from '@pintora/cli'
import type {PintoraConfig} from '@pintora/standalone'

const buildSVG = async (code: string, config: PintoraConfig) => {
  const result = await render({
    code: code,
    pintoraConfig: config,
    mimeType: 'image/svg+xml'
  })
}

In the API usage documentation, there is no mention of how to use the CLI's Node.js APIs, and no mention of how to use the '@pintora/standalone' package to generate an SVG from a string.

I would suggest to either:

  • document the API of '@pintora/cli'
  • or to embed within '@pintora/standalone' the render function from '@pintora/cli' which allows using it in a Node.js script.
@hikerpig
Copy link
Owner

hikerpig commented Oct 20, 2023

Thank you for the try and this feedback, I'll look into it this weekend.
Basically it's the former one, add some documentation about how to use @pintora/cli as a node.js library.

@hikerpig
Copy link
Owner

I've added a little basic demostration for this usage. https://pintorajs.vercel.app/docs/advanced/api-usage/#pintora-api-in-nodejs-pintoracli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants