PublicShow 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 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 filtered_tree(:Filter, +Options, +Term, -JSON) is det
Render a filtered tree.