Allows the use of multiple tree structures. Provides tools to create, manipulate, and query the the trees individually and/or collectively.
Allows the use of multiple tree structures. Provides tools to create, manipulate, and query the the trees individually and/or collectively.
Default output buffer size for filter-enlive-subtrees
.
Default output buffer size for `filter-enlive-subtrees`.
(->Node hids)
Inputs: [hids :- [HID]] Returns: Node
Constructs a Node from a vector of HIDs
Inputs: [hids :- [HID]] Returns: Node Constructs a Node from a vector of HIDs
(add-bush bush)
Inputs: [bush] Returns: HID
Adds a bush to the forest
Inputs: [bush] Returns: HID Adds a bush to the forest
(add-node attrs-arg)
(add-node attrs-arg kid-hids)
Inputs: ([attrs-arg] [attrs-arg :- (s/if map? tsk/KeyMap s/Keyword) kid-hids :- [HID]]) Returns: HID
Inputs: ([attrs-arg] [attrs-arg :- (s/if map? tsk/KeyMap s/Keyword) kid-hids :- [HID]]) Returns: HID
(add-tree tree-node)
Inputs: [tree-node :- tsk/KeyMap] Returns: HID
Adds a tree to the forest.
Inputs: [tree-node :- tsk/KeyMap] Returns: HID Adds a tree to the forest.
(add-tree-edn arg)
Inputs: [arg] Returns: HID
Adds a EDN-format tree to the forest.
Inputs: [arg] Returns: HID Adds a EDN-format tree to the forest.
(add-tree-enlive arg)
Inputs: [arg] Returns: HID
Adds an Enlive-format tree to the forest
Inputs: [arg] Returns: HID Adds an Enlive-format tree to the forest
(add-tree-hiccup arg)
Inputs: [arg] Returns: HID
Adds a Hiccup-format tree to the forest.
Inputs: [arg] Returns: HID Adds a Hiccup-format tree to the forest.
(add-tree-html html-str)
Inputs: [html-str :- s/Str] Returns: HID
Adds a tree to the forest from an HTML string.
Inputs: [html-str :- s/Str] Returns: HID Adds a tree to the forest from an HTML string.
(add-tree-xml xml-str)
Inputs: [xml-str :- s/Str] Returns: HID
Adds a tree to the forest from an XML string.
Inputs: [xml-str :- s/Str] Returns: HID Adds a tree to the forest from an XML string.
(all-hids)
Inputs: [] Returns: #{HID}
Returns a set of all HIDs in the forest
Inputs: [] Returns: #{HID} Returns a set of all HIDs in the forest
(attr-get hid attr-name)
Inputs: [hid :- HID attr-name :- s/Keyword] Returns: tsk/KeyMap
Use the supplied function & arguments to update the attr value for a Node as in clojure.core/update
Inputs: [hid :- HID attr-name :- s/Keyword] Returns: tsk/KeyMap Use the supplied function & arguments to update the attr value for a Node as in clojure.core/update
(attr-remove hid attr)
Inputs: [hid :- HID attr :- s/Keyword] Returns: tsk/KeyMap
Removes the specified attribute for an element
Inputs: [hid :- HID attr :- s/Keyword] Returns: tsk/KeyMap Removes the specified attribute for an element
(attr-set hid attr-name attr-val)
Inputs: [hid :- HID attr-name :- s/Keyword attr-val :- s/Any] Returns: Node
Resets the value of a leaf
Inputs: [hid :- HID attr-name :- s/Keyword attr-val :- s/Any] Returns: Node Resets the value of a leaf
(attr-update hid attr-name fn-update-attr & fn-update-attr-args)
Inputs: [hid :- HID attr-name :- s/Keyword fn-update-attr & fn-update-attr-args] Returns: tsk/KeyMap
Use the supplied function & arguments to update the attr value for a Node as in clojure.core/update
Inputs: [hid :- HID attr-name :- s/Keyword fn-update-attr & fn-update-attr-args] Returns: tsk/KeyMap Use the supplied function & arguments to update the attr value for a Node as in clojure.core/update
(attrs-merge hid attrs-in)
Inputs: [hid :- HID attrs-in :- tsk/KeyMap] Returns: tsk/KeyMap
Merge the supplied attrs map into the attrs of a Node
Inputs: [hid :- HID attrs-in :- tsk/KeyMap] Returns: tsk/KeyMap Merge the supplied attrs map into the attrs of a Node
(attrs-set hid attrs-new)
Inputs: [hid :- HID attrs-new :- tsk/KeyMap] Returns: tsk/KeyMap
Replace the attrs of a Node with the supplied attrs map
Inputs: [hid :- HID attrs-new :- tsk/KeyMap] Returns: tsk/KeyMap Replace the attrs of a Node with the supplied attrs map
(bush->enlive bush)
Inputs: [bush :- tsk/Vec] Returns: tsk/KeyMap
Converts a Bush to an Enlive-format data structure
Inputs: [bush :- tsk/Vec] Returns: tsk/KeyMap Converts a Bush to an Enlive-format data structure
(bush->hiccup arg)
Inputs: [arg :- tsk/Vec] Returns: tsk/Vec
Converts a Bush to a Hiccup-format data structure.
Inputs: [arg :- tsk/Vec] Returns: tsk/Vec Converts a Bush to a Hiccup-format data structure.
(bush->tree bush)
Inputs: [bush] Returns: tsk/KeyMap
Converts a bush to a tree
Inputs: [bush] Returns: tsk/KeyMap Converts a bush to a tree
(bush-node? arg)
Inputs: [arg] Returns: s/Bool
Inputs: [arg] Returns: s/Bool
(edn->tree data)
(edn->tree idx data)
Inputs: ([data :- s/Any] [idx :- (s/if int? s/Int (s/eq nil)) data :- s/Any])
Creates a tree from an EDN data structure
Inputs: ([data :- s/Any] [idx :- (s/if int? s/Int (s/eq nil)) data :- s/Any]) Creates a tree from an EDN data structure
(enlive->bush arg)
Inputs: [arg :- tsk/KeyMap] Returns: tsk/Vec
Converts an Enlive-format data structure to a Bush.
Inputs: [arg :- tsk/KeyMap] Returns: tsk/Vec Converts an Enlive-format data structure to a Bush.
(enlive->hiccup node)
Inputs: [node :- s/Any] Returns: s/Any
Inputs: [node :- s/Any] Returns: s/Any
(enlive->tree enlive-tree)
Inputs: [enlive-tree :- tsk/KeyMap] Returns: tsk/KeyMap
Convert an Enlive-format data structure to a tree. Is tolerant of missing or nil values for :attrs and :content keys.
Inputs: [enlive-tree :- tsk/KeyMap] Returns: tsk/KeyMap Convert an Enlive-format data structure to a tree. Is tolerant of missing or nil values for :attrs and :content keys.
(enlive-node-lax? arg)
Returns true for nominal Enlive nodes, else false
Returns true for nominal Enlive nodes, else false
(enlive-node-strict? arg)
Returns true for strictly valid Enlive nodes, else false
Returns true for strictly valid Enlive nodes, else false
(filter-enlive-subtrees enlive-tree-lazy subtree-path)
Lazily read an enlive tree, retaining only rooted subtrees as specified by subtree-path
Lazily read an enlive tree, retaining only rooted subtrees as specified by `subtree-path`
(find-hid root-spec tgt-path)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec] Returns: HID
Searches as with find-hids
, expecting & returning a single HID result.
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec] Returns: HID Searches as with `find-hids`, expecting & returning a single HID result.
(find-hids root-spec tgt-path)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec] Returns: [HID]
Searches for subtrees as for find-paths
, but retains only the HID of each subtree root (i.e. the last
element of each path vector)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec] Returns: [HID] Searches for subtrees as for `find-paths`, but retains only the HID of each subtree root (i.e. the last element of each path vector)
(find-hids-with root-spec tgt-path hid-pred)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec hid-pred :- s/Any]
Searches for subtrees as for find-hids
, discarding HIDs that fail the hid-pred
function.
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec hid-pred :- s/Any] Searches for subtrees as for `find-hids`, discarding HIDs that fail the `hid-pred` function.
(find-paths root-spec tgt-path)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec]
Returns: HID
Searches the forest for subtrees matching the tgt-path
rooted at root-spec
.
Returns a vector of hid-paths.
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec] Returns: [[HID]] Searches the forest for subtrees matching the `tgt-path` rooted at `root-spec`. Returns a vector of hid-paths.
(find-paths-with root-spec tgt-path path-pred)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec path-pred :- s/Any]
Searches for subtrees as for find-paths
, discarding paths that fail the path-pred
function.
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec path-pred :- s/Any] Searches for subtrees as for `find-paths`, discarding paths that fail the `path-pred` function.
(forest-hid? arg)
Returns true if the arg type is a legal HID value
Returns true if the arg type is a legal HID value
(format-path hids)
Inputs: [hids :- [HID]]
Format an HID path for printing (bush format)
Inputs: [hids :- [HID]] Format an HID path for printing (bush format)
(format-paths solns)
Inputs: [solns :- HID
]
Format a list of HID paths for printing (bush format)
Inputs: [solns :- [[HID]]] Format a list of HID paths for printing (bush format)
(has-descendant-with? root-spec tgt-path path-pred)
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec path-pred :- s/Any]
Returns true iff root-hid
has at least one matching subtree, after discarding paths failing the 'path-pred' function.
Inputs: [root-spec :- HidRootSpec tgt-path :- tsk/Vec path-pred :- s/Any] Returns true iff `root-hid` has at least one matching subtree, after discarding paths failing the 'path-pred' function.
(has-descendant? root-hid tgt-path)
Inputs: [root-hid :- HID tgt-path :- tsk/Vec]
Returns true iff root-hid
has at least one matching subtree
Inputs: [root-hid :- HID tgt-path :- tsk/Vec] Returns true iff `root-hid` has at least one matching subtree
(hiccup->bush arg)
Inputs: [arg :- tsk/Vec] Returns: tsk/Vec
Converts a Hiccup-format data structure to a Bush.
Inputs: [arg :- tsk/Vec] Returns: tsk/Vec Converts a Hiccup-format data structure to a Bush.
(hiccup->enlive node)
Inputs: [node :- s/Any] Returns: s/Any
Converts a data from Hiccup -> Enlive format
Inputs: [node :- s/Any] Returns: s/Any Converts a data from Hiccup -> Enlive format
(hiccup->tree arg)
Inputs: [arg :- tsk/Vec] Returns: tsk/KeyMap
Converts a Hiccup-format data structure to a Tree.
Inputs: [arg :- tsk/Vec] Returns: tsk/KeyMap Converts a Hiccup-format data structure to a Tree.
The Plumatic Schema type name for a pointer to a forest node (abbrev. for Hex ID)
The Plumatic Schema type name for a pointer to a forest node (abbrev. for Hex ID)
(hid->attr hid attr)
Inputs: [hid :- HID attr :- s/Keyword] Returns: s/Any
Given an HID, returns the value of a single attr
Inputs: [hid :- HID attr :- s/Keyword] Returns: s/Any Given an HID, returns the value of a single attr
(hid->attrs hid)
Inputs: [hid :- HID] Returns: tsk/KeyMap
Given an HID, returns all node attributes as a map
Inputs: [hid :- HID] Returns: tsk/KeyMap Given an HID, returns all node attributes as a map
(hid->bush hid)
Inputs: [hid :- HID] Returns: tsk/Vec
Returns the subtree rooted ad an HID (bush format)
Inputs: [hid :- HID] Returns: tsk/Vec Returns the subtree rooted ad an HID (bush format)
(hid->edn hid)
Inputs: [hid :- HID]
Returns the data rooted ad an HID (EDN format)
Inputs: [hid :- HID] Returns the data rooted ad an HID (EDN format)
(hid->hiccup hid)
Inputs: [hid :- HID] Returns: tsk/Vec
Returns the subtree rooted ad an HID (hiccup format)
Inputs: [hid :- HID] Returns: tsk/Vec Returns the subtree rooted ad an HID (hiccup format)
(hid->kids hid)
Inputs: [hid :- HID] Returns: [HID]
Returns the HIDs for a nodes children.
Inputs: [hid :- HID] Returns: [HID] Returns the HIDs for a nodes children.
(hid->leaf hid)
Inputs: [hid :- HID] Returns: Node
Returns the leaf node corresponding to an HID
Inputs: [hid :- HID] Returns: Node Returns the leaf node corresponding to an HID
(hid->node hid)
Inputs: [hid :- HID] Returns: Node
Returns the node corresponding to an HID
Inputs: [hid :- HID] Returns: Node Returns the node corresponding to an HID
(hid->tree hid)
Inputs: [hid :- HID] Returns: tsk/KeyMap
Inputs: [hid :- HID] Returns: tsk/KeyMap
(hid->value hid)
Inputs: [hid :- HID] Returns: s/Any
Given an HID, returns the :value attribute
Inputs: [hid :- HID] Returns: s/Any Given an HID, returns the :value attribute
The Plumatic Schema type name for the values accepted as starting points (roots) for a subtree path search.
The Plumatic Schema type name for the values accepted as starting points (roots) for a subtree path search.
(html->enlive html-str)
Inputs: [html-str :- s/Str] Returns: tsk/KeyMap
Inputs: [html-str :- s/Str] Returns: tsk/KeyMap
Plumatic Schema type name for interceptor type used by walk-tree
.
Plumatic Schema type name for interceptor type used by `walk-tree`.
(kids-append hid kids-new)
Inputs: [hid :- HID kids-new :- [HID]] Returns: tsk/KeyMap
Appends a list of kids a Node
Inputs: [hid :- HID kids-new :- [HID]] Returns: tsk/KeyMap Appends a list of kids a Node
(kids-prepend hid kids-in)
Inputs: [hid :- HID kids-in :- [HID]] Returns: tsk/KeyMap
Appends a list of kids a Node
Inputs: [hid :- HID kids-in :- [HID]] Returns: tsk/KeyMap Appends a list of kids a Node
(kids-set hid kids-new)
Inputs: [hid :- HID kids-new :- [HID]] Returns: Node
Resets the kids of a Node to the supplied list
Inputs: [hid :- HID kids-new :- [HID]] Returns: Node Resets the kids of a Node to the supplied list
(kids-update hid fn-update-kids & fn-update-kids-args)
Inputs: [hid :- HID fn-update-kids & fn-update-kids-args] Returns: tsk/KeyMap
Updates the kids for a Node using a function, as in clojure.core/update
Inputs: [hid :- HID fn-update-kids & fn-update-kids-args] Returns: tsk/KeyMap Updates the kids for a Node using a function, as in clojure.core/update
(leaf-hid? hid)
Inputs: [hid :- HID]
Returns true iff an HID is a leaf
Inputs: [hid :- HID] Returns true iff an HID is a leaf
(leaf-path? path)
Inputs: [path :- [HID]] Returns: s/Bool
Returns true if an HID path ends in a leaf
Inputs: [path :- [HID]] Returns: s/Bool Returns true if an HID path ends in a leaf
(new-forest)
Returns a new, empty forest.
Returns a new, empty forest.
(new-hid)
Inputs: [] Returns: HID
Returns a new HexID
Inputs: [] Returns: HID Returns a new HexID
The Plumatic Schema description of a legal node in a forest of trees
The Plumatic Schema description of a legal node in a forest of trees
(raw-leaf-treenode? node)
Inputs: [node :- tsk/KeyMap] Returns: s/Bool
Returns true if a TreeNode is a leaf with {:tag ::raw}.
Inputs: [node :- tsk/KeyMap] Returns: s/Bool Returns true if a TreeNode is a leaf with {:tag ::raw}.
(raw-whitespace-leaf-treenode? node)
Inputs: [node :- tsk/KeyMap] Returns: s/Bool
Returns true if a TreeNode is a leaf with {:tag ::raw} and whitespace value.
Inputs: [node :- tsk/KeyMap] Returns: s/Bool Returns true if a TreeNode is a leaf with {:tag ::raw} and whitespace value.
(remove-kids hid kids-leaving)
(remove-kids hid kids-leaving missing-kids-ok?)
Inputs: ([hid :- HID kids-leaving :- (s/if sequential? [HID] #{HID})] [hid :- HID kids-leaving :- (s/if sequential? [HID] #{HID}) missing-kids-ok? :- s/Bool]) Returns: tsk/KeyMap
Removes a set of children from a Node (including any duplcates).
Inputs: ([hid :- HID kids-leaving :- (s/if sequential? [HID] #{HID})] [hid :- HID kids-leaving :- (s/if sequential? [HID] #{HID}) missing-kids-ok? :- s/Bool]) Returns: tsk/KeyMap Removes a set of children from a Node (including any duplcates).
(remove-path-subtree path)
Inputs: [path :- [HID]]
Given an HID path, removes from the forest all nodes in the subtree rooted at the end of that path.
Inputs: [path :- [HID]] Given an HID path, removes from the forest all nodes in the subtree rooted at the end of that path.
(remove-whitespace-leaves)
(remove-whitespace-leaves root-hid)
Inputs: ([] [root-hid :- HID])
Removes leaves from all trees in the forest that are whitespace-only strings (including zero-length strings).
Inputs: ([] [root-hid :- HID]) Removes leaves from all trees in the forest that are whitespace-only strings (including zero-length strings).
(root-hids)
Inputs: [] Returns: #{HID}
Return a vector of all root HID's
Inputs: [] Returns: #{HID} Return a vector of all root HID's
(set-node hid node)
(set-node hid attrs kids)
Inputs: ([hid :- HID node :- Node] [hid :- HID attrs :- tsk/KeyMap kids :- [HID]])
Unconditionally sets the value of a Node in the forest
Inputs: ([hid :- HID node :- Node] [hid :- HID attrs :- tsk/KeyMap kids :- [HID]]) Unconditionally sets the value of a Node in the forest
(tree->bush tree-node)
Inputs: [tree-node :- tsk/Map] Returns: tsk/Vec
Inputs: [tree-node :- tsk/Map] Returns: tsk/Vec
(tree->edn node)
Converts a tree to an EDN data structure
Converts a tree to an EDN data structure
(tree->enlive tree-node)
Inputs: [tree-node :- tsk/KeyMap] Returns: (s/if map? tsk/KeyMap tsk/Vec)
Inputs: [tree-node :- tsk/KeyMap] Returns: (s/if map? tsk/KeyMap tsk/Vec)
(tree->hiccup arg)
Inputs: [arg :- tsk/KeyMap] Returns: tsk/Vec
Converts a Tree to a Hiccup-format data structure.
Inputs: [arg :- tsk/KeyMap] Returns: tsk/Vec Converts a Tree to a Hiccup-format data structure.
(tree-node? node)
Inputs: [node :- tsk/KeyMap] Returns: s/Bool
Returns true if the arg is a legal tree node
Inputs: [node :- tsk/KeyMap] Returns: s/Bool Returns true if the arg is a legal tree node
(valid-forest-leaf? node)
Inputs: [node :- tsk/KeyMap] Returns: s/Bool
Returns true if the arg is a forest leaf node (empty :tupelo.forest/khids).
Inputs: [node :- tsk/KeyMap] Returns: s/Bool Returns true if the arg is a forest leaf node (empty :tupelo.forest/khids).
(valid-forest-node? arg)
Inputs: [arg :- tsk/KeyMap] Returns: s/Bool
Returns true if the arg is a legal forest node
Inputs: [arg :- tsk/KeyMap] Returns: s/Bool Returns true if the arg is a legal forest node
(validate-attrs attrs)
Inputs: [attrs :- tsk/KeyMap] Returns: tsk/KeyMap
Inputs: [attrs :- tsk/KeyMap] Returns: tsk/KeyMap
(validate-hid hid)
Inputs: [hid :- HID]
Returns HID arg iff it exists in the forest, else throws.
Inputs: [hid :- HID] Returns HID arg iff it exists in the forest, else throws.
(walk-tree root-hid intc-map)
Inputs: [root-hid :- HID intc-map :- tsk/KeyMap]
Recursively walks a subtree of the forest, applying the supplied :enter
and ':leave` functions
to each node. Usage:
(walk-tree <subtree-root-hid> intc-map)
where intc-map
is an interceptor map like:
{ :enter <pre-fn> ; defaults to `identity`
:leave <post-fn> } ; defaults to `identity`
Here, pre-fn
and post-fn
look like:
(fn [path] ...)
where path
is a vector of HIDs beginning at the root of the sub-tree being walked.
Inputs: [root-hid :- HID intc-map :- tsk/KeyMap] Recursively walks a subtree of the forest, applying the supplied `:enter` and ':leave` functions to each node. Usage: (walk-tree <subtree-root-hid> intc-map) where `intc-map` is an interceptor map like: { :enter <pre-fn> ; defaults to `identity` :leave <post-fn> } ; defaults to `identity` Here, `pre-fn` and `post-fn` look like: (fn [path] ...) where `path` is a vector of HIDs beginning at the root of the sub-tree being walked.
(whitespace-leaf-hid? hid)
Inputs: [hid :- HID] Returns: s/Bool
Returns true iff an HID is a leaf node (no children) and has a :value
attribute containing only whitespace.
Inputs: [hid :- HID] Returns: s/Bool Returns true iff an HID is a leaf node (no children) and has a `:value` attribute containing only whitespace.
(xml->enlive xml-str)
Inputs: [xml-str :- s/Str] Returns: tsk/KeyMap
Inputs: [xml-str :- s/Str] Returns: tsk/KeyMap
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close