<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ar">
	<id>https://www.arabsciencepedia.org/w/index.php?action=history&amp;feed=atom&amp;title=%D9%88%D8%AD%D8%AF%D8%A9%3AClade</id>
	<title>وحدة:Clade - تاريخ المراجعة</title>
	<link rel="self" type="application/atom+xml" href="https://www.arabsciencepedia.org/w/index.php?action=history&amp;feed=atom&amp;title=%D9%88%D8%AD%D8%AF%D8%A9%3AClade"/>
	<link rel="alternate" type="text/html" href="https://www.arabsciencepedia.org/w/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:Clade&amp;action=history"/>
	<updated>2026-04-11T02:56:02Z</updated>
	<subtitle>تاريخ التعديل لهذه الصفحة في الويكي</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.arabsciencepedia.org/w/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:Clade&amp;diff=41030&amp;oldid=prev</id>
		<title>أسيل سيوف: أنشأ الصفحة ب&#039;--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...&#039;</title>
		<link rel="alternate" type="text/html" href="https://www.arabsciencepedia.org/w/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:Clade&amp;diff=41030&amp;oldid=prev"/>
		<updated>2018-04-11T08:12:26Z</updated>

		<summary type="html">&lt;p&gt;أنشأ الصفحة ب&amp;#039;--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...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحة جديدة&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--NOTE: this module contains functions for generating the table structure of the clade tree in two ways:&lt;br /&gt;
-- (1) the original method was generated by a number of function calls from the template using {{invoke}}&lt;br /&gt;
--        function p.openTable(frame) - creates wikitext code to open the HTML table&lt;br /&gt;
--        function p.node(frame)  - deals with the first node (|1,|label1) and creates wikitext for top row of the table&lt;br /&gt;
--        function p.nodeN(frame) - deals with a sister nodes (|2-17), adding a row each time it is called&lt;br /&gt;
--        function p.closeTable() - closes the HTML table&lt;br /&gt;
-- (2) the revised method is called by the template with one {{invoke}} instruction; it has three functions:&lt;br /&gt;
--        p.main(frame) - opens and closes table, loops through the children of node, main is invoked once and controls the rest, calling ...&lt;br /&gt;
--        p.addTaxon(childNumber, nodeLeaf) - the nuts and bolts; code dealing with each child node&lt;br /&gt;
--        p.addLabel(childNumber) - adds the label text&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--============================== main function (for Method 2) ===========================&lt;br /&gt;
-- main function, which will &lt;br /&gt;
--[[Main function to generate the table structure of the tree&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:Module:Sandbox/Jts1882/CladeN|main|style={{{STYLE}}} }}&lt;br /&gt;
Template: User:Jts1882/sandbox/templates/CladeN&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
&lt;br /&gt;
	local cladeString = &amp;quot;&amp;quot;	&lt;br /&gt;
	local maxChildren = 20 -- currently 17 in the clade/cladex templates&lt;br /&gt;
	local childNumber = 0&lt;br /&gt;
	local lastNode = 0&lt;br /&gt;
	local nodeCount = 0 -- total leafs plus new clade branches&lt;br /&gt;
	local leafCount = 0 -- just the terminal leaves&lt;br /&gt;
	local cladeCount = 0 -- new clade calls (each with a table)&lt;br /&gt;
	local childCount = 0 -- number of leaves in the clade (can use to set bottom of bracket in addTaxon()&lt;br /&gt;
	local totalCount = 0&lt;br /&gt;
	&lt;br /&gt;
	--[[Note: this preprocessing loop gets information about the whole structure (number of nodes, leaves etc)&lt;br /&gt;
		it makes a redundant calls to the templates through transclusion, but doen&amp;#039;t affect the template depths; &lt;br /&gt;
		it would probably be better to store the transcluded nodes in a table (a job for later)&lt;br /&gt;
	]]&lt;br /&gt;
--[[ disable proprocessing loop&lt;br /&gt;
	while 	childNumber &amp;lt; maxChildren do -- preprocessing loop&lt;br /&gt;
		childNumber = childNumber + 1 -- so we start with 1&lt;br /&gt;
		local nodeLeaf,data = mw.getCurrentFrame():getParent().args[tostring(childNumber)] or &amp;quot;&amp;quot;  -- get data from |N=&lt;br /&gt;
  &lt;br /&gt;
		if nodeLeaf ~= &amp;quot;&amp;quot; then&lt;br /&gt;
			childCount = childCount + 1  -- this counts child elements in this clade&lt;br /&gt;
		    &lt;br /&gt;
		    for i in string.gmatch(nodeLeaf, &amp;quot;|| rowspan&amp;quot;) do -- count number of rows started (transclusion)&lt;br /&gt;
   				nodeCount = nodeCount + 1&lt;br /&gt;
     		end&lt;br /&gt;
		    for i in string.gmatch(nodeLeaf, &amp;quot;{| cellspacing&amp;quot;) do -- count number of tables started (transclusion)&lt;br /&gt;
   				cladeCount = cladeCount + 1&lt;br /&gt;
     		end&lt;br /&gt;
           -- _, cladeCount = string.gsub(nodeLeaf, &amp;quot;{| cellspacing&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
            --_, nodeCount = string.gsub(nodeLeaf, &amp;quot;|| rowspan&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
            &lt;br /&gt;
            --totalCount = totalCount + nodeCount&lt;br /&gt;
			lastNode = childNumber&lt;br /&gt;
		--	if data ~= nil then totalCount = totalCount + tonumber(data) else totalCount = totalCount + 1 end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		--cladeString = cladeString .. &amp;#039;\n&amp;#039; .. &amp;#039; count= &amp;#039; .. totalCount&lt;br /&gt;
&lt;br /&gt;
	end&lt;br /&gt;
]]	&lt;br /&gt;
    nodeCount = nodeCount + childCount --(elements passed down by transduction plus current child elements)&lt;br /&gt;
    cladeCount = cladeCount + 1        --(elements passed down by transduction plus current clade)&lt;br /&gt;
    leafCount = nodeCount-cladeCount+1&lt;br /&gt;
    totalCount =leafCount-- cladeCount --nodeCount &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    local testing = false&lt;br /&gt;
    --testing = true                  -- COMMENT OUT TO GET MODULE RUNNING WITHOUT THE TEST&lt;br /&gt;
    if testing then &lt;br /&gt;
    	local dataString = p.test(1)&lt;br /&gt;
    	cladeString = cladeString .. dataString&lt;br /&gt;
    	return cladeString &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
	local tableStyle = frame.args.style or &amp;quot;&amp;quot;&lt;br /&gt;
	if tableStyle == &amp;#039;{{{style}}}&amp;#039; then tableStyle = &amp;quot;&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	local captionName =mw.getCurrentFrame():getParent().args[&amp;#039;caption&amp;#039;] or &amp;quot;&amp;quot;&lt;br /&gt;
	local captionStyle = mw.getCurrentFrame():getParent().args[&amp;#039;captionstyle&amp;#039;] or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- open table	&lt;br /&gt;
	--cladeString = cladeString .. &amp;#039;{| style=&amp;quot;border-collapse:collapse;border-spacing:0;margin:0;&amp;#039; .. tableStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
    cladeString = cladeString .. &amp;#039;{| style=&amp;quot;border-spacing:0;margin:0;&amp;#039; .. tableStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    -- add caption&lt;br /&gt;
	if captionName ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		cladeString = cladeString .. &amp;#039;\n|+ style=&amp;quot;&amp;#039; .. captionStyle .. &amp;#039;&amp;quot;|&amp;#039; .. captionName&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- global nodeParameters (unnumber, i.e. color, thickness, state) apply to whole node bracket, &lt;br /&gt;
	--    but can be overrriden by branchParameters (numbered, e.g. color2, thickness2, state2)&lt;br /&gt;
	nodeColor = mw.getCurrentFrame():getParent().args[&amp;#039;color&amp;#039;] or &amp;quot;&amp;quot;&lt;br /&gt;
	nodeThickness = tonumber(mw.getCurrentFrame():getParent().args[&amp;#039;thickness&amp;#039;]) or 1&lt;br /&gt;
	nodeState = mw.getCurrentFrame():getParent().args[&amp;#039;state&amp;#039;] or &amp;quot;solid&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	local moreNeeded = true&lt;br /&gt;
	childNumber = 0&lt;br /&gt;
	lastNode = 0&lt;br /&gt;
&lt;br /&gt;
	--[[get child elements (add more rows for each child of node; each child is two rows)&lt;br /&gt;
	    the function addTaxon is called to add the rows for each child element;&lt;br /&gt;
	    each child add two rows: the first cell of each row contains the label or sublabel (below the line label), respectively;&lt;br /&gt;
	    the second cell spans both rows and contains the leaf name or a new clade structure&lt;br /&gt;
	    a third cell on the top row is sometimes added to contain a group  to the right&lt;br /&gt;
	]]&lt;br /&gt;
	&lt;br /&gt;
	while 	childNumber &amp;lt; maxChildren do -- disable moreNeeded &lt;br /&gt;
	                                        -- while childNumber &amp;lt; 17 and moreNeeded == true do&lt;br /&gt;
		childNumber = childNumber + 1 -- so we start with 1&lt;br /&gt;
		local nodeLeaf = mw.getCurrentFrame():getParent().args[tostring(childNumber)] or &amp;quot;&amp;quot;  -- get data from |N=&lt;br /&gt;
		local nodeLabel = mw.getCurrentFrame():getParent().args[&amp;#039;label&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;  -- get data from |labelN=&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		local newickString = mw.getCurrentFrame():getParent().args[&amp;#039;newick&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;  -- get data from |labelN=&lt;br /&gt;
		if newickString ~= &amp;quot;&amp;quot; then -- if using a newick string instead of a clade structure&lt;br /&gt;
			if nodeLabel == &amp;quot;&amp;quot; then -- use labelN by default, otherwise use root name from Newick string&lt;br /&gt;
				nodeLabel = p.getNewickOuterterm(newickString) -- need to use terminal part of newick string for label&lt;br /&gt;
			end&lt;br /&gt;
			cladeString = cladeString .. &amp;#039;\n&amp;#039; .. p.addTaxon(childNumber, p.newick(0, newickString), nodeLabel)&lt;br /&gt;
			lastNode = childNumber&lt;br /&gt;
		elseif nodeLeaf ~= &amp;quot;&amp;quot; then -- if the node contains a leaf name or clade structue&lt;br /&gt;
			cladeString = cladeString .. &amp;#039;\n&amp;#039; .. p.addTaxon(childNumber, nodeLeaf, nodeLabel)&lt;br /&gt;
			lastNode = childNumber&lt;br /&gt;
		else&lt;br /&gt;
			moreNeeded = false -- no |N= so don&amp;#039;t look for more&lt;br /&gt;
			-- Note: this changes the behaviour. If there is no |2, it won&amp;#039;t look for |3 or |4, which clade does (is this desirable?)&lt;br /&gt;
			-- this has been disabled to allow consistent behaviour with clade/cladex (it will check to the limit set)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[finish last row by adding cell with no left border &lt;br /&gt;
        note: the row was started in addTaxon(), but the cell not added as left border yet to be determined; &lt;br /&gt;
             here the cell is added to the last child node with no left border as it is below the bracket&lt;br /&gt;
             this will be moved to addTaxon() when the number of the last child is known &lt;br /&gt;
   	]]&lt;br /&gt;
   local subLabel = mw.getCurrentFrame():getParent().args[&amp;#039;sublabel&amp;#039;..tostring(lastNode)] or &amp;quot;&amp;quot;  -- request in addLabel&lt;br /&gt;
	&lt;br /&gt;
	--use subLabel for annotating the clade structues to use structure information (DEBUGGIING ONLY)&lt;br /&gt;
	--subLabel= &amp;#039;(N=&amp;#039; .. totalCount .. &amp;#039;)&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	--cladeString = cladeString ..  &amp;#039;\n&amp;#039; .. &amp;#039;| style=&amp;quot;border: 0; padding: 0; vertical-align: top;&amp;quot; | &amp;lt;br/&amp;gt; &amp;#039;&lt;br /&gt;
	cladeString = cladeString ..  &amp;#039;\n&amp;#039; .. &amp;#039;|style=&amp;quot;border:0;vertical-align:top;text-align:center;&amp;quot;|&amp;#039; .. p.addLabel(lastNode-1,subLabel) &lt;br /&gt;
&lt;br /&gt;
    --[[ footer description (add addition row spanning two columns at bottom of table)&lt;br /&gt;
    	this is designed to provide the description below the whole clade structure (mimicking cladogram);&lt;br /&gt;
    	however, it can also be used to add labels and spacing to the whole clade structre&lt;br /&gt;
	]]&lt;br /&gt;
	local footerText  = mw.getCurrentFrame():getParent().args[&amp;#039;footer&amp;#039;] or &amp;quot;&amp;quot;&lt;br /&gt;
	local footerStyle = mw.getCurrentFrame():getParent().args[&amp;#039;footerstyle&amp;#039;] or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	if footerText ~= &amp;quot;&amp;quot; then&lt;br /&gt;
	   --cladeString = cladeString ..  &amp;#039;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Test &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;#039; &lt;br /&gt;
	   cladeString = cladeString ..  &amp;#039;\n|-style=&amp;quot;&amp;#039; .. footerStyle .. &amp;#039;&amp;quot;\n|colspan=&amp;quot;2&amp;quot;|&amp;lt;p&amp;gt;&amp;#039; .. footerText .. &amp;#039;&amp;lt;/p&amp;gt;||&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- close table (wikitext to close table)&lt;br /&gt;
	cladeString = cladeString ..  &amp;#039;\n|}&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	return cladeString&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ function to add child elements&lt;br /&gt;
     adds wikitext for two rows of the table for each child node, &lt;br /&gt;
     	the first cell in each is used for the label and sublabel; the bottom border forms the horizonal branch of the bracket&lt;br /&gt;
     	the second cell is used for the leafname or a transcluded clade structure and spans both rows&lt;br /&gt;
     note that the first and last child nodes need to be handled differently from the middle elements&lt;br /&gt;
	     the middle elements (|2, |3 ...) use a left border to create the vertical line of the bracket&lt;br /&gt;
	     the first child element doesn&amp;#039;t use a left border for the first cell in the top row (as it is above the bracket)&lt;br /&gt;
	     the last child doesn&amp;#039;t use a left border for the first cell in the second row (as it is above the bracket)&lt;br /&gt;
	     a complication is that the number of the last child node is not known;&lt;br /&gt;
	     	as a result the cells will be added to the row on the next iteration or after the main loop finishes&lt;br /&gt;
]]&lt;br /&gt;
function p.addTaxon(childNumber, nodeLeaf, nodeLabel)&lt;br /&gt;
&lt;br /&gt;
	-- get leaf and labels&lt;br /&gt;
	--local nodeLeaf  = mw.getCurrentFrame():getParent().args[tostring(childNumber)] or &amp;quot;&amp;quot;    -- used passed variable to avoid redundancy&lt;br /&gt;
	--local nodeLabel = mw.getCurrentFrame():getParent().args[&amp;#039;label&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;  -- request in addLabel&lt;br /&gt;
	&lt;br /&gt;
	-- get formating parameters for branch (default to global nodeParameters)&lt;br /&gt;
	--    - the branch parameters have a number, e.g. |colorN, |thicknessN, |stateN&lt;br /&gt;
	--    - the node parameters have no number, e.g. |color, |thickness, |state&lt;br /&gt;
	local branchThickness = tonumber(mw.getCurrentFrame():getParent().args[&amp;#039;thickness&amp;#039;..tostring(childNumber)]) or nodeThickness&lt;br /&gt;
	local branchColor = mw.getCurrentFrame():getParent().args[&amp;#039;color&amp;#039;..tostring(childNumber)] or nodeColor&lt;br /&gt;
	local branchStyle = mw.getCurrentFrame():getParent().args[&amp;#039;style&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;&lt;br /&gt;
	local branchState = mw.getCurrentFrame():getParent().args[&amp;#039;state&amp;#039;..tostring(childNumber)] or nodeState -- &amp;quot;solid&amp;quot; &lt;br /&gt;
	if branchState == &amp;#039;double&amp;#039; then if branchThickness &amp;lt; 2 then branchThickness = 3 end end  -- need thick line for double&lt;br /&gt;
&lt;br /&gt;
    -- the left border takes node parameters, the bottom border takes branch parameters&lt;br /&gt;
   local bottomBorder =  tostring(branchThickness) ..&amp;#039;px &amp;#039; .. branchState  .. (branchColor~=&amp;quot;&amp;quot; and &amp;#039; &amp;#039; .. branchColor or &amp;#039;&amp;#039;)&lt;br /&gt;
   local leftBorder   =  tostring(nodeThickness)   ..&amp;#039;px &amp;#039; .. nodeState  .. (nodeColor~=&amp;quot;&amp;quot; and &amp;#039; &amp;#039; .. nodeColor or &amp;#039;&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	-- variables for right hand bar or bracket&lt;br /&gt;
	--local barColor  = &amp;quot;&amp;quot; &lt;br /&gt;
	local barRight  = mw.getCurrentFrame():getParent().args[&amp;#039;bar&amp;#039;..tostring(childNumber)] or &amp;quot;0&amp;quot;&lt;br /&gt;
	local barBottom = mw.getCurrentFrame():getParent().args[&amp;#039;barend&amp;#039;..tostring(childNumber)] or &amp;quot;0&amp;quot;&lt;br /&gt;
	local barTop    = mw.getCurrentFrame():getParent().args[&amp;#039;barbegin&amp;#039;..tostring(childNumber)] or &amp;quot;0&amp;quot;&lt;br /&gt;
	local barLabel  = mw.getCurrentFrame():getParent().args[&amp;#039;barlabel&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;&lt;br /&gt;
	local groupLabel  = mw.getCurrentFrame():getParent().args[&amp;#039;grouplabel&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;&lt;br /&gt;
	local groupLabelStyle  = mw.getCurrentFrame():getParent().args[&amp;#039;labelstyle&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	--replace colours with format string; need right bar for all three options&lt;br /&gt;
	if barRight  ~= &amp;quot;0&amp;quot; then barRight  = &amp;quot;2px solid &amp;quot; .. barRight  end &lt;br /&gt;
	if barTop    ~= &amp;quot;0&amp;quot; then barRight  = &amp;quot;2px solid &amp;quot; .. barTop    end&lt;br /&gt;
	if barBottom ~= &amp;quot;0&amp;quot; then barRight  = &amp;quot;2px solid &amp;quot; .. barBottom end &lt;br /&gt;
	if barTop    ~= &amp;quot;0&amp;quot; then barTop    = &amp;quot;2px solid &amp;quot; .. barTop    end&lt;br /&gt;
	if barBottom ~= &amp;quot;0&amp;quot; then barBottom = &amp;quot;2px solid &amp;quot; .. barBottom end &lt;br /&gt;
	&lt;br /&gt;
	-- now construct wikitext &lt;br /&gt;
	local styleString = &amp;#039;&amp;#039;&lt;br /&gt;
	local cladeString = &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	--[[ first add cell to the spacing row (for 2-17); it completes the previous row &lt;br /&gt;
	    why is this here rather than at the end of each row? &lt;br /&gt;
		To allow left border (here while extending bracket) or not (end of bracket)&lt;br /&gt;
	]]&lt;br /&gt;
	if childNumber  ~= 1 then&lt;br /&gt;
  		local subLabel = mw.getCurrentFrame():getParent().args[&amp;#039;sublabel&amp;#039;..tostring(childNumber-1)] or &amp;quot;&amp;quot;  -- request in addLabel&lt;br /&gt;
&lt;br /&gt;
		--styleString = &amp;#039; style=&amp;quot;border-left:&amp;#039; .. leftBorder ..&amp;#039;;border-top:0;border-right:0;border-bottom:0;vertical-align:top;text-align:center;&amp;quot;&amp;#039;&lt;br /&gt;
		styleString = &amp;#039; style=&amp;quot;border:0;border-left:&amp;#039; .. leftBorder ..&amp;#039;;vertical-align:top;text-align:center;&amp;quot;&amp;#039;&lt;br /&gt;
		--cladeString = cladeString .. &amp;#039;| &amp;#039; .. styleString .. &amp;#039; | &amp;lt;br/&amp;gt; &amp;#039; -- for sublabel &amp;#039; | y&amp;lt;br/&amp;gt; &amp;#039;&lt;br /&gt;
		cladeString = cladeString .. &amp;#039;|&amp;#039; .. styleString .. &amp;#039;|&amp;#039; ..  p.addLabel(childNumber-1,subLabel)&lt;br /&gt;
	end &lt;br /&gt;
   &lt;br /&gt;
   -- new row&lt;br /&gt;
   cladeString = cladeString .. &amp;#039;\n|-&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	-- now add cell with label&lt;br /&gt;
	styleString = &amp;#039;&amp;#039;&lt;br /&gt;
	if childNumber == 1 then&lt;br /&gt;
		-- the width gives minimum spacing when all labels are empty (was 1.5em)&lt;br /&gt;
		--styleString = &amp;#039; style=&amp;quot;width:1em;border-bottom:&amp;#039; .. bottomBorder .. &amp;#039;;border-left:0;border-top:0;border-right:0;padding:0 0.2em;vertical-align:bottom;text-align:center;&amp;#039; .. branchStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
		styleString = &amp;#039; style=&amp;quot;width:1em;border:0;padding:0 0.2em;border-bottom:&amp;#039; .. bottomBorder .. &amp;#039;;vertical-align:bottom;text-align:center;&amp;#039; .. branchStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
 	else -- for 2-17&lt;br /&gt;
    	styleString = &amp;#039; style=&amp;quot;border:0;padding:0 0.2em;border-left:&amp;#039; .. leftBorder .. &amp;#039;;border-bottom:&amp;#039; .. bottomBorder .. &amp;#039;;vertical-align:bottom;text-align:center;&amp;#039; .. branchStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
    cladeString = cladeString .. &amp;#039;\n|&amp;#039; .. styleString  .. &amp;#039;|&amp;#039; .. p.addLabel(childNumber,nodeLabel) -- p.addLabel(nodeLabel)&lt;br /&gt;
&lt;br /&gt;
	-- add cell with leaf (which may be a table with transluded content)&lt;br /&gt;
    --cladeString = cladeString .. &amp;#039;|| rowspan=2 style=&amp;quot;border: 0; padding: 0; border-right: &amp;#039; .. barRight .. &amp;#039;;border-bottom: &amp;#039; .. barBottom .. &amp;#039;;border-top: &amp;#039; .. barTop .. &amp;#039;;&amp;#039; .. branchStyle .. &amp;#039; &amp;quot; | &amp;#039;&lt;br /&gt;
	styleString = &amp;#039;&amp;#039;  &lt;br /&gt;
    if barRight  ~= &amp;quot;0&amp;quot;  then &lt;br /&gt;
    	styleString = &amp;#039;style=&amp;quot;border:0;padding:0;border-right:&amp;#039; .. barRight .. &amp;#039;;border-bottom:&amp;#039; .. barBottom .. &amp;#039;;border-top:&amp;#039; .. barTop .. &amp;#039;;&amp;#039; .. branchStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
    else&lt;br /&gt;
    	styleString = &amp;#039;style=&amp;quot;border:0;padding:0;&amp;#039; .. branchStyle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    cladeString = cladeString .. &amp;#039;||rowspan=2 &amp;#039; .. styleString .. &amp;#039;|&amp;#039;&lt;br /&gt;
    -- note: this is where leading spaces can be added to labels and leaves. This was commented out in the clade template. Most trees seem to have added spaces, to would need to check for existing spaces; however, cladex uses it&lt;br /&gt;
    -- or could use padding:0 0.2em in cell style as for labels&lt;br /&gt;
    cladeString = cladeString .. &amp;#039;\n&amp;#039; .. nodeLeaf&lt;br /&gt;
    &lt;br /&gt;
    -- stuff for right-hand bar-bracket&lt;br /&gt;
	if barRight  ~= &amp;quot;0&amp;quot;  then &lt;br /&gt;
    	cladeString = cladeString .. &amp;#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;#039;            -- add spaces between leaf text and bar&lt;br /&gt;
		if barLabel ~= &amp;quot;&amp;quot; then &lt;br /&gt;
			-- cladeString = cladeString ..  &amp;#039;\n| &amp;#039; .. barLabel end  -- experiment for labeling the bar&lt;br /&gt;
			cladeString = cladeString .. &amp;#039;&amp;lt;td style=&amp;quot;vertical-align:middle;&amp;quot;&amp;gt;&amp;#039; .. barLabel ..&amp;#039;&amp;lt;/td&amp;gt;&amp;#039; &lt;br /&gt;
		end&lt;br /&gt;
	end &lt;br /&gt;
	if groupLabel ~= &amp;quot;&amp;quot;then &lt;br /&gt;
    	--cladeString = cladeString .. &amp;#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;#039;            -- add spaces between leaf text and bar (could use padding)&lt;br /&gt;
		cladeString = cladeString .. &amp;#039;&amp;lt;td style=&amp;quot;&amp;#039;.. groupLabelStyle .. &amp;#039;&amp;quot;&amp;gt;&amp;#039; .. groupLabel ..&amp;#039;&amp;lt;/td&amp;gt;&amp;#039; &lt;br /&gt;
	end 	&lt;br /&gt;
&lt;br /&gt;
	-- add row	(needed because of rowspan=2); &lt;br /&gt;
    -- note: the cell will be added on the next iteration of addTaxon (with left border) or after the main loop (without left border)&lt;br /&gt;
    local branchStyleString = &amp;#039;style=&amp;quot;&amp;#039; .. branchStyle .. &amp;#039;&amp;quot;  &amp;#039; &lt;br /&gt;
    if branchStyle == &amp;#039;&amp;#039; then branchStyleString = &amp;#039;&amp;#039;  end -- avoid empty style elements&lt;br /&gt;
	cladeString = cladeString .. &amp;#039;\n|-&amp;#039; .. branchStyleString&lt;br /&gt;
	&lt;br /&gt;
	-- TODO code to put whole row here instead of completing on next call to addTaxon() or after main loop&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	return cladeString&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ adds text for label or sublabel to a cell&lt;br /&gt;
]]&lt;br /&gt;
function p.addLabel(childNumber,nodeLabel)&lt;br /&gt;
	&lt;br /&gt;
	--local nodeLabel = mw.getCurrentFrame():getParent().args[&amp;#039;label&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	local firstChars = string.sub(nodeLabel, 1,2) -- get first two characters; will be {{ if no parameter (for Old method?)&lt;br /&gt;
	--if nodeLabel ~= &amp;quot;{{{label1}}}&amp;quot; then&lt;br /&gt;
	if firstChars == &amp;quot;{{{&amp;quot; or nodeLabel == &amp;quot;&amp;quot; then&lt;br /&gt;
		return &amp;#039;&amp;lt;br/&amp;gt;&amp;#039; --&amp;#039;&amp;amp;nbsp;&amp;lt;br/&amp;gt;&amp;#039;  -- remove space to reduce post-expand include size (the width=1.5em handles spacing)&lt;br /&gt;
	else&lt;br /&gt;
		-- spaces can cause  wrapping and can break tree structure, hence use span with nowrap class&lt;br /&gt;
		--return &amp;#039;&amp;lt;span class=&amp;quot;nowrap&amp;quot;&amp;gt;&amp;#039; .. nodeLabel .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
		&lt;br /&gt;
		-- a better method for template expansion size is to replace spaces with nonbreaking spaces&lt;br /&gt;
		-- however, there is a problem if labels have a styling element (e.g. &amp;lt;span style= ..., &amp;lt;span title= ...)&lt;br /&gt;
		local stylingElementDetected = false&lt;br /&gt;
		if string.find(nodeLabel, &amp;quot;span &amp;quot;) ~= nil  then  stylingElementDetected = true end&lt;br /&gt;
		if string.find(nodeLabel, &amp;quot; style&amp;quot;) ~= nil then stylingElementDetected = true end &lt;br /&gt;
		&lt;br /&gt;
		if stylingElementDetected == true then &lt;br /&gt;
			return &amp;#039;&amp;lt;span class=&amp;quot;nowrap&amp;quot;&amp;gt;&amp;#039; .. nodeLabel .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
    	else	&lt;br /&gt;
    		local nowrapString = string.gsub(nodeLabel,&amp;quot; &amp;quot;, &amp;quot;&amp;amp;nbsp;&amp;quot;) -- replace spaces with non-breaking space&lt;br /&gt;
			return nowrapString&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[=================== Newick string handling function =============================&lt;br /&gt;
]]&lt;br /&gt;
function p.getNewickOuterterm(newickString)&lt;br /&gt;
	return string.gsub(newickString, &amp;quot;%b()&amp;quot;, &amp;quot;&amp;quot;)   -- delete parenthetic term&lt;br /&gt;
end&lt;br /&gt;
function p.newick(count,newickString)&lt;br /&gt;
	local cladeString = &amp;quot;&amp;quot;&lt;br /&gt;
	count = count+1&lt;br /&gt;
	--start table&lt;br /&gt;
	cladeString = cladeString .. &amp;#039;{| style=&amp;quot;border-collapse:collapse;border-spacing:0;border:0;margin:0;&amp;#039;  &lt;br /&gt;
	&lt;br /&gt;
	local j,k&lt;br /&gt;
	j,k = string.find(newickString, &amp;#039;%(.*%)&amp;#039;)                 -- find location of outer parenthesised term&lt;br /&gt;
	local innerTerm = string.sub(newickString, j+1, k-1)      -- select content in parenthesis&lt;br /&gt;
	local outerTerm = string.gsub(newickString, &amp;quot;%b()&amp;quot;, &amp;quot;&amp;quot;)   -- delete parenthetic term&lt;br /&gt;
	if outerTerm == &amp;#039;panthera&amp;#039; then outerTerm = &amp;quot;x&amp;quot; end     -- how is this set in local variable for inner nodes?&lt;br /&gt;
	&lt;br /&gt;
	outerTerm = tostring(count)&lt;br /&gt;
	&lt;br /&gt;
	-- need to remove commas in bracket terms before split, so temporarily replace commas between brackets&lt;br /&gt;
    local innerTerm2 =  string.gsub(innerTerm, &amp;quot;%b()&amp;quot;,  function (n)&lt;br /&gt;
                                         	return string.gsub(n, &amp;quot;,%s*&amp;quot;, &amp;quot;XXX&amp;quot;)  -- also strip spaces after commas here&lt;br /&gt;
                                            end)&lt;br /&gt;
	--cladeString = cladeString .. &amp;#039;\n&amp;#039; .. p.addTaxon(1, innerTerm2, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	local s = strsplit(innerTerm2, &amp;quot;,&amp;quot;)&lt;br /&gt;
	local i=1	&lt;br /&gt;
	while s[i] do	&lt;br /&gt;
		restoredString = string.gsub(s[i],&amp;quot;XXX&amp;quot;, &amp;quot;,&amp;quot;)   -- convert back to commas&lt;br /&gt;
		--restoredString = s[i]&lt;br /&gt;
		local outerTerm = string.gsub(restoredString, &amp;quot;%b()&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		if string.find(restoredString, &amp;#039;%(.*%)&amp;#039;) then&lt;br /&gt;
			--cladeString = cladeString .. &amp;#039;\n&amp;#039; .. p.addTaxon(i, restoredString, &amp;quot;x&amp;quot;)&lt;br /&gt;
			cladeString = cladeString .. &amp;#039;\n&amp;#039; .. p.addTaxon(i, p.newick(count,restoredString), outerTerm)&lt;br /&gt;
			-- p.addTaxon(2, p.newick(count,newickString2), &amp;quot;root&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			cladeString = cladeString .. &amp;#039;\n&amp;#039; .. p.addTaxon(i, restoredString, &amp;quot;&amp;quot;) --count)&lt;br /&gt;
		end&lt;br /&gt;
		i=i+1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- close table&lt;br /&gt;
	cladeString = cladeString ..  &amp;#039;\n&amp;#039; .. &amp;#039;| style=&amp;quot;border: 0; padding: 0; vertical-align: top;&amp;quot; | &amp;lt;br/&amp;gt; \n|}&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	return cladeString&lt;br /&gt;
end&lt;br /&gt;
-- emulate a standard split string function&lt;br /&gt;
function strsplit(inputstr, sep) &lt;br /&gt;
        if sep == nil then&lt;br /&gt;
                sep = &amp;quot;%s&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        local t={} ; i=1&lt;br /&gt;
        for str in string.gmatch(inputstr, &amp;quot;([^&amp;quot;..sep..&amp;quot;]+)&amp;quot;) do&lt;br /&gt;
                t[i] = str&lt;br /&gt;
                i = i + 1&lt;br /&gt;
        end&lt;br /&gt;
        return t&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Bits from Peter Coxhead&amp;#039;s module&lt;br /&gt;
--    https://en.wikipedia.org/w/index.php?title=Module:Autotaxobox&amp;amp;action=edit&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Utility function primarily intended for use in checking and debugging.&lt;br /&gt;
Returns number of levels in a taxonomic hierarchy, starting from&lt;br /&gt;
the supplied taxon as level 1.&lt;br /&gt;
Usage: {{#invoke:Autotaxobox|nLevels|TAXON}}&lt;br /&gt;
]]&lt;br /&gt;
function p.nLevels(frame)&lt;br /&gt;
	local currTaxon = frame.args[1]&lt;br /&gt;
    local i = 1&lt;br /&gt;
	local maxN = 2&lt;br /&gt;
	local searching = true&lt;br /&gt;
	while searching and i &amp;lt; maxN  do&lt;br /&gt;
		--local parent = frame:expandTemplate{ title = &amp;#039;Template:Taxonomy/&amp;#039; .. currTaxon, args = {[&amp;#039;machine code&amp;#039;] = &amp;#039;parent&amp;#039; } }&lt;br /&gt;
		local parent = frame:expandTemplate{ title =  currTaxon, args = {[&amp;#039;machine code&amp;#039;] = &amp;#039;parent&amp;#039; } }&lt;br /&gt;
		if parent ~= &amp;#039;&amp;#039; then&lt;br /&gt;
			currTaxon = parent&lt;br /&gt;
			i = i + 1&lt;br /&gt;
		else&lt;br /&gt;
			searching = false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if searching then return currTaxon --maxN .. &amp;#039;+&amp;#039;&lt;br /&gt;
	else return i&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Utility function primarily intended for use in checking and debugging.&lt;br /&gt;
Returns a comma separated list of a taxonomic hierarchy, starting from&lt;br /&gt;
the supplied taxon.&lt;br /&gt;
Usage: {{#invoke:Autotaxobox|listAll|TAXON}}&lt;br /&gt;
]]&lt;br /&gt;
function p.listAll(frame)&lt;br /&gt;
	local currTaxon = frame.args[1]&lt;br /&gt;
	local i = 1&lt;br /&gt;
	local searching = true&lt;br /&gt;
	local maxN = 100&lt;br /&gt;
	local lst = currTaxon&lt;br /&gt;
	while i &amp;lt; maxN and searching do&lt;br /&gt;
		local currCall = &amp;#039;Template:Taxonomy/&amp;#039; .. currTaxon&lt;br /&gt;
		local parent = frame:expandTemplate{ title = currCall, args = {[&amp;#039;machine code&amp;#039;] = &amp;#039;parent&amp;#039; } }&lt;br /&gt;
		if parent ~= &amp;#039;&amp;#039; then&lt;br /&gt;
			currTaxon = parent&lt;br /&gt;
			lst = lst .. &amp;#039;, &amp;#039; .. currTaxon&lt;br /&gt;
			i = i + 1&lt;br /&gt;
		else&lt;br /&gt;
			searching = false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if searching then lst = lst .. &amp;#039;...&amp;#039; end&lt;br /&gt;
	return lst .. &amp;#039; (&amp;#039; .. i .. &amp;#039;)&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- =================== experimental Newick to clade parser function =============================&lt;br /&gt;
&lt;br /&gt;
--[[Function of convert Newick strings to clade format&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:Module:Sandbox/Jts1882/CladeN|newickConverter|newickstring={{{NEWICK_STRING}}} }}&lt;br /&gt;
]]&lt;br /&gt;
function p.newickConverter(frame)&lt;br /&gt;
	&lt;br /&gt;
	local newickString = frame.args[&amp;#039;newickstring&amp;#039;]&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	if newickString == &amp;#039;{{{newickstring}}}&amp;#039; then return newickString  end&lt;br /&gt;
&lt;br /&gt;
	-- show the Newick string&lt;br /&gt;
	local cladeString = &amp;#039;&amp;#039;&lt;br /&gt;
	local levelNumber = 1           --  for depth of iteration&lt;br /&gt;
	local childNumber = 1           --  number of sister elements on node  (always one for root)&lt;br /&gt;
	&lt;br /&gt;
	--  converted the newick string to the clade structure&lt;br /&gt;
	cladeString = cladeString .. &amp;#039;{{clade&amp;#039;&lt;br /&gt;
	cladeString = cladeString .. p.newickParseLevel(newickString, levelNumber, childNumber) &lt;br /&gt;
	cladeString = cladeString .. &amp;#039;\r}}&amp;#039;  &lt;br /&gt;
&lt;br /&gt;
	local resultString = &amp;#039;&amp;#039;&lt;br /&gt;
    local option = mw.getCurrentFrame():getParent().args[&amp;#039;option&amp;#039;] or &amp;#039;&amp;#039;&lt;br /&gt;
    if option == &amp;#039;tree&amp;#039; then&lt;br /&gt;
	 	--show the transcluded clade diagram&lt;br /&gt;
		resultString =   cladeString    	&lt;br /&gt;
    else&lt;br /&gt;
    	-- show the Newick string&lt;br /&gt;
		resultString = &amp;#039;&amp;lt;pre&amp;gt;&amp;#039;..newickString..&amp;#039;&amp;lt;/pre&amp;gt;&amp;#039;	&lt;br /&gt;
	    -- show the converted clade structure&lt;br /&gt;
	    resultString = resultString .. &amp;#039;&amp;lt;pre&amp;gt;&amp;#039;.. cladeString ..&amp;#039;&amp;lt;/pre&amp;gt;&amp;#039;	&lt;br /&gt;
    end&lt;br /&gt;
    --resultString = frame:expandTemplate{ title = &amp;#039;clade&amp;#039;,  frame:preprocess(cladeString) }&lt;br /&gt;
&lt;br /&gt;
    return resultString&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ Parse one level of Newick sting&lt;br /&gt;
     This function recieves a Newick string, which has two components&lt;br /&gt;
      1. the right hand term is a clade label: |labelN=labelname&lt;br /&gt;
      2. the left hand term in parenthesis has common delimited child nodes, each of which can be&lt;br /&gt;
           i.  a taxon name which just needs:  |N=leafname &lt;br /&gt;
           ii. a Newick string which needs further processing through reiteration&lt;br /&gt;
]]&lt;br /&gt;
function p.newickParseLevel(newickString,levelNumber,childNumber)&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
	local cladeString = &amp;quot;&amp;quot;&lt;br /&gt;
	local indent = p.getIndent(levelNumber) &lt;br /&gt;
	--levelNumber=levelNumber+1&lt;br /&gt;
	&lt;br /&gt;
	local j=0&lt;br /&gt;
	local k=0&lt;br /&gt;
	j,k = string.find(newickString, &amp;#039;%(.*%)&amp;#039;)                 -- find location of outer parenthesised term&lt;br /&gt;
	local innerTerm = string.sub(newickString, j+1, k-1)      -- select content in parenthesis&lt;br /&gt;
	local outerTerm = string.gsub(newickString, &amp;quot;%b()&amp;quot;, &amp;quot;&amp;quot;)   -- delete parenthetic term&lt;br /&gt;
&lt;br /&gt;
	cladeString = cladeString .. indent .. &amp;#039;|label&amp;#039;..childNumber..&amp;#039;=&amp;#039;  .. outerTerm&lt;br /&gt;
	cladeString = cladeString .. indent .. &amp;#039;|&amp;#039; .. childNumber..&amp;#039;=&amp;#039;  .. &amp;#039;{{clade&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	levelNumber=levelNumber+1&lt;br /&gt;
	indent = p.getIndent(levelNumber)&lt;br /&gt;
	&lt;br /&gt;
		-- protect commas in inner parentheses from split; temporarily replace commas between parentheses&lt;br /&gt;
	    local innerTerm2 =  string.gsub(innerTerm, &amp;quot;%b()&amp;quot;,  function (n)&lt;br /&gt;
	                                         	return string.gsub(n, &amp;quot;,%s*&amp;quot;, &amp;quot;XXX&amp;quot;)  -- also strip spaces after commas here&lt;br /&gt;
	                                            end)&lt;br /&gt;
	&lt;br /&gt;
		local s = strsplit(innerTerm2, &amp;quot;,&amp;quot;)&lt;br /&gt;
		local i=1	&lt;br /&gt;
		while s[i] do	&lt;br /&gt;
			restoredString = string.gsub(s[i],&amp;quot;XXX&amp;quot;, &amp;quot;,&amp;quot;)   -- convert back to commas&lt;br /&gt;
	&lt;br /&gt;
			local outerTerm = string.gsub(restoredString, &amp;quot;%b()&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
			if string.find(restoredString, &amp;#039;%(.*%)&amp;#039;) then&lt;br /&gt;
				--cladeString = cladeString .. indent .. &amp;#039;|y&amp;#039; .. i .. &amp;#039;=&amp;#039; .. p.newickParseLevel(restoredString,levelNumber+1,i) &lt;br /&gt;
				cladeString = cladeString  .. p.newickParseLevel(restoredString,levelNumber,i) &lt;br /&gt;
			else&lt;br /&gt;
				cladeString = cladeString .. indent .. &amp;#039;|&amp;#039; .. i .. &amp;#039;=&amp;#039; .. restoredString --.. &amp;#039;(level=&amp;#039; .. levelNumber .. &amp;#039;)&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			i=i+1&lt;br /&gt;
		end&lt;br /&gt;
--    end -- end splitting of strings&lt;br /&gt;
&lt;br /&gt;
	cladeString = cladeString .. indent .. &amp;#039;}}&amp;#039;  &lt;br /&gt;
    return cladeString&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.getIndent(levelNumber)&lt;br /&gt;
	local indent = &amp;quot;\r&amp;quot;&lt;br /&gt;
	local extraIndent = mw.getCurrentFrame():getParent().args[&amp;#039;indent&amp;#039;] or 0&lt;br /&gt;
	&lt;br /&gt;
	while tonumber(extraIndent) &amp;gt; 0 do&lt;br /&gt;
	    indent = indent .. &amp;quot; &amp;quot; -- an extra indent to make aligining compound trees easier&lt;br /&gt;
	    extraIndent = extraIndent - 1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	while levelNumber &amp;gt; 1 do&lt;br /&gt;
		indent = indent .. &amp;quot;   &amp;quot;&lt;br /&gt;
		levelNumber = levelNumber-1&lt;br /&gt;
	end&lt;br /&gt;
	return indent&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.newickstuff(newickString)&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.test(dummy)&lt;br /&gt;
	local dataString = &amp;quot;&amp;quot;&lt;br /&gt;
    dataString =	&amp;quot;NEWCLADE:&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    local childNumber =0&lt;br /&gt;
    local lastNode = 0&lt;br /&gt;
	while 	childNumber &amp;lt; 17 do -- disable moreNeeded &lt;br /&gt;
	&lt;br /&gt;
		childNumber = childNumber + 1 -- so we start with 1&lt;br /&gt;
		local nodeLeaf = mw.getCurrentFrame():getParent().args[tostring(childNumber)]  or &amp;quot;&amp;quot; -- get data from |N=&lt;br /&gt;
		--local nodeLabel = mw.getCurrentFrame():getParent().args[&amp;#039;label&amp;#039;..tostring(childNumber)] or &amp;quot;&amp;quot;  -- get data from |labelN=&lt;br /&gt;
        if nodeLeaf ~= &amp;quot;&amp;quot; then&lt;br /&gt;
			dataString = dataString .. tostring(childNumber)&lt;br /&gt;
&lt;br /&gt;
			local firstChars = string.sub(nodeLeaf, 1,2) -- get first two characters&lt;br /&gt;
			--if nodeLabel ~= &amp;quot;{{{label1}}}&amp;quot; then&lt;br /&gt;
			if firstChars == &amp;quot;{{&amp;quot;  then&lt;br /&gt;
                dataString = dataString .. &amp;#039;XXX&amp;#039; .. nodeLeaf&lt;br /&gt;
			end&lt;br /&gt;
			dataString = dataString .. &amp;#039;LEAF:&amp;#039; .. nodeLeaf&lt;br /&gt;
			&lt;br /&gt;
			lastNode = childNumber&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
    local numClades=0&lt;br /&gt;
    local numBranches=0&lt;br /&gt;
    -- _, count = string.gsub(dataString, &amp;quot;NEWCLADE&amp;quot;, &amp;quot;NEXT&amp;quot;)&lt;br /&gt;
   &lt;br /&gt;
    for i in string.gmatch(dataString, &amp;quot;NEWCLADE&amp;quot;) do&lt;br /&gt;
   		numClades = numClades + 1&lt;br /&gt;
     end&lt;br /&gt;
    dataString =   dataString .. &amp;#039;&amp;lt;br/&amp;gt;(numClades=&amp;#039; .. numClades .. &amp;#039;)&amp;#039;&lt;br /&gt;
    for i in string.gmatch(dataString, &amp;quot;LEAF&amp;quot;) do&lt;br /&gt;
   		numBranches = numBranches + 1&lt;br /&gt;
     end&lt;br /&gt;
    dataString =   dataString .. &amp;#039;&amp;lt;br/&amp;gt;(numClades=&amp;#039; .. numClades .. &amp;#039;)&amp;#039;&lt;br /&gt;
    dataString =   dataString .. &amp;#039;&amp;lt;br/&amp;gt;(numBranches=&amp;#039; .. numBranches .. &amp;#039;)&amp;#039;&lt;br /&gt;
    &lt;br /&gt;
	mw:log(numClades)&lt;br /&gt;
	&lt;br /&gt;
	--return &amp;#039;numClades=&amp;#039; .. numClades .. &amp;#039;; numBranches=&amp;#039; .. numBranches&lt;br /&gt;
	return  dataString &lt;br /&gt;
end&lt;br /&gt;
function p.test2(target)&lt;br /&gt;
	local target =&amp;quot;User:Jts1882/sandbox/templates/Template:Passeroidea&amp;quot;&lt;br /&gt;
	local result = mw.getCurrentFrame():expandTemplate{ title = target, args = {[&amp;#039;style&amp;#039;] = &amp;#039;&amp;#039; } }&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- this must be at end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>أسيل سيوف</name></author>
	</entry>
</feed>