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
BUG: standalone HTML and Restructured Text wrong heading #3119
Comments
I also tried a different input (same flags - again mind the =====
Title
=====
--------
subtitle
--------
heading1
========
heading2
--------
heading3
.~~~~~~~~
heading4
.```````` The non <section id="title" class="level1">
<h1>Title</h1>
<section id="subtitle" class="level2">
<h2>subtitle</h2>
<section id="heading1" class="level3">
<h3>heading1</h3>
<section id="heading2" class="level4">
<h4>heading2</h4>
<section id="heading3" class="level5">
<h5>heading3</h5>
<section id="heading4" class="level6">
<h6>heading4</h6>
</section>
</section>
</section>
</section>
</section>
</section> The <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Title</title>
<style type="text/css">code{white-space: pre;}</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<h1 class="title">Title</h1>
<h1 class="subtitle">subtitle</h1>
</header>
<section id="heading1" class="level1">
<h1>heading1</h1>
<section id="heading2" class="level2">
<h2>heading2</h2>
<section id="heading3" class="level3">
<h3>heading3</h3>
<section id="heading4" class="level4">
<h4>heading4</h4>
</section>
</section>
</section>
</section>
</body>
</html> |
The output with
|
W3C recommends not to use heading elements for subtitles:
They also offer a list of common idioms to work around this. Wrapping title and subtitle in spans and putting them in the same header might be viable solution. <h1><span class="title">Title</span><span class="subtitle">heading1</span><h1> |
@tarbeb that solution is going to produce very ugly output without special CSS. |
That's true. Wrapping things in a |
+++ Albert Krewinkel [Sep 15 16 01:34 ]:
I've tried to avoid doing that, but it's an option. It's hard to see what the real downside to using an h1 is |
Right, sorry. There used to be an old rule that multiple The other reason is that the W3C designed an outline algorithm which is intended to allow well-defined toc generation. AFAIK no widely used software actually supports that feature, violating the recommendation should not cause much problems in practice. I like standard conformance though, going against it rubs me the wrong way. It's more of an æstetical than a practical issue. |
There used to be an old rule that multiple <h1> elements confuse search
engines and would lead to lower search rankings. I believe this is no
longer true, but it's still deeply ingrained in may web-developers'
minds.
We have this issue even without subtitles, since level-1
headers go to h1.
Many would favor making the title the only h1, and demoting
everything else a level, so `#` headers are h2.
But this breaks some expectations -- `#` in markdown is
supposed to be h1.
Not sure what's best here.
… The other reason is that the W3C designed an outline algorithm which is
intended to allow well-defined toc generation. AFAIK no widely used
software actually supports that feature, violating the recommendation
should not cause much problems in practice. I like standard conformance
though, going against it rubs me the wrong way. It's more of an
æstetical than a practical issue.
|
Using HTML5 and <header>
<h1 class="title">Title</h1>
<p class="subtitle">Subtitle</p>
</header> It's among the common idiom listed by the W3C and should look okay even when it is unstyled. |
I don't feel strongly about it. I think I'd be fine with I think this only concerns the HTML template. |
When converting a restructured text to HTML with:
the heading and the title get the same level of heading, and all the headers are accordingly generated.
The
--section-divs
does not influence the behavior.For example, with the following input (
.
in heading 3 is there only to prevent GitHub rendering, but should be removed for testing).the output is:
when
--standalone
is not used, the expected output is obtained, i.e.:EDIT: minor fixes
The text was updated successfully, but these errors were encountered: