Display an outline as a nested table: Difference between revisions
Content added Content deleted
m (→{{header|zkl}}: tweak) |
|||
Line 1,076: | Line 1,076: | ||
} |
} |
||
} |
} |
||
span=( spans and (spans.sum(0) + span - 1) or span ); |
span=( spans and (spans.sum(0) + span - 1) or span ).max(1); |
||
parent[2]=span; |
parent[2]=span; |
||
return(rows,span); |
return(rows,span); |
||
Line 1,088: | Line 1,088: | ||
trees.append(tree); |
trees.append(tree); |
||
r,c := parse(ow,tree,cell,0,2,unit); |
r,c := parse(ow,tree,cell,0,2,unit); |
||
tree[0]= |
tree[0]=c; // span for this "branch" |
||
rows,cols = rows.max(r), cols + |
rows,cols = rows.max(r), cols + c; |
||
} |
} |
||
return(rows+1,cols,title,trees); |
return(rows+1,cols,title,trees); |
||
Line 1,104: | Line 1,104: | ||
foreach t in (trees){ // create this row |
foreach t in (trees){ // create this row |
||
span,clr := t[0], clrs.next(); |
span,clr := t[0], clrs.next(); |
||
col,cols := 1, t[1,*].filter('wrap([(d,_,text)]){ d==row }); |
|||
⚫ | |||
⚫ | |||
if(col<cpos){ out.writeln(cell(clr,cpos-col,"")); col=cpos } |
|||
⚫ | |||
else{ |
|||
⚫ | |||
col:=1; |
|||
⚫ | |||
⚫ | |||
if(col<cpos){ out.writeln(cell(clr,cpos-col,"")); col=cpos } |
|||
⚫ | |||
⚫ | |||
if(col<=span) out.writeln(cell(clr,span-col+1,"")); |
|||
} |
|||
} |
} |
||
} |
} |
||
Line 1,161: | Line 1,156: | ||
| style="background: #e6ffff " colspan=2 | |
| style="background: #e6ffff " colspan=2 | |
||
|} |
|} |
||
And the Perl6 example: |
And the Perl6 example: |
||
Line 1,197: | Line 1,193: | ||
| style="background: #ffebd2 " colspan=1 | translating the indentation to a nested structure, |
| style="background: #ffebd2 " colspan=1 | translating the indentation to a nested structure, |
||
| style="background: #ffebd2 " colspan=1 | and padding the tree to even depth. |
| style="background: #ffebd2 " colspan=1 | and padding the tree to even depth. |
||
⚫ | |||
| style="background: #f0fff0 " colspan=2 | and the width of a parent node as a sum. |
| style="background: #f0fff0 " colspan=2 | and the width of a parent node as a sum. |
||
⚫ | |||
| style="background: #e6ffff " colspan=1 | either as a wiki table, |
| style="background: #e6ffff " colspan=1 | either as a wiki table, |
||
| style="background: #e6ffff " colspan=1 | or as HTML. |
| style="background: #e6ffff " colspan=1 | or as HTML. |
||
Line 1,204: | Line 1,200: | ||
|- |
|- |
||
| style="background: #ffebd2 " colspan=3 | |
| style="background: #ffebd2 " colspan=3 | |
||
⚫ | |||
| style="background: #f0fff0 " colspan=1 | (The sum of the widths of its children) |
| style="background: #f0fff0 " colspan=1 | (The sum of the widths of its children) |
||
| style="background: #f0fff0 " colspan=1 | Propagating the sums upward as necessary. |
| style="background: #f0fff0 " colspan=1 | Propagating the sums upward as necessary. |
||
⚫ | |||
| style="background: #e6ffff " colspan=2 | |
| style="background: #e6ffff " colspan=2 | |
||
| style="background: #ffeeff " colspan=1 | |
| style="background: #ffeeff " colspan=1 | |