Graphing support: add nomnoml #145

Closed
opened 2026-01-29 14:28:38 +00:00 by claunia · 5 comments
Owner

Originally created by @PulsarFX on GitHub (Oct 12, 2017).

Would it be possible to add further graphing support to the existing mermaid extension?
Mermaid is really weak on class diagrams, so I started looking around and found http://www.nomnoml.com/ from https://github.com/skanaar/nomnoml
which has really nice syntax and produces nice diagrams.
Maybe something like

  ```nomnoml
  ```

To insert a nomnoml block?

Originally created by @PulsarFX on GitHub (Oct 12, 2017). Would it be possible to add further graphing support to the existing mermaid extension? Mermaid is really weak on class diagrams, so I started looking around and found http://www.nomnoml.com/ from https://github.com/skanaar/nomnoml which has really nice syntax and produces nice diagrams. Maybe something like ```nomnoml ``` To insert a nomnoml block?
claunia added the enhancementPR Welcome! labels 2026-01-29 14:28:38 +00:00
Author
Owner

@PulsarFX commented on GitHub (Oct 16, 2017):

to add a little more input:

nomnoml can draw to a canvas, or output the diagram in svg:
this is a minimal example showing both types:

<html>
    <head>
        <script src="zepto.min.js"></script>
        <script src="lodash.min.js"></script>
        <script src="dagre.min.js"></script>
        <script src="nomnoml.js"></script>
    </head>
    <body>
        <canvas id="target-canvas"></canvas>
        <div id="nomnomldiv"></div>
        <script>
            var canvas = document.getElementById('target-canvas');
            var source = '[nomnoml] is -> [awesome]';
            nomnoml.draw(canvas, source);
            
            var divid = document.getElementById('nomnomldiv');
            divid.innerHTML = nomnoml.renderSvg(source);
        </script>
    </body>
</html>

it would be enough to let markdig output a div just like it is done with mermaid:

        <div class="nomnoml">
            [class irtzr]->[class vbr] 
            [df458 ]->[nvjht877fg]
        </div>

this could be parsed afterwards like this:

        <script>
            function htmlDecode(input)
            {
              var doc = new DOMParser().parseFromString(input, "text/html");
              return doc.documentElement.textContent;
            }
            var graphs = document.getElementsByClassName('nomnoml');
            for (var i = 0; i < graphs.length; i++) {
                graphs[i].innerHTML = nomnoml.renderSvg(htmlDecode(graphs[i].innerHTML));
            }            
        </script>
@PulsarFX commented on GitHub (Oct 16, 2017): to add a little more input: nomnoml can draw to a canvas, or output the diagram in svg: this is a minimal example showing both types: ```html <html> <head> <script src="zepto.min.js"></script> <script src="lodash.min.js"></script> <script src="dagre.min.js"></script> <script src="nomnoml.js"></script> </head> <body> <canvas id="target-canvas"></canvas> <div id="nomnomldiv"></div> <script> var canvas = document.getElementById('target-canvas'); var source = '[nomnoml] is -> [awesome]'; nomnoml.draw(canvas, source); var divid = document.getElementById('nomnomldiv'); divid.innerHTML = nomnoml.renderSvg(source); </script> </body> </html> ``` it would be enough to let markdig output a div just like it is done with mermaid: ``` <div class="nomnoml"> [class irtzr]->[class vbr] [df458 ]->[nvjht877fg] </div> ``` this could be parsed afterwards like this: ``` <script> function htmlDecode(input) { var doc = new DOMParser().parseFromString(input, "text/html"); return doc.documentElement.textContent; } var graphs = document.getElementsByClassName('nomnoml'); for (var i = 0; i < graphs.length; i++) { graphs[i].innerHTML = nomnoml.renderSvg(htmlDecode(graphs[i].innerHTML)); } </script> ```
Author
Owner

@xoofx commented on GitHub (Oct 16, 2017):

This is a one line add in markdig (see DiagramExtension.cs#L27), so PR welcome if you want this. 😉

@xoofx commented on GitHub (Oct 16, 2017): This is a one line add in markdig (see [DiagramExtension.cs#L27](https://github.com/lunet-io/markdig/blob/42472085a62dfb86e229f1cbb16e24aead6a9741/src/Markdig/Extensions/Diagrams/DiagramExtension.cs#L27)), so PR welcome if you want this. 😉
Author
Owner

@PulsarFX commented on GitHub (Oct 17, 2017):

I can only provide patches. thanks to .net core 2 I am not able to compile or do anything :-/

nomnomlSupport.zip

@PulsarFX commented on GitHub (Oct 17, 2017): I can only provide patches. thanks to .net core 2 I am not able to compile or do anything :-/ [nomnomlSupport.zip](https://github.com/lunet-io/markdig/files/1390442/nomnomlSupport.zip)
Author
Owner

@PulsarFX commented on GitHub (Oct 17, 2017):

finally managed to create a pull request: #149
only took me 6 hours 🤣

@PulsarFX commented on GitHub (Oct 17, 2017): finally managed to create a pull request: #149 only took me 6 hours :rofl:
Author
Owner

@xoofx commented on GitHub (Oct 17, 2017):

Fixed by #149

@xoofx commented on GitHub (Oct 17, 2017): Fixed by #149
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#145