mdaines / viz-js

Graphviz in your browser
https://viz-js.com/
MIT License
4.08k stars 352 forks source link

Special Characters: Results in syntax error #14

Closed lenntt closed 10 years ago

lenntt commented 11 years ago

When I have the following dot code (with setting charset or leaving it default to utf8):

      digraph full_graph {
         graph [charset="latin1"];
         0 -> 1 [label="éñॐ턞鸽V000_000"];
      }

Then Viz.js rendering does not render the edge and shows an error:

Error: :3: syntax error near line 3

While running graphviz from the command line by:

    dot -Tsvg graph.dot -o test.svg -v

I get the svg I expected.

There's probably not a simple fix for this (or has emscripten some build-in magic??), but though you should know.

mdaines commented 11 years ago

I'm not sure if there's a simple fix, but for some special characters it is possible to use HTML entities. I am using • and → in Grammophone, for example.

succeun commented 11 years ago

solved.. http://smartchamploo.blogspot.kr/2013/03/vizjs.html

As-is

function src(id) {
  return document.getElementById(id).innerHTML;
}

To-be

function src(id) {
  var dot = document.getElementById(id).innerHTML;
  return dot + new Array(dot.length).join(" ");
}
vmarkovtsev commented 10 years ago

Works for me on the latest 0.0.3 without patching src function. If there are still problems with Unicode left, feel free to reopen this.