Add :confval:epub_css_files

This commit is contained in:
Takeshi KOMIYA
2018-02-11 23:14:54 +09:00
parent 5efecd2150
commit bd2967f1d2
4 changed files with 39 additions and 1 deletions

View File

@@ -59,7 +59,8 @@ Features added
* LaTeX: new key ``'fvset'`` for :confval:`latex_elements`. For
XeLaTeX/LuaLaTeX its default sets ``fanvyvrb`` to use normal, not small,
fontsize in code-blocks (refs: #4793)
* Add :confval:`html_css_files` for adding CSS files from configuration
* Add :confval:`html_css_files` and :confval:`epub_css_files` for adding CSS
files from configuration
Bugs fixed
----------

View File

@@ -1524,6 +1524,14 @@ the `Dublin Core metadata <http://dublincore.org/>`_.
.. versionadded:: 1.1
.. confval:: epub_css_files
A list of CSS files. The entry must be a *filename* string or a tuple
containing the *filename* string and the *attributes* dictionary. For more
information, see :confval:`html_css_files`.
.. versionadded:: 1.8
.. confval:: epub_guide
Meta data for the guide element of :file:`content.opf`. This is a

View File

@@ -247,6 +247,7 @@ def setup(app):
app.add_config_value('epub_guide', (), 'env')
app.add_config_value('epub_pre_files', [], 'env')
app.add_config_value('epub_post_files', [], 'env')
app.add_config_value('epub_css_files', lambda config: config.html_css_files, 'epub')
app.add_config_value('epub_exclude_files', [], 'env')
app.add_config_value('epub_tocdepth', 3, 'env')
app.add_config_value('epub_tocdup', True, 'env')

View File

@@ -317,6 +317,34 @@ def test_epub_writing_mode(app):
assert 'writing-mode: vertical-rl;' in css
@pytest.mark.sphinx('epub', testroot='html_assets')
def test_epub_assets(app):
app.builder.build_all()
# epub_sytlesheets (same as html_css_files)
content = (app.outdir / 'index.xhtml').text()
assert ('<link rel="stylesheet" type="text/css" href="_static/css/style.css" />'
in content)
assert ('<link media="print" rel="stylesheet" title="title" type="text/css" '
'href="https://example.com/custom.css" />' in content)
@pytest.mark.sphinx('epub', testroot='html_assets',
confoverrides={'epub_css_files': ['css/epub.css']})
def test_epub_css_files(app):
app.builder.build_all()
# epub_css_files
content = (app.outdir / 'index.xhtml').text()
assert '<link rel="stylesheet" type="text/css" href="_static/css/epub.css" />' in content
# files in html_css_files are not outputed
assert ('<link rel="stylesheet" type="text/css" href="_static/css/style.css" />'
not in content)
assert ('<link media="print" rel="stylesheet" title="title" type="text/css" '
'href="https://example.com/custom.css" />' not in content)
@pytest.mark.sphinx('epub')
def test_run_epubcheck(app):
app.build()