mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
parent
9916518fee
commit
06a861703d
@ -47,7 +47,7 @@ epub_fix_images = False
|
|||||||
epub_max_image_width = 0
|
epub_max_image_width = 0
|
||||||
epub_show_urls = 'inline'
|
epub_show_urls = 'inline'
|
||||||
epub_use_index = False
|
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',
|
latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
|
||||||
'Georg Brandl', 'manual', 1)]
|
'Georg Brandl', 'manual', 1)]
|
||||||
|
@ -113,7 +113,7 @@ COVER_TEMPLATE = u'''\
|
|||||||
<meta name="cover" content="%(cover)s"/>
|
<meta name="cover" content="%(cover)s"/>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
COVERPAGE_NAME = u'epub-cover.html'
|
COVERPAGE_NAME = u'epub-cover.xhtml'
|
||||||
|
|
||||||
FILE_TEMPLATE = u'''\
|
FILE_TEMPLATE = u'''\
|
||||||
<item id="%(id)s"
|
<item id="%(id)s"
|
||||||
@ -128,6 +128,10 @@ GUIDE_TEMPLATE = u'''\
|
|||||||
|
|
||||||
TOCTREE_TEMPLATE = u'toctree-l%d'
|
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]'
|
LINK_TARGET_TEMPLATE = u' [%(uri)s]'
|
||||||
|
|
||||||
FOOTNOTE_LABEL_TEMPLATE = u'#%d'
|
FOOTNOTE_LABEL_TEMPLATE = u'#%d'
|
||||||
@ -143,7 +147,7 @@ GUIDE_TITLES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MEDIA_TYPES = {
|
MEDIA_TYPES = {
|
||||||
'.html': 'application/xhtml+xml',
|
'.xhtml': 'application/xhtml+xml',
|
||||||
'.css': 'text/css',
|
'.css': 'text/css',
|
||||||
'.png': 'image/png',
|
'.png': 'image/png',
|
||||||
'.gif': 'image/gif',
|
'.gif': 'image/gif',
|
||||||
@ -198,6 +202,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
spine_template = SPINE_TEMPLATE
|
spine_template = SPINE_TEMPLATE
|
||||||
guide_template = GUIDE_TEMPLATE
|
guide_template = GUIDE_TEMPLATE
|
||||||
toctree_template = TOCTREE_TEMPLATE
|
toctree_template = TOCTREE_TEMPLATE
|
||||||
|
doctype = DOCTYPE
|
||||||
link_target_template = LINK_TARGET_TEMPLATE
|
link_target_template = LINK_TARGET_TEMPLATE
|
||||||
css_link_target_class = CSS_LINK_TARGET_CLASS
|
css_link_target_class = CSS_LINK_TARGET_CLASS
|
||||||
guide_titles = GUIDE_TITLES
|
guide_titles = GUIDE_TITLES
|
||||||
@ -207,7 +212,8 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
def init(self):
|
def init(self):
|
||||||
StandaloneHTMLBuilder.init(self)
|
StandaloneHTMLBuilder.init(self)
|
||||||
# the output files for epub must be .html only
|
# 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.playorder = 0
|
||||||
self.tocid = 0
|
self.tocid = 0
|
||||||
|
|
||||||
@ -277,7 +283,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
"""
|
"""
|
||||||
refnodes.insert(0, {
|
refnodes.insert(0, {
|
||||||
'level': 1,
|
'level': 1,
|
||||||
'refuri': self.esc(self.config.master_doc + '.html'),
|
'refuri': self.esc(self.config.master_doc + self.out_suffix),
|
||||||
'text': ssp(self.esc(
|
'text': ssp(self.esc(
|
||||||
self.env.titles[self.config.master_doc].astext()))
|
self.env.titles[self.config.master_doc].astext()))
|
||||||
})
|
})
|
||||||
@ -481,6 +487,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
"""
|
"""
|
||||||
if pagename.startswith('genindex'):
|
if pagename.startswith('genindex'):
|
||||||
self.fix_genindex(addctx['genindexentries'])
|
self.fix_genindex(addctx['genindexentries'])
|
||||||
|
addctx['doctype'] = self.doctype
|
||||||
StandaloneHTMLBuilder.handle_page(self, pagename, addctx, templatename,
|
StandaloneHTMLBuilder.handle_page(self, pagename, addctx, templatename,
|
||||||
outfilename, event_arg)
|
outfilename, event_arg)
|
||||||
|
|
||||||
|
@ -82,6 +82,9 @@ PACKAGE_DOC_TEMPLATE = u'''\
|
|||||||
</package>
|
</package>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
DOCTYPE = u'''<!DOCTYPE html>
|
||||||
|
'''
|
||||||
|
|
||||||
# The epub3 publisher
|
# The epub3 publisher
|
||||||
|
|
||||||
|
|
||||||
@ -99,6 +102,7 @@ class Epub3Builder(EpubBuilder):
|
|||||||
navlist_template = NAVLIST_TEMPLATE
|
navlist_template = NAVLIST_TEMPLATE
|
||||||
navlist_indent = NAVLIST_INDENT
|
navlist_indent = NAVLIST_INDENT
|
||||||
content_template = PACKAGE_DOC_TEMPLATE
|
content_template = PACKAGE_DOC_TEMPLATE
|
||||||
|
doctype = DOCTYPE
|
||||||
|
|
||||||
# Finish by building the epub file
|
# Finish by building the epub file
|
||||||
def handle_finish(self):
|
def handle_finish(self):
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
{%- extends "basic/layout.html" %}
|
{%- extends "basic/layout.html" %}
|
||||||
|
|
||||||
{%- block doctype -%}
|
{%- block doctype -%}
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
{{ doctype }}
|
||||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
{%- endblock -%}
|
{%- endblock -%}
|
||||||
{# add only basic navigation links #}
|
{# add only basic navigation links #}
|
||||||
{% block sidebar1 %}{% endblock %}
|
{% block sidebar1 %}{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user