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

Need node IDs to be able to create more than one node with the same label #187

Closed
lorlik opened this issue Jan 13, 2023 · 21 comments
Closed

Comments

@lorlik
Copy link

lorlik commented Jan 13, 2023

Nomnoml syntax and graph rendering relies on node label for identity. Unfortunately, this is very limiting as there are many situations where one may have more than one node with the same label. Would it be possible to extend syntax and rendering to allow for optional IDs for all types of nodes (e.g. [<style> {id} label ]) where if ID is missing then the graph would continue to use label as ID, if its present then ID would be used as identifier of unique node instead of label? Use of curly brackets for syntax is just a suggestion, any syntax to indicate ID would be fine.

@skanaar
Copy link
Owner

skanaar commented Jan 13, 2023

I am right now doing a big rewrite of the parser to support some new features, for example an ID field.
But it might take a while, I have very little time for my hobbies right now.

@lorlik
Copy link
Author

lorlik commented Jan 13, 2023

What was your vision for ID syntax in case we decide to contribute and add it ourselves?

@skanaar
Copy link
Owner

skanaar commented Jan 14, 2023

You can track the rewrite from Jison to Peggy in the rewrite-grammar branch.
https://github.com/skanaar/nomnoml/blob/rewrite-grammar/src/grammar.pegjs

This is the new syntax: [<type id=foo>foobar].

The plan is to allow any metadata to be added as key-value pairs within the angle brackets.

@skanaar
Copy link
Owner

skanaar commented Jan 15, 2023

Have a look at https://stage.nomnoml.com/ where I have deployed a release candidate for the new parser.

I would be very grateful for some testing here before I deploy it to www.nomnoml.com 🙏

@lorlik
Copy link
Author

lorlik commented Jan 17, 2023

Thank you. I am getting a compile error on stage for a graph that works in the current version. There are no details to where the issue is. How would you like me to communicate the doc to you for troubleshooting? I'd prefer for it not to be in the public domain.

@skanaar
Copy link
Owner

skanaar commented Jan 17, 2023

You can email me on [email protected]. I'll delete it once I have identified the troublesome syntax.

@tcbuzor
Copy link

tcbuzor commented Jan 17, 2023

I tested the new parser for my current use case and it works. Do you have any other cases you need help testing?

@skanaar
Copy link
Owner

skanaar commented Jan 18, 2023

@tcbuzor nice to hear that it works.

Just test it with whatever diagrams you usually write. You might be using a different "style" than me, one that I haven't anticipated. 😄

@tcbuzor
Copy link

tcbuzor commented Jan 19, 2023

Sure, will test other scenarios. Do you mind also providing some insight into how one might implement the ERD associations? #185

@bdlabs
Copy link

bdlabs commented Feb 18, 2023

Maybe this syntax would be a better way
#attr foobar: id=foo;
or
#.foobar: id=foo; in css

[foobar]

Because this solution will be clearer when the engine will be expanded with additional arguments like this.

@wurst-hans
Copy link

wurst-hans commented Feb 22, 2023

You can track the rewrite from Jison to Peggy in the rewrite-grammar branch. https://github.com/skanaar/nomnoml/blob/rewrite-grammar/src/grammar.pegjs

This is the new syntax: [<type id=foo>foobar].

The plan is to allow any metadata to be added as key-value pairs within the angle brackets.

Your project is really fantastic. I'm just looking for a simple JS library that is able to render a simple static flowchart out of a text definition. There are other really great projects like MermaidJS or jsPlump, but they are so huge and massive overkill. And your new parser was the feature I'm waiting for. Using numeric IDs for connecting elements, ex.:

[<note id=1>First slide]
[<start>Start]->[1]

is much easier than using long text labels. I love nomnoml.

EDIT: The only thing I had to change is exporting layouters because I need a minimum width and height of note boxes, so I've overwritten nomnoml.layouters.note as workaround.

@skanaar
Copy link
Owner

skanaar commented Feb 26, 2023

New version deployed to https://stage.nomnoml.com
It fixes the issues reported by @lorlik

And thank you @wurst-hans for your kind words 😍

@lorlik
Copy link
Author

lorlik commented Feb 27, 2023

@skanaar , thank you for fixing the issue.

@42sol-eu
Copy link

Have a look at https://stage.nomnoml.com/ where I have deployed a release candidate for the new parser.

I would be very grateful for some testing here before I deploy it to www.nomnoml.com 🙏

@skanaar I will do that. My nomnoml skills have been called magic over the last years, this is because my brain really loves and integrates that syntax so much more than plantuml or mermaid.

and yes I have checked this with mermaid some weeks ago
my logical part of my brain says: "Mermaid really makes sence"
but my system 1 (see the book "thinking fast and slow") does not put
so I am still a believer of nomnoml that I can use whilst talking and in meetings as a magical white board.

If there are specifics to test please feel free to ping me!

@42sol-eu
Copy link

42sol-eu commented Mar 12, 2023

...
is much easier than using long text labels. I love nomnoml.

There is a trick that I found with the old parser:

  1. Pick a short title for the first line (like [N1;this is the note])
  2. now N1 is the id! use it like [N1] -- [cool]

@zflat
Copy link

zflat commented Apr 9, 2023

You can track the rewrite from Jison to Peggy in the rewrite-grammar branch. https://github.com/skanaar/nomnoml/blob/rewrite-grammar/src/grammar.pegjs

This is the new syntax: [<type id=foo>foobar].

The plan is to allow any metadata to be added as key-value pairs within the angle brackets.

It looks like there are restrictions on what can be added as values?

I tried [<class id=x0_y0>A] on https://stage.nomnoml.com/ and get a compile error:

Expected ">" or space but "_" found.

Right now the value is restricted to characters [a-zA-Z0-9] but maybe some other characters could be added? In the new grammar, an Attr would need to be key:Ident "=" value:AttrVal where AttrVal would be a new definition that allows more charactes than the Ident does. Does that seem possible?

Edit:
Looking more at the grammar I realize that the attr value needs to able to be used as an Ident, so maybe Ident could also include _? I just think that it will be hard to write identifiers that can be readable only using camel case.

@skanaar
Copy link
Owner

skanaar commented Apr 10, 2023

@zflat good feedback.
I would like to keep some restrictions to which characters are allowed to allow for new syntax in the future.
But [a-zA-Z0-9_] seems reasonable. :)

@zflat
Copy link

zflat commented Apr 10, 2023

Thanks! The only other thing I would request that could truly allow any metadata would be to support enough characters for base32 or base64 encoding, however supporting the = for padding probably makes this infeasible. I acknowledge that this is scope creep and most likely something you don't want to support so either way, thanks for all the work you put into this library and tool!

@skanaar
Copy link
Owner

skanaar commented Apr 16, 2023

I have deployed a new version to https://stage.nomnoml.com that solves some performance issues.

I would really appreciate if you can guys can test it out. As soon as I am confident it works it'll be deployed to nomnoml.com

@zflat
Copy link

zflat commented Apr 19, 2023

Working for for my use-case:

Screenshot from 2023-04-19 16-55-36

Thanks again!

@skanaar
Copy link
Owner

skanaar commented Apr 23, 2023

New version released 🎉

@skanaar skanaar closed this as completed Apr 23, 2023
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

7 participants