Turn HTML like this
para zeroHEAD-Apara a1para a2HEAD-Bpara b1
into an object tree like this:
Section {
count: 0,
intro: [ '<p>para zero</p>' ],
subs:
[ Section { count: 1, title: 'HEAD-A',
intro: [ '<p>para a1</p>', '<p>para a2</p>' ],
subs: [], ids: [] },
Section { count: 2, title: 'HEAD-B',
or new HTML something like this:
para zero 1. HEAD-A para a1 para a2 2. HEAD-B para b1
Command line
That's from the command-line:
$ sectioner example/doc1.html
API
const sectioner = const root = sectioner // do stuff with root, which is a Section. For each Section s://// s.title -- text of the title// s.ids -- array of html ids you want for this section// s.intro -- array of html bits, eg '<p>...</p>' before subsections// s.subs -- array of subsections, new sectioner.Section()// s.head -- null, or like intro for the HTML <head> // after manipulating the tree how you like, optionally call root // then you can use// s.coord -- array like [1,3] for section 1.3// s.coordText --- 1.3.// s.coordText('/', ':') -- 1/3:// s.hLevel 2 (in this case), h2, because 1.3 is second level // finally const html = root