Reduce epub checker warnings/errors for epub3 builder.

Fix DOCTYPE to html5 and change extension from .html to .xhtml.

Sphinx's documents result:

  before: 95 warnings& 1238 errors
  after: 623 errors
This commit is contained in:
Yoshiki Shibukawa 2016-07-17 09:53:04 +09:00
parent 9916518fee
commit 06a861703d
4 changed files with 17 additions and 7 deletions

View File

@ -47,7 +47,7 @@ epub_fix_images = False
epub_max_image_width = 0
epub_show_urls = 'inline'
epub_use_index = False
epub_guide = (('toc', 'contents.html', u'Table of Contents'),)
epub_guide = (('toc', 'contents.xhtml', u'Table of Contents'),)
latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
'Georg Brandl', 'manual', 1)]

View File

@ -113,7 +113,7 @@ COVER_TEMPLATE = u'''\
<meta name="cover" content="%(cover)s"/>
'''
COVERPAGE_NAME = u'epub-cover.html'
COVERPAGE_NAME = u'epub-cover.xhtml'
FILE_TEMPLATE = u'''\
<item id="%(id)s"
@ -128,6 +128,10 @@ GUIDE_TEMPLATE = u'''\
TOCTREE_TEMPLATE = u'toctree-l%d'
DOCTYPE = u'''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
'''
LINK_TARGET_TEMPLATE = u' [%(uri)s]'
FOOTNOTE_LABEL_TEMPLATE = u'#%d'
@ -143,7 +147,7 @@ GUIDE_TITLES = {
}
MEDIA_TYPES = {
'.html': 'application/xhtml+xml',
'.xhtml': 'application/xhtml+xml',
'.css': 'text/css',
'.png': 'image/png',
'.gif': 'image/gif',
@ -198,6 +202,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
spine_template = SPINE_TEMPLATE
guide_template = GUIDE_TEMPLATE
toctree_template = TOCTREE_TEMPLATE
doctype = DOCTYPE
link_target_template = LINK_TARGET_TEMPLATE
css_link_target_class = CSS_LINK_TARGET_CLASS
guide_titles = GUIDE_TITLES
@ -207,7 +212,8 @@ class EpubBuilder(StandaloneHTMLBuilder):
def init(self):
StandaloneHTMLBuilder.init(self)
# the output files for epub must be .html only
self.out_suffix = '.html'
self.out_suffix = '.xhtml'
self.link_suffix = '.xhtml'
self.playorder = 0
self.tocid = 0
@ -277,7 +283,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
"""
refnodes.insert(0, {
'level': 1,
'refuri': self.esc(self.config.master_doc + '.html'),
'refuri': self.esc(self.config.master_doc + self.out_suffix),
'text': ssp(self.esc(
self.env.titles[self.config.master_doc].astext()))
})
@ -481,6 +487,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
"""
if pagename.startswith('genindex'):
self.fix_genindex(addctx['genindexentries'])
addctx['doctype'] = self.doctype
StandaloneHTMLBuilder.handle_page(self, pagename, addctx, templatename,
outfilename, event_arg)

View File

@ -82,6 +82,9 @@ PACKAGE_DOC_TEMPLATE = u'''\
</package>
'''
DOCTYPE = u'''<!DOCTYPE html>
'''
# The epub3 publisher
@ -99,6 +102,7 @@ class Epub3Builder(EpubBuilder):
navlist_template = NAVLIST_TEMPLATE
navlist_indent = NAVLIST_INDENT
content_template = PACKAGE_DOC_TEMPLATE
doctype = DOCTYPE
# Finish by building the epub file
def handle_finish(self):

View File

@ -10,8 +10,7 @@
{%- extends "basic/layout.html" %}
{%- block doctype -%}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
{{ doctype }}
{%- endblock -%}
{# add only basic navigation links #}
{% block sidebar1 %}{% endblock %}