Jump to content

Display an outline as a nested table: Difference between revisions

→‎Python: Functional: Adjusted to allow for outlines with more than one root (forests, rather than trees)
(→‎Python: Functional: Adjusted to allow for outlines with more than one root (forests, rather than trees))
Line 2,349:
 
 
# wikiTableFromOutlinewikiTablesFromOutline :: [String] -> String -> String
def wikiTableFromOutlinewikiTablesFromOutline(colorSwatch):
'''Wikitable markup for a nested (colspan) tabletables representing
representing the indentation of a given outline.
Each key-line point (child of thea tree root) has a
distinct color, inherited by all its descendants.
The first color in the swatch is for the root node.
A sequence of tables is generated where the outline
represents a forest rather than a singly-rooted tree.
'''
def go(soutline):
return '\n\n'.join([
wikiTableFromTree(colorSwatch)(tree) for tree in
forestFromLevels,(
indentLevelsFromLines(
s outline.splitlines()
)
)(
])
return go
 
 
# wikiTableFromTree :: [String] -> Tree String -> String
def wikiTableFromTree(colorSwatch):
'''A wikitable rendered from a single tree'''
def go(tree):
return compose(
wikiTableFromRows,
Line 2,363 ⟶ 2,380:
paintedTree(colorSwatch),
widthMeasuredTree,
fullDepthTree,
head,)(tree)
 
forestFromLevels,
indentLevelsFromLines
)(
s.splitlines()
)
return go
 
Line 2,392 ⟶ 2,405:
 
print(
wikiTableFromOutlinewikiTablesFromOutline([
"#ffffe6",
"#ffebd2",
9,659

edits

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