-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clamp heading level to 6 when outputting HTML #176
base: main
Are you sure you want to change the base?
Conversation
I don't think silently treating it as If djot doesn't support warning messages, it would be better to output the text as-is (i.e. |
This raises the question whether we should put the check at the parser level, so that seven #s just don't form a heading node, instead of dealing with it in the renderer. It could be that other formats allow > 6 levels of headings, but I'm not sure that's a reason by itself... |
I personally would imagine that anything using more than six levels of headers is probably generating those headers outside of a language like djot and therefore djot should be fine limiting itself in the way HTML has, since most people will be limited by HTML otherwise. So, whether it's reasonable to have that many headers wouldn't have to be addressed: just whether it's reasonable for someone using djot should, and I think the answer is probably no. Like maybe some physical books might be doing that, but will you be writing your entire book in djot? Probably not. If it's a website, something like that will be split into multiple pages. |
Pandoc will gladly treat |
My immediate thought when I saw this was "hey, djot isn't meant to be HTML-centric!" IOW I think the parser should probably produce heading nodes at any level since someone's output format might support that. I'm not saying that it's likely but HTML's cutoff at six is nonetheless arbitrary; some formats cut off at a lower level (e.g. Perl Pod at four) and I think that in principle the door should be left open for higher levels. The/an HTML renderer is another matter: it should do something when encountering a heading higher than 6. I think I'm most in favor of something like |
I like the idea of djot producing |
WAI-ARIA provides an
|
Given the following input:
The Lua code will gladly produce:
The JavaScript code does as well.
<h8>
and so on are also possible with no maximum I can find either in code or in the standard.Only
<h1>
through<h6>
are valid HTML. It may be useful for Djot to support heading levels higher than 6 when it is used to construct documents that support such, though in the interest of reducing ambiguity in the spec I'd suggest that some maximum is picked and I think that 6 is a reasonable number. All that being said, all this PR does is tweak html.lua such that if a heading level higher than 6 is encountered, only an<h6>
is outputted.Unfortunately I will not be submitting a PR for djot.js as I do not have a setup for transpiling and testing TypeScript, but I suspect a patch for that repo will be as trivial as this one.