Support API in nodejs
See original GitHub issueDescribe the solution you’d like
I see that mermaid provides API to operate on the browser side, but why similar API isn’t provided in nodejs?
For example:
const mermaid = require('mermaid');
var renderer = new marked.Renderer();
renderer.code = function (code, language) {
if(code.match(/^sequenceDiagram/)||code.match(/^graph/)){
return '<div class="mermaid">'+mermaid.render(code)+'</div>';
}
else{
return '<pre><code>'+code+'</code></pre>';
}
};
Many MD renderers will provide code blocks. We only need to render them into the SVG. Compared with introducting JS in the browser, this solution can improve the efficiency of page loading (after all, it has been processed in node )
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Creating a Secure Node.js REST API - Toptal
Creating a Secure REST API in Node.js · Request with the appropriate data for creating a user · Confirmation response with userID ·...
Read more >Node.js - RESTful API - Tutorialspoint
Node.js - RESTful API, REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol.
Read more >How to Build REST API with Node.js from Scratch - Edureka
This article on Building a REST API with Node.js will give you a step by step demostration for creating a CRUD application using...
Read more >Node-API | Node.js v19.3.0 Documentation
Node-API is a C API that ensures ABI stability across Node.js versions and different compiler levels. A C++ API can be easier to...
Read more >Consume and provide APIs with API Connect and Node.js
Learn how both API providers and API consumers interact with API Connect as an API hub. Learn how API providers can use Node.js...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I haven’t tried it, but JsDOM ( https://github.com/jsdom/jsdom ) provides a fairly complete DOM API implementation for node.js without having to use the full browser stack including the renderer and CSS implementation (like puppeteer).
So in its simplest form you could try to pass a JsDOM
<div>
element to mermaid API as that last parameter that allows to inject an own element to be used for the rendering.Edits: Issue #559 covers the discussion but was auto-closed by the bot due to inactivity. summary: JsDom does not work because the layout algorithm relies on letting the browser engine calculate the size of the elements. Since any custom CSS is supported and the layout is SVG, i.e. absolute pixels it looks the mermaid architecture is actually constrained to browser engines .
Closing as wont fix