Building a Structured Outline 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 




Your code only needs to take the input list and transform it into the expected data structure, which will be printed.
Jelly, 53 50 bytes

Ḋœṡ¥€⁶ZµḢVØ0jI&gt;0ẋ"AƲị“&lt;ol&gt;“&lt;/ol&gt;”żṪ“&lt;li&gt;“&lt;/li&gt;”jⱮƊ


Try it online!

A monadic link taking a list of strings as input and outputting an HTML fragment with nested ordered lists. Should handle arbitrarily deep nesting of lists and return a syntactically valid HTML fragment. 

Example:

H1 All About Birds
H2 Kinds of Birds
H3 The Finch
H3 The Swan
H2 Habitats
H3 Wetlands
H4 Types of wetlands
H5 Very wet wetland
H3 Coast
H1 All about fish
H2 Sharks


yields:

&lt;ol&gt;&lt;li&gt;All About Birds&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Kinds of Birds&lt;/li&gt;&lt;ol&gt;&lt;li&gt;The Finch&lt;/li&gt;&lt;li&gt;The Swan&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Habitats&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Wetlands&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Types of wetlands&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Very wet wetland&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;Coast&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;All about fish&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Sharks&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;


All About BirdsKinds of BirdsThe FinchThe SwanHabitatsWetlandsTypes of wetlandsVery wet wetlandCoastAll about fishSharks