DomParfitt / graphviz-react

React component for displaying Graphviz graphs
MIT License
102 stars 21 forks source link

HTML-like Labels support? #35

Closed un0btanium closed 3 years ago

un0btanium commented 3 years ago

Does this allow nodes to be defined with HTML-like labels? I dont seem to get it to work in the demo. For example:

graph { 
a [label=<<b>Test</b>>]
}

it throws Parse Error: Cannot read property '3' of null.

DomParfitt commented 3 years ago

Hi @un0btanium,

I think this is only an issue with the demo, which uses graphlib-dot to validate that the input string is valid DOT (the code for that is here) and it seems as if it doesn't correctly parse HTML-like labels. This code isn't present in the actual graphlib-react library, which does no validation on the structure of the input strings and leaves that up to the consumer of the library, it only affects the demo.

A quick look at the graphlib-dot repo and this issue seems to be related to the issue you're having. Setting the labelType to "html", as per the below example, should allow you to use HTML-like labels in the demo.

graph { 
  a [label=<<b>Test</b>> labelType="html"]
}

Hope that helps.

DomParfitt commented 3 years ago

Actually, using labelType doesn't seem to solve the issue. Regardless, it's only an issue with the demo and not the actual library.

un0btanium commented 3 years ago

Oh, I see. That's good news. I tried it out and it does indeed work properly in my React application. Thank you :)