gisture icon indicating copy to clipboard operation
gisture copied to clipboard

Too many <h1>s

Open nat-418 opened this issue 3 years ago • 2 comments

Problem

For various reasons including screen readers and semantic HTML, there should only be one top-level <h1> element per page.

Solution

AFAIK gisture is just consuming whatever is coming from the raw markdown. It should either take it's first-level heading from the markdown file when it detects one is present. The alternative of just leveling all markdown headings one down (unless already at the bottom-level of <h6> seems an inferior solution.

I don't know Rust but I might hack on it and see what I can do. No promises though given I would be starting from zero.

nat-418 avatar Nov 14 '21 15:11 nat-418

Hey @nat-418 thank you for raising this issue. If I understand the problem correctly, you're saying the heading elements in the blog content should not be <h1> except only the title right?

Now it's just renders the Markdown directly as is, so # Title would be parsed as <h1>Title</h1>, ## Title as <h2>Title</h2> and so on. So should it render them as <h{n}> where n should be leveled down from the Markdown input?

Another thing is, it's all user input so in the gist markdown, one can manually enter it like that, in which case, it would cause a lot of confusion.

What do you think?

If as a user, it's a problem for you, I will fix it. :raised_hands:

Also if this is something that can be fixed directly from the HTML (for layouts), the templates are here.

PS: If you want to implement this, there are two places you can make changes to achieve this. The first one is in the Markdown parser itself (A good reference on the usage) and the second place is where you can configure the lol_html rewriter to do the level down.

mufeedvh avatar Nov 14 '21 18:11 mufeedvh

Yes, that is correct. I will hack on it a bit and pester you later if I fail to make headway. It's a nice-to-fix, cf. https://www.w3.org/TR/2014/REC-html5-20141028/sections.html#headings-and-section

nat-418 avatar Nov 14 '21 21:11 nat-418