Jump to content

Display an outline as a nested table: Difference between revisions

m
J: lighter random colors
(J)
m (J: lighter random colors)
Line 682:
y (+//. c&*)`(~.@[)`]}^:_ c
}}
 
NB. avoid dark colors
pastel=: {{256#.192+?m$,:3#64}}
 
task=: {{
Line 692 ⟶ 695:
widths=. width tr NB. column widths
top=. I.2>dr
color=.<"1 hfd (?2^24)''pastel (I.tr e.pad)} (top top} tr)&{^:_ ?(#dr)#2^24pastel
r=.'{| class="wikitable" style="text-align: center;"',LF
for_d.~.dr do. NB. descend through the depths
Line 721 ⟶ 724:
}}</lang>
 
Generated output from <tt>task outline</tt> was:
 
{| class="wikitable" style="text-align: center;"
|-
| style="background: #7db43695ab96" colspan=7 | Display an outline as a nested table.
|-
| style="background: #0f2deed99fa5" colspan=3 | Parse the outline to a tree,
| style="background: #bdb8cfa1b8b5" colspan=2 | count the leaves descending from each node,
| style="background: #37e81f43e9cb" colspan=2 | and write out a table with 'colspan' values
|-
| style="background: #0f2deed99fa5" colspan=1 | measuring the indent of each line,
| style="background: #0f2deed99fa5" colspan=1 | translating the indentation to a nested structure,
| style="background: #0f2deed99fa5" colspan=1 | and padding the tree to even depth.
| style="background: #bdb8cfa1b8b5" colspan=1 | defining the width of a leaf as 1,
| style="background: #bdb8cfa1b8b5" colspan=1 | and the width of a parent node as a sum.
| style="background: #37e81f43e9cb" colspan=1 | either as a wiki table,
| style="background: #37e81f43e9cb" colspan=1 | or as HTML.
|-
| style="background: #a5c383c9decd" colspan=1 |
| style="background: #a5c383c9decd" colspan=1 |
| style="background: #a5c383c9decd" colspan=1 |
| style="background: #a5c383c9decd" colspan=1 |
| style="background: #bdb8cfa1b8b5" colspan=1 | (The sum of the widths of its children)
| style="background: #a5c383c9decd" colspan=1 |
| style="background: #a5c383c9decd" colspan=1 |
|}
 
 
=={{header|JavaScript}}==
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.