hoyois / html5outliner Goto Github PK
View Code? Open in Web Editor NEWA Javascript implementation of the HTML outline algorithm
A Javascript implementation of the HTML outline algorithm
When I try to get the depth of heading elements, they always return a value of 1, as opposed to their section depth (body > article > h1 should be depth 2), regardless of where they are located in the document.
The similar h5o project has an outline object method called asHTML()
that outputs an ordered list of section titles, optionally as hyperlinks (using the section’s id
or generating one if there’s none), that can be used to output a table of contents. I’d like to see that in this one. Right now I am using both scripts for their unique features, which means I incur a performance hit making the client download two separate scripts that do essentially the same thing, and then running them both.
Keeping this up to date with the latest specs / drafts would be highly beneficial.
I've tested following code both using your tools and tools from https://gsnedders.html5.org/outliner/ , and found that they return different results
<body>
<section>
<section>
<h1>Wind</h1>
<p>xxx
</section>
<p>yyy
<section>
<h1>Cloud</h3>
<p>zzz
</section>
<h1>Rain</h1>
</section>
</body>
result from your tools:
1.Document
1.Section
1.Wind
2.Cloud
2.Rain
result from https://gsnedders.html5.org/outliner/
1.Untitled Section
1.Rain
1.Wind
2.Cloud
I don't know which one is more correct...
Could you add a licence file so it is clear whether HTMLOutliner.js can be used in other projects and under what conditions?
I couldn’t find any in the README or the main JavaScript file. Without a specified licence “nobody else may reproduce, distribute, or create derivative works from your work”.
If I’m not mistaken, I might have found a bug.
Take this document:
<body>
<section>
<nav></nav>
<h1>Only heading</h1>
</section>
</body>
The HTML5 Outliner produces this outline:
But I think this should be the correct outline:
The first element of heading content in an element of sectioning content represents the heading for that section.
So shouldn’t it use the h1
as heading for the section
even though this h1
comes after the nav
?
I’m not sure what the correct behaviour is when this happens in the body
sectioning root, e.g.:
<body>
<nav></nav>
<h1>Only Heading</h1>
</body>
The quoted spec explicitly mentions "in an element of sectioning content", so it doesn’t necessarily apply to sectioning root elements.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.