Skip to content

Commit

Permalink
Remove HTML 4 support (#11385)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Apr 28, 2023
1 parent 3e3251d commit ad47373
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 899 deletions.
22 changes: 9 additions & 13 deletions sphinx/builders/html/__init__.py
Expand Up @@ -45,7 +45,6 @@
from sphinx.util.matching import DOTFILES, Matcher, patmatch
from sphinx.util.osutil import copyfile, ensuredir, os_path, relative_uri
from sphinx.util.tags import Tags
from sphinx.writers._html4 import HTML4Translator
from sphinx.writers.html import HTMLWriter
from sphinx.writers.html5 import HTML5Translator

Expand Down Expand Up @@ -374,10 +373,7 @@ def add_js_file(self, filename: str, **kwargs: Any) -> None:

@property
def default_translator_class(self) -> type[nodes.NodeVisitor]: # type: ignore
if self.config.html4_writer:
return HTML4Translator # RemovedInSphinx70Warning
else:
return HTML5Translator
return HTML5Translator

@property
def math_renderer_name(self) -> str:
Expand Down Expand Up @@ -565,7 +561,7 @@ def prepare_writing(self, docnames: set[str]) -> None:
'parents': [],
'logo_url': logo,
'favicon_url': favicon,
'html5_doctype': not self.config.html4_writer,
'html5_doctype': True,
}
if self.theme:
self.globalcontext.update(
Expand Down Expand Up @@ -1310,13 +1306,13 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
config.html_favicon = None # type: ignore


def deprecate_html_4(_app: Sphinx, config: Config) -> None:
"""Warn on HTML 4."""
# RemovedInSphinx70Warning
def error_on_html_4(_app: Sphinx, config: Config) -> None:
"""Error on HTML 4."""
if config.html4_writer:
logger.warning(_('Support for emitting HTML 4 output is deprecated and '
'will be removed in Sphinx 7. ("html4_writer=True" '
'detected in configuration options)'))
raise ConfigError(_(
'HTML 4 is no longer supported by Sphinx. '
'("html4_writer=True" detected in configuration options)',
))


def setup(app: Sphinx) -> dict[str, Any]:
Expand Down Expand Up @@ -1380,7 +1376,7 @@ def setup(app: Sphinx) -> dict[str, Any]:
app.connect('config-inited', validate_html_static_path, priority=800)
app.connect('config-inited', validate_html_logo, priority=800)
app.connect('config-inited', validate_html_favicon, priority=800)
app.connect('config-inited', deprecate_html_4, priority=800)
app.connect('config-inited', error_on_html_4, priority=800)
app.connect('builder-inited', validate_math_renderer)
app.connect('html-page-context', setup_css_tag_helper)
app.connect('html-page-context', setup_js_tag_helper)
Expand Down
16 changes: 3 additions & 13 deletions sphinx/themes/basic/layout.html
Expand Up @@ -7,12 +7,9 @@
:copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{%- block doctype -%}{%- if html5_doctype %}
{%- block doctype -%}
<!DOCTYPE html>
{%- else %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{%- endif %}{%- endblock %}
{%- endblock %}
{%- set reldelim1 = reldelim1 is not defined and ' &#187;' or reldelim1 %}
{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and
Expand Down Expand Up @@ -105,17 +102,10 @@ <h3>{{ _('Navigation') }}</h3>
{%- if html_tag %}
{{ html_tag }}
{%- else %}
<html{% if not html5_doctype %} xmlns="http://www.w3.org/1999/xhtml"{% endif %}{% if language is not none %} lang="{{ language }}"{% endif %}>
<html{% if language is not none %} lang="{{ language }}"{% endif %}>
{%- endif %}
<head>
{%- if not html5_doctype and not skip_ua_compatible %}
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
{%- endif %}
{%- if use_meta_charset or html5_doctype %}
<meta charset="{{ encoding }}" />
{%- else %}
<meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" />
{%- endif %}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{- metatags }}
{%- block htmltitle %}
Expand Down

0 comments on commit ad47373

Please sign in to comment.