• Resolved JoachimDurchholz

    (@joachimdurchholz)


    Using this:

    digraph hierarchy {
    size="5,5"
    node[shape=record,style=filled,fillcolor=gray95]
    edge[dir=back, arrowtail=empty]
    
    2[label = "{AbstractSuffixTree|+ text\n+ root|...}"]
    3[label = "{SimpleSuffixTree|...| + constructTree()\l...}"]
    4[label = "{CompactSuffixTree|...| + compactNodes()\l...}"]
    5[label = "{SuffixTreeNode|...|+ addSuffix(...)\l...}"]
    6[label = "{SuffixTreeEdge|...|+ compactLabel(...)\l...}"]
    
    2->3
    2->4
    5->5[constraint=false, arrowtail=odiamond]
    4->3[constraint=false, arrowtail=odiamond]
    2->5[constraint=false, arrowtail=odiamond]
    5->6[arrowtail=odiamond]
    }

    Putting the dot source inside hierarchy.dot and running dot -O -Tsvg hierarchy.dot works just fine, putting it between [graphviz] markers gives me this:

    Error generating Graphviz image
    
    Graphviz cannot generate graph
    Warning: : syntax error in line 2 near ']'

    I have no way of finding out what’s wrong.
    Well okay removing the size parameter gave me another error, so I can find out problems by commenting out individual lines. Actually I’d be okay with that if errors happened just occasionally, but I’m not okay if I need to do this multiple times with no indication how many more problems of that kind mind be waiting for me.

    It would be nice if the plugin printed the full path name of the generated .dot file and the command-line invokation it used.

    The plugin page shows the generated sample graph, and pasting the code there to the WP page works just fine, too.

    Using TFO-Graphviz 1.12, which is accessing Graphviz through graphviz path /usr/bin/dot. Graphviz itself is dot - graphviz version 2.36.0 (20140111.2315).

    As things are, my only way forward is to generate the graphs offline.
    That will also fix the lack of svg support.

    https://www.ads-software.com/plugins/tfo-graphviz/

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Chris Luke

    (@chrisy)

    If I remove the “size” directive, your dot works for me, so I’ll investigate why that is.

    I’ll add something to the error to show you the command line; the dot itself is fed into stdinof the dot process. Would it be useful to have it include the dot in the error message? I think it will help because there’s whitespace mangling going on. What wordpress gives us from between the [graphviz] markers has various HTML encoding going on – some of which is destructive to whitespace. I could even add line numbers.

    As for svg, it wasn’t widely renderable when this was written and nobody else has asked for it. That can be added, too.

    Plugin Author Chris Luke

    (@chrisy)

    I may have worked it out. I think WordPress is converting the second ” mark into a special one.

    size="5,5"

    became

    size="5,5″

    Meh, this may need some work.

    Thread Starter JoachimDurchholz

    (@joachimdurchholz)

    The example dot renders as 17k in png and 6k in svg; not a big deal but might become a factor for larger graphs. Plus, maybe future browsers allow copying labels from SVGs so people can paste them to their texts (never give up hope ?? ).
    SVG is widely accepted enough for Wikipedia to use it, so I guess it’s ready for the unwashed masses ??

    Yes, a dotfile dump with line numbers would be really, really, really pretty please nice!
    Graphviz error messages are vague enough to be almost useless, the line number is almost the only thing to go by. I don’t know whether whitespace mangling can fold lines, but if it does, then line numbers will be indispensable to diagnose problems.
    If whitespace mangling can create syntax errors, then printing the dot source will also be essential to even start diagnosing things.

    The command line would be heplful, too, to find out whether the options given in the [graphviz] tag are getting transformed to the options I expect.
    It’s not as important as the dot source dump, but it would be very nice to have.

    Thread Starter JoachimDurchholz

    (@joachimdurchholz)

    Urk. That quote mark conversion really stinks.
    That might explain why all the other lines fail, too. There are many strings in the example dot. The size setting isn’t that important (it’s just what happened to be in the example I was working off, and scheduled for removal-if-possible), but somehow I doubt I can work entirely without quote marks, I need to do a lot of labelling with all kinds of punctuation for UML diagrams.
    It would be nice if the WP API offered a way to say “please don’t transform the stuff between [graphviz] and [/graphviz]”, but given that you say “needs some work” I guess that’s not available.

    Plugin Author Chris Luke

    (@chrisy)

    If you’re curious, this is what WordPress turned your DOT into:

    1
        2 digraph hierarchy {
        3 size="5,5″
        4 node[shape=record,style=filled,fillcolor=gray95]
        5 edge[dir=back, arrowtail=empty]
        6 2[label = "{AbstractSuffixTree|+ text\n+ root|…}"]
        7 3[label = "{SimpleSuffixTree|…| + constructTree()\l…}"]
        8 4[label = "{CompactSuffixTree|…| + compactNodes()\l…}"]
        9 5[label = "{SuffixTreeNode|…|+ addSuffix(…)\l…}"]
       10 6[label = "{SuffixTreeEdge|…|+ compactLabel(…)\l…}"]
       11 2->3;
       12 2->4;
       13 5->5[constraint=false, arrowtail=odiamond]
       14 4->3[constraint=false, arrowtail=odiamond]
       15 2->5[constraint=false, arrowtail=odiamond]
       16 5->6[arrowtail=odiamond]
       17 }
       18

    I’ve added mappings for the two characters it’s mangling there. I just wish there was a way to turn this off.

    Plugin Author Chris Luke

    (@chrisy)

    I have added the SVG format too. Once I’ve tested it a bit I’ll release version 1.13.

    Plugin Author Chris Luke

    (@chrisy)

    https://blog.flirble.org/2015/11/15/adding-svg-support-tfo-graphviz/ if you want to see the SVG thing working ??

    Plugin Author Chris Luke

    (@chrisy)

    Hm, so I added width and height attributes so you could scale the SVG to the page; unfortunately it seems browsers don’t scale attached image maps with the image.

    The only way I see to fix this is to include some JavaScript that will do it, which feels icky for what this plugin is doing. Any thoughts?

    Plugin Author Chris Luke

    (@chrisy)

    Okay, I’ve pushed version 1.13. Give it a test and let me know if it works for you, please!

    Thread Starter JoachimDurchholz

    (@joachimdurchholz)

    Many thanks – looking forward to trying out 1.13!

    The imagemap problem isn’t going to affect me, but if you can refer me to a URL with a failing imagemap, I may be able to spot something off.

    Thread Starter JoachimDurchholz

    (@joachimdurchholz)

    MUCH better!

    Now I get this:

    Error generating Graphviz image

    Graphviz cannot generate graph
    Command: /usr/bin/dot ‘-Kdot’ ‘-Tpng’ ‘-o/var/www/webs/jo/html/durchholz.org/wp-content/tfo-graphviz/872702058610b9e66b4cdd7930c3ed7f.png’
    Output:
    Warning: : syntax error in line 7 near ‘&’

    Original DOT:
    1
    2 digraph hierarchy {
    3 size=”5,5″
    4 node[shape=record,style=filled,fillcolor=gray95]
    5 edge[dir=back, arrowtail=empty]
    6
    7 2[label = ?{AbstractSuffixTree|+ text\n+ root|…}”]
    8 3[label = ?{SimpleSuffixTree|…| + constructTree()\l…}”]
    9 4[label = ?{CompactSuffixTree|…| + compactNodes()\l…}”]
    10 5[label = ?{SuffixTreeNode|…|+ addSuffix(…)\l…}”]
    11 6[label = ?{SuffixTreeEdge|…|+ compactLabel(…)\l…}”]
    12
    13 2->3
    14 2->4
    15 5->5[constraint=false, arrowtail=odiamond]
    16 4->3[constraint=false, arrowtail=odiamond]
    17 2->5[constraint=false, arrowtail=odiamond]
    18 5->6[arrowtail=odiamond]
    19 }
    20

    Which is still a failure but at least I’m seeing it’s leaving in the opening quotes. These are opening quotes, not HTML entities.
    I found that this is caused by language preferences; the opening quotes in German are different than the closing ones.

    Language differences do more. This is what I get for French:

    1
    2 digraph hierarchy {
    3 size= ?5,5″
    4 node[shape=record,style=filled,fillcolor=gray95]
    5 edge[dir=back, arrowtail=empty]
    6
    7 2[label = ? {AbstractSuffixTree|+ text\n+ root|…} ?]
    8 3[label = ? {SimpleSuffixTree|…| + constructTree()\l…} ?]
    9 4[label = ? {CompactSuffixTree|…| + compactNodes()\l…} ?]
    10 5[label = ? {SuffixTreeNode|…|+ addSuffix(…)\l…} ?]
    11 6[label = ? {SuffixTreeEdge|…|+ compactLabel(…)\l…} ?]

    … but I LOVE how I can see what’s actually happening!

    Plugin Author Chris Luke

    (@chrisy)

    I can add mappings for your opening quotes to plain ASCII ones if you can tell me the &#...; for it. (replace the … with hex).

    Or maybe I should look for a complete such list, or a module that already does it. Hmm.

    As for the imagemap, I “fixed” it with some JavaScript – but it only loads it if you both use imagemaps and set either width or height attributes, so it shouldn’t affect anyone else.

    Plugin Author Chris Luke

    (@chrisy)

    Oh, I think I’ve found the proper answer. https://codex.www.ads-software.com/Plugin_API/Filter_Reference/no_texturize_shortcodes

    Not tested it yet, but will give it a go.

    Thread Starter JoachimDurchholz

    (@joachimdurchholz)

    no_texturize_shortcodes looks good, yes.

    Avoid JS if you can. My offer to take a look at a non-working URL stands.

    Plugin Author Chris Luke

    (@chrisy)

    no_texturize_shortcodes works for the HTML entities. It doesn’t stop it turning newlines into <br /> and <p>...</p> tags though. Having a dig for that now.

    As for the scaling, it’s an issue where I don’t set the size in the dot explicitly and then scale the resulting svg in the <img> tag; it doesn’t also scale the map.

    If I don’t scale the output image using width/height in the img tag then there’s no problem; but I can imagine some themes, especially responsive themes, will alter the image size to fit the layout, so some sort of post-processing is required regardless.

    Anyway, I’ll setup a page later showing this.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Doesn't work, no idea why’ is closed to new replies.