fix #2762: change html template for xhtml validation error (for epub)

This commit is contained in:
Yoshiki Shibukawa 2017-04-21 12:48:25 +09:00
parent 868bb4b2a9
commit 76ff2c0135
2 changed files with 17 additions and 0 deletions

View File

@ -47,6 +47,11 @@ THEME_WRITING_MODES = {
DOCTYPE = '''<!DOCTYPE html>''' DOCTYPE = '''<!DOCTYPE html>'''
HTML_TAG = (
u'<html xmlns="http://www.w3.org/1999/xhtml" '
u'xmlns:epub="http://www.idpf.org/2007/ops">'
)
class Epub3Builder(_epub_base.EpubBuilder): class Epub3Builder(_epub_base.EpubBuilder):
""" """
@ -60,6 +65,8 @@ class Epub3Builder(_epub_base.EpubBuilder):
template_dir = path.join(package_dir, 'templates', 'epub3') template_dir = path.join(package_dir, 'templates', 'epub3')
doctype = DOCTYPE doctype = DOCTYPE
html_tag = HTML_TAG
use_meta_charset = True
# Finish by building the epub file # Finish by building the epub file
def handle_finish(self): def handle_finish(self):
@ -134,6 +141,8 @@ class Epub3Builder(_epub_base.EpubBuilder):
writing_mode = self.config.epub_writing_mode writing_mode = self.config.epub_writing_mode
self.globalcontext['theme_writing_mode'] = THEME_WRITING_MODES.get(writing_mode) self.globalcontext['theme_writing_mode'] = THEME_WRITING_MODES.get(writing_mode)
self.globalcontext['html_tag'] = self.html_tag
self.globalcontext['use_meta_charset'] = self.use_meta_charset
def build_navlist(self, navnodes): def build_navlist(self, navnodes):
# type: (List[nodes.Node]) -> List[NavPoint] # type: (List[nodes.Node]) -> List[NavPoint]

View File

@ -110,9 +110,17 @@
{%- endfor %} {%- endfor %}
{%- endmacro %} {%- endmacro %}
{%- if html_tag %}
{{ html_tag }}
{%- else %}
<html xmlns="http://www.w3.org/1999/xhtml"{% if language is not none %} lang="{{ language }}"{% endif %}> <html xmlns="http://www.w3.org/1999/xhtml"{% if language is not none %} lang="{{ language }}"{% endif %}>
{%- endif %}
<head> <head>
{%- if use_meta_charset %}
<meta charset="{{ encoding }}" />
{%- else %}
<meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" /> <meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" />
{%- endif %}
{{ metatags }} {{ metatags }}
{%- block htmltitle %} {%- block htmltitle %}
<title>{{ title|striptags|e }}{{ titlesuffix }}</title> <title>{{ title|striptags|e }}{{ titlesuffix }}</title>