Skip to content
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

Unequal number of <div> and </div> in sphinx_rtd_theme/layout.html #1273

Open
thomas-nilsson-irfu opened this issue Jan 10, 2022 · 6 comments
Labels
Bug A bug Needed: replication Bug replication is required

Comments

@thomas-nilsson-irfu
Copy link

Problem

The included template, sphinx_rtd_theme/layout.html, does not have an equal number of <div> and </div> tags making it effectively invalid as per html standard.

Counting the numbers of <div> tags I get 12 and counting </div> I only get 11...

Reproducible Project

Including a simple shell script example:

# number of start tags:
grep -c '<div' sphinx_rtd_theme/layout.html
# number of end tags:
grep -c '</div' sphinx_rtd_theme/layout.html

Expected Results

Correctly start (<div>) and end (</div>) all tags in the template so it correctly follows the HTML standard, neither tag is omissible.

Ref:
https://html.spec.whatwg.org/multipage/grouping-content.html#the-div-element

Environment Info

  • Python Version: N/A
  • Sphinx Version: N/A
  • RTD Theme Version: master branch (as of 2022-01-10).
@thomas-nilsson-irfu thomas-nilsson-irfu added Bug A bug Needed: replication Bug replication is required labels Jan 10, 2022
@NaincyKumariKnoldus
Copy link

Hey @thomas-nilsson-irfu I want to resolve this error. Can I?

@astrojuanlu
Copy link
Contributor

Hi @NaincyKumariKnoldus ! Your contribution is more than welcome. We haven't yet assessed what <div> is missing a closing tag.

@NaincyKumariKnoldus
Copy link

hye @astrojuanlu I will see that which

is missing closing tag. Can I?

@NaincyKumariKnoldus
Copy link

Hello @astrojuanlu and @thomas-nilsson-irfu I have raised now a PR for this and fixed this issue.
Please review it. Thanks!

@astrojuanlu
Copy link
Contributor

xref #1274

@tombai777
Copy link

There's only an unequal number due to this conditionally templated div, so on a grep you'd get 12 of '<div' but only 11 of 'div>' even though it would always render correctly.

Screenshot 2022-06-09 at 14 19 10

If this really is a problem you could fix it by conditionally displaying the class, roughly like this:

<div {% if theme_style_external_links|tobool %} class="rst-content style-external-links" {% else %} class="rst-content" {% endif %}>...</div>

or something similar instead of this if/else/endif block.

Could also do it with a helper function; see https://forums.meteor.com/t/solved-conditional-css-class-applied-to-element-in-template-can-this-be-simplified/7627

Not sure if this is really worth a fix (given it probably violates code style) or just to close this issue 🫠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Needed: replication Bug replication is required
Projects
None yet
Development

No branches or pull requests

4 participants