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