]> granicus.if.org Git - graphviz/commitdiff
Add html() function to create HTML-like strings
authorerg <devnull@localhost>
Wed, 11 Aug 2010 16:10:38 +0000 (16:10 +0000)
committererg <devnull@localhost>
Wed, 11 Aug 2010 16:10:38 +0000 (16:10 +0000)
cmd/gvpr/gvpr.1
lib/gvpr/actions.c
lib/gvpr/actions.h
lib/gvpr/compile.c
lib/gvpr/gprdata

index 9ab0ffd35abd811ac0080382a95c9d7f0f477a35..32306c9f194b09b9aef34921a81cbdc2c16d4cb2 100644 (file)
@@ -663,6 +663,15 @@ returns a version of \fIs\fP with the alphabetic characters converted to lower-c
 returns a version of \fIs\fP appropriate to be used as an identifier
 in a dot file.
 .TP
+\fBhtml\fP(\fIg\fP : \fBgraph_t\fP, \fIs\fP : \fBstring\fP) : \fBstring\fP
+returns a ``magic'' version  of \fIs\fP as an HTML string. This will typically be
+used to attach an HTML-like label to a graph object. Note that the returned string
+lives in \fIg\fP. In particular, it will be freed when \fIg\fP is closed, and to
+act as an HTML string, it has to be used with an object of \fIg\fP. In addition,
+note that the
+angle bracket quotes should not be part of \fIs\fP. These will be added if 
+\fIg\fP is written in concrete DOT format.
+.TP
 \fBxOf\fP(\fIs\fP : \fBstring\fP) : \fBstring\fP
 returns the string "\fIx\fP" if \fIs\fP has the form "\fIx\fP,\fIy\fP", 
 where both \fIx\fP and \fIy\fP are numeric.
@@ -1073,7 +1082,7 @@ Computes the degrees of nodes with edges.
 Colon\(hyseparated list of directories to be searched to find
 the file specified by the \-f option.
 .SH BUGS AND WARNINGS
-Scripts should be careful deleting nodes during \fBN{}\fP and \fBE{}\fp
+Scripts should be careful deleting nodes during \fBN{}\fP and \fBE{}\fP
 blocks using BFS and DFS traversals as these rely on stacks and queues of
 nodes. 
 .PP
index 7071e5efbdcf8514ef7fa418d7d721655546e8d8..ada9b74f639fcb16f6ccbb3edfa33f399697d5c2 100644 (file)
@@ -793,6 +793,14 @@ char *toUpper(Expr_t * pgm, char *s, Sfio_t* tmps)
     return exstring(pgm, sfstruse(tmps));
 }
 
+/* toHtml:
+ * Create a string marked as HTML
+ */
+char *toHtml(Agraph_t* g, char *arg)
+{
+    return agstrdup_html (g, arg);
+}
+
 /* canon:
  * Canonicalize a string for printing.
  */
@@ -806,6 +814,7 @@ char *canon(Expr_t * pgm, char *arg)
 
     return p;
 }
+
 #include <stdlib.h>
 #ifdef WIN32
 #include "compat.h"
index f380511635dadf73f7ac86cb8553cf4f409d319f..adc9fe7293c42abcf77337c4da4f24ab8f8827a5 100644 (file)
@@ -48,6 +48,7 @@ extern "C" {
     extern int closeFile(Expr_t *, int);
     extern char *readLine(Expr_t *, int);
     extern char *canon(Expr_t * pgm, char *);
+    extern char *toHtml(Agraph_t*, char *);
     extern char *toLower(Expr_t * pgm, char *, Sfio_t*);
     extern char *toUpper(Expr_t * pgm, char *, Sfio_t*);
     extern int deleteObj(Agraph_t * g, Agobj_t * obj);
index a7f8881580f4a75d06325f0bb47b317937ee9136..a85911fb01007b6383d25013c3d3cb99f0f04f2c 100644 (file)
@@ -1379,6 +1379,15 @@ getval(Expr_t * pgm, Exnode_t * node, Exid_t * sym, Exref_t * ref,
        case F_canon:
            v.string = canon(pgm, args[0].string);
            break;
+       case F_html:
+           gp = INT2PTR(Agraph_t *, args[0].integer);
+           if (gp) {
+               v.string = toHtml(gp, args[1].string);
+           } else {
+               error(ERROR_WARNING, "NULL graph passed to html()");
+               v.string = 0;
+           }
+           break;
        case F_tolower:
            v.string = toLower(pgm, args[0].string, state->tmp);
            break;
index 230a6b73711a95d6ab8ab4ceaba060c0b9eef353..cf1d4bb4f6cf6d588ca669ab192cfc888fdfd07e 100644 (file)
@@ -99,6 +99,7 @@ F_xof       "xOf"          FUNCTION S|A(1,S)
 F_yof       "yOf"          FUNCTION S|A(1,S)
 F_llof      "llOf"         FUNCTION S|A(1,S)
 F_urof      "urOf"         FUNCTION S|A(1,S)
+F_html      "html"         FUNCTION S|A(1,G)|A(2,S)
 F_canon     "canon"        FUNCTION S|A(1,S)
 F_get       "aget"         FUNCTION S|A(1,O)|A(2,S)
 F_set       "aset"         FUNCTION I|A(1,O)|A(2,S)|A(3,S)