From: Matthew Fernandez Date: Thu, 24 Jun 2021 02:55:29 +0000 (-0700) Subject: gv2gxl: in GXL output, indicate when a label originated as an HTML like label X-Git-Tag: 2.48.0~14^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80ff3d1f8d05672e5d983e8696f5f2fb51d9e4bb;p=graphviz gv2gxl: in GXL output, indicate when a label originated as an HTML like label When translating Dot to GXL, labels come out as strings. Input something like: `label="foo"` and the GXL output is something like `foo`. This translation is fine and works well, until you start using HTML like labels. Graphviz allows `<` and `>` as delimiters to indicate your label string contains HTML that should be parsed. When you try to use this feature in combination with gv2gxl, you get a lossy translation. E.g. the labels `label="foo"` and `label=` come out identically in GXL. This commit makes use of the GXL ‘kind’ field on attributes to note that the source was an HTML like label. If you translate the two labels from above, you will now get: foo and foo respectively. This is a partial fix for #517. This makes the translation to GXL no longer lossy. The other half of this is recognizing the ‘kind’ field during gxl2gv translation and preserving it on the way back. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 015e37a56..88f801cc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix a typo `GD_LIBS` to `GDLIB_LIBS` in `tclpkg/tcldot/Makefile.am` !2022 - Autotools build system sets libgd variables now instead of incorrectly setting GTK variables +- HTML strings used as labels are distinguishable in GXL output by + `kind="HTML-like string"` ## [2.47.3] - 2021-06-19 diff --git a/cmd/tools/gv2gxl.c b/cmd/tools/gv2gxl.c index c1adbc7f1..4f525db76 100644 --- a/cmd/tools/gv2gxl.c +++ b/cmd/tools/gv2gxl.c @@ -649,7 +649,12 @@ writeNondefaultAttr(void *obj, FILE * gxlFile, Dict_t * defdict) fprintf(gxlFile, "\t\n"); } else { tabover(gxlFile); - fprintf(gxlFile, "\t\n", xml_string(sym->name)); + fprintf(gxlFile, "\tname)); + if (aghtmlstr(data->str[sym->id])) { + // This is a <…> string. Note this in the kind. + fprintf(gxlFile, " kind=\"HTML-like string\""); + } + fprintf(gxlFile, ">\n"); tabover(gxlFile); fprintf(gxlFile, "\t\t%s\n", xml_string(data->str[sym->id])); tabover(gxlFile);