Module:Sandbox/Jts1882/CladeSVG explained

--NOTE: this module contains functions for generating the table structure of the clade tree in two ways:-- (1) the original method was generated by a number of function calls from the template using -- function p.openTable(frame) - creates wikitext code to open the HTML table-- function p.node(frame) - deals with the first node (|1,|label1) and creates wikitext for top row of the table-- function p.nodeN(frame) - deals with a sister nodes (|2-17), adding a row each time it is called-- function p.closeTable - closes the HTML table-- (2) the revised method is called by the template with one instruction; it has three functions:-- p.main(frame) - opens and closes table, loops through the children of node, main is invoked once and controls the rest, calling ...-- p.addTaxon(childNumber, nodeLeaf) - the nuts and bolts; code dealing with each child node-- p.addLabel(childNumber) - adds the label text

local p =

--

main function (for Method 2)

-- main function, which will --main|style= }}Template: User:Jts1882/sandbox/templates/CladeN

function p.main(frame)

local cladeString = "" local maxChildren = 20 -- currently 17 in the clade/cladex templates local childNumber = 0 local lastNode = 0 local nodeCount = 0 -- total leafs plus new clade branches local leafCount = 0 -- just the terminal leaves local cladeCount = 0 -- new clade calls (each with a table) local childCount = 0 -- number of leaves in the clade (can use to set bottom of bracket in addTaxon local totalCount = 0 ----N= if nodeLeaf ~= "" then childCount = childCount + 1 -- this counts child elements in this clade for i in string.gmatch(nodeLeaf, "|| rowspan") do -- count number of rows started (transclusion) nodeCount = nodeCount + 1 end for i in string.gmatch(nodeLeaf, "