Skip to content

Commit

Permalink
Add parsing penwidth attribute
Browse files Browse the repository at this point in the history
'penwidth' defines the line width as 'width'. If both are exist,
'penwidth' is used and 'width' is discarded as described in [1].
This update fixes #24.

[1] https://www.graphviz.org/doc/info/attrs.html#d:penwidth
  • Loading branch information
geminoa committed Sep 18, 2018
1 parent a55f145 commit 997e614
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/network/dotparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,25 @@ function parseAttributeList() {

attr_list = parseDirAttribute(attr_names, attr_list);

var nof_attr_list = attr_list.length;
// parse 'penwidth'
var nof_attr_list;
if (attr_names.includes('penwidth')) {
var tmp_attr_list = [];

nof_attr_list = attr_list.length;
for (i = 0; i < nof_attr_list; i++) {
// exclude 'width' from attr_list if 'penwidth' exists
if (attr_list[i].name !== 'width') {
if (attr_list[i].name === 'penwidth') {
attr_list[i].name = 'width';
}
tmp_attr_list.push(attr_list[i]);
}
}
attr_list = tmp_attr_list;
}

nof_attr_list = attr_list.length;
for (i = 0; i < nof_attr_list; i++) {
setValue(attr_list[i].attr, attr_list[i].name, attr_list[i].value)
}
Expand Down

0 comments on commit 997e614

Please sign in to comment.