Html labels with placeholders

I have many nodes with table html labels which differs only by a few words. is there a way to set the html as default node label with special notation that will be substitued by values at render time, in the same way that it’s done with node name and \N ?

I don’t believe graphviz has a feature like that.

If I’m not mistaken, you’re asking about an enhancement to strdup_and_subst_obj0that seems like it might be only a few lines of code (except we need to extract an attribute name or inline literal value from the escape sequence, which seems like a more ambitious extension). SUMMON MY SUMMER INTERNS.

Short answer: no
Longer answer: there are lots of ways to accomplish your goal, but the right answer depends on your OS (Windows, Linux, MACOS, …), your tech knowledge, and the specifics of how you want to accomplish your goal.
We can probably provide a solution, but we need more info.

Note that the \N analogy does not seem to quite apply. \N is replaced with a value from within the graph, while
(I assume) you want more of a “form letter” / template where the substitute values come from “outside”

I have no idea how/if it would be possible to implement it. but as unless i’m mistaken, unknown attributes are ignored by the renderer, so my idea was something looking like

node [
	shape=plain
	label=<<table>
			<tr><td>\N</td></tr>
			<tr><td>\var</td></tr>
		  </table>>
]

nodename [var="some text"]

or, if variable by name are out of feasibility

node [
	shape=plain
	label=<<table>
			<tr><td>\N</td></tr>
			<tr><td>\_1</td></tr>
		  </table>>
]

nodename [_1="some text"]

Here is a “maybe good enough” result. The input was edited by a slapped-together gvpr (https://www.graphviz.org/pdf/gvpr.1.pdf) program named gvEd.gvpr.
The command line is gvpr -cf gvEd.gvpr htmlVars0.gv | dot -Tpng ...
I will publish gvEd.gvpr sometime this week (it need testing & cleanup)

graph H{

node [
	shape=plain
	label=<<table>
		<tr><td>\N</td></tr>
		<tr><td BGCOLOR=_BGC>txt2</td></tr>
		<tr><td>just some words</td></tr>
		<tr><td>var</td></tr>
	  </table>>
]

node1 [var="some text" txt2="more words" _BGC="\"white\""]
node2 [var="some more text" txt2="one word"  dummy=abc junk=xyz _BGC="\"white\""]
node3 [var="text3" txt2="no more words" _BGC="\"RED\""]
node4 [var="text four" txt2="some words" _BGC="\"GREEN\""]
node1 -- { node2 node3 node4 }

node100 [label="not html" width=1]

node [
	shape=plain
	label=<<table>
		<tr><td>Round No. 2</td></tr>
		<tr><td>var</td></tr>
		<tr><td>just some words</td></tr>
		<tr><td>txt2</td></tr>
	  </table>>
]
node5 [var="something" txt2="these words"]
node6 [var="one hot dog" txt2="no more words"]
node7 [var="over<br/>under" txt2="last words"]
node5 -- node6 -- node7

}

Giving:

Does this look close enough?

YES, that’s exactly what I am after !

I’m eagerly waiting for the gvpr source to learn something new :slightly_smiling_face:

gvEd.gvpr can be found here:

Usage example:
gvpr -a P__ -cf gvEd.gvpr htmlVars1.gv | dot -Tpng -ooo.png

htmlVars1.gv:


graph H {

  edge [
    __EC1="green" __EC2=purple __EC3="\"lightblue\""
  ] 
  node[label="\N"  XYZ="12345"]
  a -- b -- c [color=__EC1]

  node [
    shape=plain
    label=<<table>
    <tr><td>\N</td></tr>
    <tr><td __BGC>__txt2</td></tr>
    <tr><td>just some words</td></tr>
    <tr><td>__var</td></tr>
    </table>>
  ]

  node1 [__var="some text" __txt2="more words"]
  node2 [__var="some more text" __txt2="one word"  dummy=abc junk=xyz ]
  node3 [__var="text3" __txt2="no more words" __BGC="BGCOLOR=\"RED\""]
  node4 [__var="text four" __txt2="some words" __BGC="BGCOLOR=\"GREEN\""]
  node1 -- { node2 node3 node4 } 

  node100 [shape=rect label="Plain, not html" width=1]

  node [
    shape=plain
    label=<<table>
    <tr><td>Round No. 2</td></tr>
    <tr><td>__var</td></tr>
    <tr><td>just some words</td></tr>
    <tr><td>__txt2</td></tr>
    </table>>
  ]
  node5 [__var="something" __txt2="these words"]
  node6 [__var="one hot dog" __txt2="no more words"]
  node7 [__var="over<br/>under" __txt2="last words"]
  edge [color=purple label="\E"]
  node5 -- node6 -- node7 [color=__EC2]
}

see also: gvInclude.gvpr - insert a Graphviz code file into another Graphviz file