1
In a fictional document management system, input documents are structured with weighted headings. Lowest weighted headings are the most important.
This is a sample document:
H1 All About Birds
H2 Kinds of Birds
H3 The Finch
H3 The Swan
H2 Habitats
H3 Wetlands
From this document we would like to produce an outline using nested ordered lists in HTML, which would look like this when rendered:
- All About Birds
- Kinds of Birds
- The Finch
- The Swan
- Habitats
- Wetlands
- Kinds of Birds
Your code only needs to take the input list and transform it into the expected data structure, which will be printed.
1When you say "using nested ordered lists in HTML" do you mean we need to produce HTML? If so could you define its form for us? (Or may we just indent using a space (or a tab?)?) – Jonathan Allan – 2019-05-11T20:37:07.467
Can the titles be assumed to only contain letters and spaces? – ArBo – 2019-05-11T21:06:33.753
2
Hi and welcome to codegolf! To avoid having to answer questions like those you received, please note that we have a sandbox for proposed challenges which allows you to receive feedback before posting. As is you are missing a few important details, like those already asked about, and things like what the highest header level there will be (or if it is indefinite).
– FryAmTheEggman – 2019-05-11T21:26:39.670This feels familiar; I think we may have had this already using Markdown's
#
instead of HTML's<h
. – Shaggy – 2019-05-11T21:50:26.423@Shaggy except this seems to be about using nested ordered lists
<ol>
rather than headings. – Nick Kennedy – 2019-05-11T22:44:34.2301May the level be greater than $9$? – Arnauld – 2019-05-11T23:06:59.570
2Are we guaranteed to always have level $L+1$ between levels $L$ and $L+2$? Are we supposed to return valid HTML? (with all trailing
</ol>
tags) – Arnauld – 2019-05-11T23:35:06.433