Display an outline as a nested table: Difference between revisions
Content deleted Content added
m →{{header|zkl}}: cut and paste error |
|||
Line 784:
"""
const
"background: #ddffdd;", "background: #ddddff;"]
colorstring(n) = bcolor[n == 1 ? 1 : mod1(n - 1, length(bcolor) - 1) + 1]
function processtable(txt)
Line 809 ⟶ 810:
function leveloneparent(i)
p = parent(i)
▲ return sum(x -> indents[x] <= 1, 1:i)
end
df.TEXT = linetext
Line 838 ⟶ 833:
println("colspan=\"$(row[:COLSPAN])\"")
end
println(" style = \"$(
end
end
Line 847 ⟶ 842:
htmlfromdataframe(processtable(text))
textplus = text * " Optionally add color to the nodes."
htmlfromdataframe(processtable(textplus))
</lang>{{out}}
<h4>A Rosetta Code Nested Table</h4><table style="width:100%" class="wikitable" >
<tr>
<td colspan="7"
Line 860 ⟶ 857:
<td colspan="2"
style = "background: #ddddff;" >and write out a table with 'colspan' values</td>
</tr>
<tr>
<td colspan="1"
style = "background: #ffdddd;" >measuring the indent of each line,</td>
<td colspan="1"
style = "background: #ffdddd;" >translating the indentation to a nested structure,</td>
<td colspan="1"
style = "background: #ffdddd;" >and padding the tree to even depth.</td>
<td colspan="1"
style = "background: #ddffdd;" >defining the width of a leaf as 1,</td>
<td colspan="1"
style = "background: #ddffdd;" >and the width of a parent node as a sum.</td>
<td colspan="1"
style = "background: #ddddff;" >either as a wiki table,</td>
<td colspan="1"
style = "background: #ddddff;" >or as HTML.</td>
</tr>
<tr>
<td colspan="4"> </td>
<td colspan="1"
style = "background: #ddffdd;" >(The sum of the widths of its children)</td>
</tr>
</table>
<h4>A Rosetta Code Nested Table</h4><table style="width:100%" class="wikitable" >
<tr>
<td colspan="8"
style = "background: #ffffaa;" >Display an outline as a nested table.</td>
</tr>
<tr>
<td colspan="3"
style = "background: #ffdddd;" >Parse the outline to a tree,</td>
<td colspan="2"
style = "background: #ddffdd;" >count the leaves descending from each node,</td>
<td colspan="2"
style = "background: #ddddff;" >and write out a table with 'colspan' values</td>
<td colspan="1"
style = "background: #ffdddd;" >Optionally add color to the nodes.</td>
</tr>
<tr>
|