[MERGE] Forward port of 11.0 to 12.0

This commit is contained in:
Martin Trigaux 2020-06-25 09:45:12 +02:00
commit 9ce3eedc65
2 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,6 @@
{% extends "basic/layout.html" %}
{% set html5_doctype = True %}
{%- block scripts %}
{{ super() }}
<script type="text/javascript" src="{{ pathto('_static/jquery.min.js', 1) }}"></script>
@ -20,15 +22,6 @@
{% set classes = classes + meta['classes'].split() %}
{% endif %}
{%- block doctype -%}
<!doctype html>
{%- endblock -%}
{%- block htmltitle -%}
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ super() }}
{%- endblock -%}
{%- block linktags -%}
{% for code, url in language_codes %}
<link rel="alternate" hreflang="{{ code }}" href="{{ url }}" />

View File

@ -32,10 +32,6 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
html_subtitle = 'html_subtitle'
# <meta> tags
meta = [
'<meta http-equiv="X-UA-Compatible" content="IE=edge">',
'<meta name="viewport" content="width=device-width, initial-scale=1">'
]
def __init__(self, builder, document):
# order of parameter swapped between Sphinx 1.x and 2.x, check if
@ -45,6 +41,11 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
super(BootstrapTranslator, self).__init__(document)
self.builder = builder
self.meta = [
'', '',
'\n <meta http-equiv="X-UA-Compatible" content="IE=edge">',
'\n <meta name="viewport" content="width=device-width, initial-scale=1">'
]
self.body = []
self.fragment = self.body
self.html_body = self.body
@ -74,6 +75,9 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
0xa0: u'&nbsp;'
})
def add_meta(self, meta):
self.meta.append('\n ' + meta)
def starttag(self, node, tagname, **attributes):
tagname = tagname.lower()
@ -130,6 +134,14 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
def depart_document(self, node):
pass
def visit_meta(self, node):
if node.hasattr('lang'):
node['xml:lang'] = node['lang']
meta = self.starttag(node, 'meta', **node.non_default_attributes())
self.add_meta(meta)
def depart_meta(self, node):
pass
def visit_section(self, node):
# close "parent" or preceding section, unless this is the opening of
# the first section