outliner
Outliner produces an outline of an HTML document in markdown format,
suitable for use as a table of contents.
Installation
If you have Go installed on your system, run:
$ go install -v git.sr.ht/\~javiljoen/outliner@latest
Usage
Run the outliner
command, passing in the HTML document via stdin.
The repo contains an example document named test.html
.
$ outliner < test.html
1. [Section A](#a)
1. [Section A.1](#a1)
1. [Section A.1.i](#a1i)
2. [Section A.1.ii](#a1ii)
2. [Section A.3](#a2)
2. [Section B](#b)
The input HTML is expected to have the following structure:
- Each section and subsection below the main container element
(i.e. after the title, preamble, etc.)
is encapsulated in a
<section>
element.
- Each section/subsection has a section heading within an
<h2>
, <h3>
, or <h4>
element,
as a direct child of the <section>
element.
(Sections below the level of subsubsection are not included in the outline.)
- The
id
attribute must be set on the <section>
element (not the heading element).
This will serve as the link target in the generated outline.
Note: If the HTML is generated by Pandoc, the expected structure can be obtained by using the --section-divs
flag.
$ pandoc --section-divs README.md | outliner
1. [Installation](#installation)
2. [Usage](#usage)