All predicatesShow sourcesvgtree.pl -- SWISH SVG tree renderer

Render a term as an SVG tree. This renderer is intended to illustrate the shape of terms or display a simple parse tree.

This renderer is also an illustration of using a JavaScript library and SVG inside rendered elements. Note that the use of RequireJS avoids loading the library multiple times as well as poluting the namespace.

Note that while the script is being evaluated, `$.ajaxScript` is a jQuery object pointing to the executing script. This is used to find the span element without using an id attribute. Using id is undesirable as it is hard to guarantee their uniqueness. However, we must find the desired element immediately and not in the RequireJS callback, so we need to put it in a variable and scope the whole thing in a function to avoid conflicts. JavaScript is fun!

Source term_rendering(+Term, +Vars, +Options)//
Render a compound term as a tree. Options processed:
list(Boolean)
If false, do not render lists.
filter(:NodeFilter)
If present, use call(NodeFilter, Term, Label, Children) to extract the label and children of a term. Operates on terms for which this call succeeds on the top node. If the call fails on a child, the child is rendered as a term.
Source is_term_tree(+Term, -Closure, +Options) is semidet[private]
True when Term is a Prolog term that can meaningfully be displayed as a tree. The actual rendering is done by calling call(Closure, Term, JSON), where the called closure must return a nested dict and each node contains:
label
The label to display. This is either a string or a dict containing html:HTMLString
children
If present, this is a list of child nodes. If not, it is a leaf node.
Source compound_tree(+Options, +Term, -JSON) is det
Render Term as a tree, considering every compound term to be a node. Renders leafs using term//1.
Source term_label(+Term, -Label, +Options) is det[private]
Create a label for a term. If we can, we generate HTML using term//2, which is translated into an SVG foreignObject. The Trident engine used by IE does not support foreignObject though :-(
Source filtered_tree(:Filter, +Options, +Term, -JSON) is det
Render a filtered tree.
Source is_trident is semidet[private]
True if we know that the client is Trident-based (IE)