Display an outline as a nested table: Difference between revisions
Display an outline as a nested table (view source)
Revision as of 00:00, 27 August 2022
, 1 year agosyntax highlighting fixup automation
m (J: better contrast) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 82:
=={{header|AutoHotkey}}==
<
oNum:=[], oMID:=[], oNod := [], oKid := [], oPnt := [], oMbr := [], oLvl := []
oCrl := ["#ffffe6;", "#ffebd2;", "#f0fff0;", "#e6ffff;", "#ffeeff;"]
Line 211:
return [html, wTable]
}
</syntaxhighlight>
Examples:<
(
Display an outline as a nested table.
Line 233:
Gui, Show
MsgBox % "HTML:`n" result.1 "`n`nWikitable:`n" result.2
return</
{{out}}
HTML:
Line 292:
=={{header|Go}}==
<
import (
Line 445:
toNest(iNodes2, 0, 0, &n2)
fmt.Println(toMarkup(n2, cols2, 4))
}</
{{out}}
Line 503:
=={{header|Haskell}}==
<
module OutlineTree where
Line 644:
<> "style=\"text-align: center;\"\n|-\n"
<> intercalate "|-\n" (wikiRow <$> rows)
<> "|}"</
{{Out}}
{| class="wikitable" style="text-align: center;"
Line 675:
Implementation:
<
tree=: (i: 0>.<:@{:)\
width=: {{NB. y is tree
Line 707:
end.
r=.r,'|}',LF
}}</
Given the task example outline:
<
Display an outline as a nested table.
Parse the outline to a tree,
Line 724:
either as a wiki table,
or as HTML.
}}</
Generated output from <tt>task outline</tt> was:
Line 754:
=={{header|JavaScript}}==
<
"use strict";
Line 1,299:
// MAIN ---
return main();
})();</
{{Out}}
{| class="wikitable" style="text-align:center;"
Line 1,327:
=={{header|Julia}}==
<
text = """
Line 1,404:
textplus = text * " Optionally add color to the nodes."
htmlfromdataframe(processtable(textplus))
</
<h4>A Rosetta Code Nested Table</h4><table style="width:100%" class="wikitable" >
<tr>
Line 1,479:
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<
Parse the outline to a tree,
measuring the indent of each line,
Line 1,598:
]
AppendTo[str, "</table>"];
StringRiffle[str, "\n"]</
{{out}}
<pre><table style='text-align: center;'>
Line 1,631:
=={{header|Nim}}==
<
const Outline = """Display an outline as a nested table.
Line 1,800:
nodelists.writeWikiTable()
echo "HTML:"
nodelists.writeHtml()</
{{out}}
Line 1,859:
=={{header|Perl}}==
<
use strict;
Line 1,913:
and write out a table with 'colspan' values
either as a wiki table,
or as HTML.</
{{out}}
<table border=1 cellspacing=0>
Line 1,946:
=={{header|Phix}}==
Can output in either html or wikitable markup
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">html</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">false</span><span style="color: #0000FF;">,</span>
Line 2,063:
<span style="color: #000000;">markup</span><span style="color: #0000FF;">(</span><span style="color: #000000;">outlines</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span><span style="color: #000000;">colours</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
in html:
Line 2,184:
=={{header|Python}}==
===Python: Procedural===
<
import itertools
Line 2,452:
table_format = "wiki"
example(table_format)</
{{out}}
Line 2,514:
===Python: Functional===
<
from itertools import chain, cycle, takewhile
Line 2,877:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
{| class="wikitable" style="text-align: center;"
Line 2,911:
Strictly speaking, this is not a nested table. It is just a single level table that has some column spans > 1. For an example of using actual nested tables, see the task entry: [[Rosetta_Code/List_authors_of_task_descriptions#Raku|List_authors_of_task_descriptions#Raku]], [[Rosetta_Code/List_authors_of_task_descriptions/Full_list|(and full output)]].
<syntaxhighlight lang="raku"
Display an outline as a nested table.
Parse the outline to a tree,
Line 3,055:
}
( $r, $g, $b ).map( ((*+$m) * 255).Int)».base(16).join
}</
{{out}}
Line 3,123:
{{libheader|Wren-dynamic}}
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
Line 3,271:
var iNodes2 = makeIndent.call(outline2, 4)
toNest.call(iNodes2, 0, 0, n2)
System.print(toMarkup.call(n2, cols2, 4))</
{{out}}
Line 3,329:
=={{header|zkl}}==
<
var [const] indent=" "*100; // no tabs
Line 3,392:
out.writeln("|}");
out.text
}</
<
#<<<
"Display an outline as a nested table.
Line 3,411:
rows,cols,title,trees := parseOutline(outlineText);
makeMarkup(rows,cols,title,trees).println();</
{{out}}
{| class="wikitable" style="text-align: center;"
Line 3,437:
And the Raku example:
<
#<<<
"Display an outline as a nested table.
Line 3,457:
rows,cols,title,trees := parseOutline(outlineText);
makeMarkup(rows,cols,title,trees).println();</
{{out}}
{| class="wikitable" style="text-align: center;"
|