Display an outline as a nested table: Difference between revisions

m
J: better contrast
(J: bugfix (use generated colors as colors rather than as a limiting color range)
m (J: better contrast)
Line 673:
=={{header|J}}==
 
Implementation (assigning colors randomly):
 
<lang J>depth=: (i.~ ~.)@(0 i."1~' '=];._2)
Line 685:
NB. avoid dark colors
NB. avoid dark colors
NB. avoid dark colors
pastel=: {{256#.192+?my$,:3#64}}
 
task=: {{
Line 696 ⟶ 697:
widths=. width tr NB. column widths
top=. I.2>dr
color=.<"1 hfd ''pastel8421504 (I.tr e.pad)} (top top} tr)&{^:_ (#dr<:2^24),pastel<:#dr
r=.'{| class="wikitable" style="text-align: center;"',LF
for_d.~.dr do. NB. descend through the depths
Line 729 ⟶ 730:
{| class="wikitable" style="text-align: center;"
|-
| style="background: #cdead6ffffff" colspan=7 | Display an outline as a nested table.
|-
| style="background: #c0f1e1e7d7cd" colspan=3 | Parse the outline to a tree,
| style="background: #f3dbd1e9c5d1" colspan=2 | count the leaves descending from each node,
| style="background: #cae2dcd8e9f4" colspan=2 | and write out a table with 'colspan' values
|-
| style="background: #c0f1e1e7d7cd" colspan=1 | measuring the indent of each line,
| style="background: #c0f1e1e7d7cd" colspan=1 | translating the indentation to a nested structure,
| style="background: #c0f1e1e7d7cd" colspan=1 | and padding the tree to even depth.
| style="background: #f3dbd1e9c5d1" colspan=1 | defining the width of a leaf as 1,
| style="background: #f3dbd1e9c5d1" colspan=1 | and the width of a parent node as a sum.
| style="background: #cae2dcd8e9f4" colspan=1 | either as a wiki table,
| style="background: #cae2dcd8e9f4" colspan=1 | or as HTML.
|-
| style="background: #c9e3ff808080" colspan=1 |
| style="background: #c9e3ff808080" colspan=1 |
| style="background: #c9e3ff808080" colspan=1 |
| style="background: #c9e3ff808080" colspan=1 |
| style="background: #f3dbd1e9c5d1" colspan=1 | (The sum of the widths of its children)
| style="background: #c9e3ff808080" colspan=1 |
| style="background: #c9e3ff808080" colspan=1 |
|}
 
6,962

edits