@@ -30,7 +30,8 @@ property_set=[
3030 (src= " cases" ,dst= " regres" ,color= " orange" ,penwidth= " 4.0" ,style= " solid" ,),
3131 (src= " weather" ,dst= " temp" ,color= " orange" ,penwidth= " 4.0" ,style= " solid" ,),
3232 (src= " demo" ,dst= " age" ,color= " orange" ,penwidth= " 4.0" ,style= " solid" ,),
33- (src= " regres" ,dst= " cost" ,color= " orange" ,penwidth= " 4.0" ,style= " solid" ,)
33+ (src= " regres" ,dst= " cost" ,color= " orange" ,penwidth= " 4.0" ,style= " solid" ,),
34+ (src= " html" ,dst= " fed" ,color= " black" ,penwidth= " 2.0" ,style= " solid" ,)
3435]
3536
3637# name, label, color
@@ -59,9 +60,10 @@ vprops = [
5960 (" cases" ," Flu\\ nCases" ," #5DADE2" ),
6061 (" prices" ," Vacc\\ nPrice" ," #5DADE2" ),
6162 (" regres" , " Regression" , " #5DADE2" ),
63+ (" html" , " <<U><B>Title </B></U> <BR/> Some text.>" , " #000000" ),
6264]
6365
64- g = MetaDiGraph (24 )
66+ g = MetaDiGraph (25 )
6567
6668set_prop! (g, :pack , true )
6769
@@ -95,11 +97,38 @@ for v in vertices(g)
9597 set_prop! (g, v, :penwidth , 2.0 )
9698end
9799
98- savegraph (" diagram.dot" , g, DOTFormat ())
99- open (" diagram_ref.dot" ) do fp
100- s_ref = read (fp)
101- open (" diagram.dot" ) do fp
102- s = read (fp)
103- @test s == s_ref
100+ @testset " dotio" begin
101+ savegraph (" diagram.dot" , g, DOTFormat ())
102+ open (" diagram_ref.dot" ) do fp
103+ s_ref = read (fp)
104+ open (" diagram.dot" ) do fp
105+ s = read (fp)
106+ @test s == s_ref
107+ end
108+
109+ # Verify that HTML labels are saved without quotes, but that "conventional" (non-html) labels are saved with quotes.
110+ # The label attribute should be either delimited by:
111+ # - "..." : OK
112+ # - <...> : OK
113+ # - both : NOK ("< or >" as bounding characters, resulting HTML in file will not be parsed correctly by dot.)
114+ quote_regex = r" label\s *=\s *\" (?:[^\"\\ ]|\\ .)*\" " # source: https://stackoverflow.com/questions/249791/regex-for-quoted-string-with-escaping-quotes
115+ html_regex = r" label\s *=\s *<.*>"
116+ invalid_quote_regex = r" label\s *=\s *\" <(?:[^\"\\ ]|\\ .)*>\" "
117+ for line in eachline (fp)
118+ test_val = false
119+ if ! occursin (r" label\s *=" ,line)
120+ # the line does not contain a "label" attribute
121+ test_val = true
122+ elseif occursin (quote_regex, line)
123+ # check if a "< or >" combination is present as outer delimiter, this shouldn't occur.
124+ test_val = ! occursin (invalid_quote_regex, line)
125+ elseif occursin (html_regex, line)
126+ # no worries, proper HTML surrounding brackets found.
127+ test_val = true
128+ end
129+ @test test_val
104130 end
105131end
132+
133+
134+ end
0 commit comments