graphviz-2999.11.0.0: Graphviz bindings for Haskell.



This module defines the syntax for HTML-like values for use in Graphviz. Please note that these values are not really HTML, but the term "HTML" is used throughout as it is less cumbersome than "HTML-like". To be able to use this, the version of Graphviz must be at least 1.10. For more information, please see:

The actual definition of the syntax specifies that these types must be valid XML syntax. As such, this assumed when printing and parsing, though the correct escape/descaping for ", &, < and > are automatically done when printing and parsing.

Differences from how Graphviz treats HTML-like values:

  • Graphviz only specifies the above-listed characters must be escaped; however, internally it also escapes -, ' and multiple sequences of spaces. This library attempts to match this behaviour. Please let me know if this behaviour (especially about escaping multiple spaces) is unwanted.
  • When parsing escaped HTML characters, numeric escapes are converted to the corresponding character as are the various characters listed above; all other escaped characters (apart from those listed above) are silently ignored and removed from the input (since technically these must be valid XML, which doesn't recognise as many named escape characters as does HTML).
  • All whitespace read in is kept (even if Graphviz would ignore multiple whitespace characters); when printing them, however, they are replaced with non-breaking spaces. As such, if multiple literal whitespace characters are used in a sequence, then the result of parsing and then printing some Dot code will not be the same as the initial Dot code. Furthermore, all whitespace characters are printed as spaces.
  • It is assumed that all parsed & values are the beginning of an XML escape sequence (which must finish with a ; character).
  • There should be no pre-escaped characters in values; when printing, the & will get escaped without considering if that is an escaped character.



data HtmlLabel Source

The overall type for HTML-like labels. Fundamentally, HTML-like values in Graphviz are either textual (i.e. a single element with formatting) or a table. Note that HtmlLabel values can be nested via HtmlLabelCell.

type HtmlText = [HtmlTextItem]Source

Represents a textual component of an HTML-like label. It is assumed that an HtmlText list is non-empty. It is preferable to "group" HtmlStr values together rather than have individual ones. Note that when printing, the individual values are concatenated together without spaces, and when parsing anything that isn't a tag is assumed to be an HtmlStr: that is, something like "<BR/> <BR/>" is parsed as:

 [HtmlNewline [], HtmlStr " ", HtmlNewline []]

data HtmlTextItem Source

Textual items in HTML-like labels.


HtmlStr String 
HtmlNewline HtmlAttributes

Only accepts an optional HtmlAlign HtmlAttribute; defined this way for ease of printing/parsing.

HtmlFont HtmlAttributes HtmlText 

data HtmlTable Source

A table in HTML-like labels. Tables are optionally wrapped in overall FONT tags.




tableFontAttrs :: Maybe HtmlAttributes

Optional FONT attributes. Just [] denotes empty FONT tags; Nothing denotes no such tags.

tableAttrs :: HtmlAttributes
tableRows :: [HtmlRow]

This list is assumed to be non-empty.

newtype HtmlRow Source

A row in an HtmlTable. The list of HtmlCell values is assumed to be non-empty.


HtmlRow [HtmlCell] 

data HtmlCell Source

Cells either recursively contain another HtmlLabel or else a path to an image file.

newtype HtmlImg Source

The path to an image; accepted HtmlAttributes are HtmlScale and HtmlSrc.


HtmlImg HtmlAttributes 

type HtmlAttributes = [HtmlAttribute]Source

The various HTML-like label-specific attributes being used.

data HtmlAttribute Source

Note that not all HtmlAttribute values are valid everywhere: see the comments for each one on where it is valid.


HtmlAlign HtmlAlign

Valid for: HtmlTable, HtmlCell, HtmlNewline.

HtmlBAlign HtmlAlign

Valid for: HtmlCell.

HtmlBGColor Color

Valid for: HtmlTable (including tableFontAttrs), HtmlCell, HtmlFont.

HtmlBorder Word8

Valid for: HtmlTable, HtmlCell. Default is 1; 0 represents no border.

HtmlCellBorder Word8

Valid for: HtmlTable. Default is 1; 0 represents no border.

HtmlCellPadding Word8

Valid for: HtmlTable, HtmlCell. Default is 2.

HtmlCellSpacing Word8

Valid for: HtmlTable, HtmlCell. Default is 2; maximum is 127.

HtmlColor Color

Valid for: HtmlTable, HtmlCell.

HtmlColSpan Word16

Valid for: HtmlCell. Default is 1.

HtmlFace String

Valid for: tableFontAttrs, HtmlFont.

HtmlFixedSize Bool

Valid for: HtmlTable, HtmlCell. Default is False.

HtmlHeight Word16

Valid for: HtmlTable, HtmlCell.

HtmlHRef String

Valid for: HtmlTable, HtmlCell.

HtmlPointSize Double

Valid for: tableFontAttrs, HtmlFont.

HtmlPort PortName

Valid for: HtmlTable, HtmlCell.

HtmlRowSpan Word16

Valid for: HtmlCell.

HtmlScale HtmlScale

Valid for: HtmlImg.

HtmlSrc FilePath

Valid for: HtmlImg.

HtmlTarget String

Valid for: HtmlTable, HtmlCell.

HtmlTitle String

Valid for: HtmlTable, HtmlCell. Has an alias of TOOLTIP.

HtmlVAlign HtmlVAlign

Valid for: HtmlTable, HtmlCell.

HtmlWidth Word16

Valid for: HtmlTable, HtmlCell.

data HtmlAlign Source

Specifies horizontal placement. When an object is allocated more space than required, this value determines where the extra space is placed left and right of the object.



Default value.


HtmlLabelCell values only; aligns lines of text using the full cell width. The alignment of a line is determined by its (possibly implicit) associated HtmlNewline element.

data HtmlVAlign Source

Specifies vertical placement. When an object is allocated more space than required, this value determines where the extra space is placed above and below the object.



Default value.


data HtmlScale Source

Specifies how an image will use any extra space available in its cell. If undefined, the image inherits the value of the ImageScale attribute.