-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from attakei/feature/footnotes
Add optional-extension `sphinx_revealjs.ext.footnotes`
- Loading branch information
Showing
9 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
============================= | ||
sphinx_revealjs.ext.footnotes | ||
============================= | ||
|
||
:Added: v2.8.0 | ||
|
||
Overview | ||
======== | ||
|
||
This extension updates position of footnotes. | ||
|
||
Installation | ||
============ | ||
|
||
You need not install extra, you can use it immediately after installing |THIS|. | ||
|
||
Usage | ||
===== | ||
|
||
WHen adding extension into your ``conf.py``, insert CSS file to customize layout of footnotes. | ||
|
||
Example | ||
------- | ||
|
||
.. code-block:: python | ||
:caption: conf.py | ||
extensions = [ | ||
"sphinx_revealjs", | ||
"sphinx_revealjs.ext.footnotes", | ||
] | ||
.. code-block:: rst | ||
:caption: sample-slide.rst | ||
Sample title | ||
============ | ||
This sentence has footnotes [#f1]_ | ||
.. [#f1] This is footnote. | ||
Configuration | ||
============= | ||
|
||
All Configuration names are prefixed ``revealjs_footnotes_``. | ||
|
||
.. confval:: revealjs_footnotes_font_size | ||
|
||
:Type: ``str`` | ||
:Default: ``50%`` | ||
:Example: ``60%`` | ||
|
||
Font-size of rendered footnote contents. | ||
|
||
.. confval:: revealjs_footnotes_ref_font_size | ||
|
||
:Type: ``str`` | ||
:Default: ``70%`` | ||
:Example: ``60%`` | ||
|
||
Font-size of rendered footnote's referer text. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Extension to add custom CSS for footnotes.""" | ||
from pathlib import Path | ||
|
||
from sphinx.application import Sphinx | ||
from sphinx.util.logging import getLogger | ||
|
||
from ... import __version__ as core_version | ||
from ...builders import RevealjsHTMLBuilder | ||
|
||
here = Path(__file__).parent | ||
logger = getLogger(__name__) | ||
|
||
|
||
def register_extra_static_path(app: Sphinx): | ||
if not isinstance(app.builder, RevealjsHTMLBuilder): | ||
return | ||
app.builder.config.revealjs_static_path.append(str(here / "static")) | ||
app.builder.add_css_file("sphinx-revealjs/css/footnotes.css") | ||
|
||
|
||
def register_css_context(app: Sphinx, ctx: dict): | ||
"""Inject config values into builder's globalcontext.""" | ||
ctx.setdefault( | ||
"revealjs_footnotes", | ||
{ | ||
"font_size": app.config.revealjs_footnotes_font_size, | ||
"ref_font_size": app.config.revealjs_footnotes_ref_font_size, | ||
}, | ||
) | ||
|
||
|
||
def setup(app: Sphinx): | ||
"""Entryoint.""" | ||
app.add_config_value("revealjs_footnotes_font_size", "50%", "env") | ||
app.add_config_value("revealjs_footnotes_ref_font_size", "70%", "env") | ||
app.connect("builder-inited", register_extra_static_path) | ||
app.connect("revealjs:ready-for-writing", register_css_context) | ||
return { | ||
"version": core_version, | ||
"env_version": 1, | ||
"parallel_read_safe": True, | ||
"parallel_write_safe": True, | ||
} |
22 changes: 22 additions & 0 deletions
22
sphinx_revealjs/ext/footnotes/static/sphinx-revealjs/css/footnotes.css_t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Customize layout of footnotes. | ||
*/ | ||
a.footnote-reference { | ||
font-size: {{ revealjs_footnotes.ref_font_size }}; | ||
vertical-align: top; | ||
} | ||
|
||
aside.footnote-list { | ||
position: fixed; | ||
bottom: 0; | ||
font-size: {{ revealjs_footnotes.font_size }}; | ||
width: 100%; | ||
} | ||
|
||
aside.footnote > span { | ||
float: left; | ||
} | ||
aside.footnote p { | ||
text-align: left; | ||
padding-left: 2rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
================= | ||
Test presentation | ||
================= | ||
|
||
Section 1 | ||
========= | ||
|
||
Sub 1-1 | ||
------- | ||
|
||
First content | ||
|
||
Sub 1-2 | ||
------- | ||
|
||
Second content [#f1]_ | ||
|
||
.. [#f1] This is footnote (rendered left-bottom of layout using sphinx.revealjs.footnotes ). | ||
Section 2 | ||
========= | ||
|
||
Sub 2-1 | ||
------- | ||
|
||
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Test cases for sphix_revealjs.ext.footnotes.""" | ||
import pytest | ||
from sphinx.testing.util import SphinxTestApp | ||
|
||
|
||
@pytest.mark.sphinx( | ||
"revealjs", | ||
testroot="default", | ||
confoverrides={ | ||
"extensions": ["sphinx_revealjs", "sphinx_revealjs.ext.footnotes"], | ||
}, | ||
) | ||
def test_skip_included(app: SphinxTestApp, status, warning): # noqa | ||
app.build() | ||
css_path = app.outdir / "_static/sphinx-revealjs/css/footnotes.css" | ||
assert css_path.exists() | ||
|
||
|
||
@pytest.mark.sphinx( | ||
"dirrevealjs", | ||
testroot="default", | ||
freshenv=True, | ||
confoverrides={ | ||
"extensions": ["sphinx_revealjs", "sphinx_revealjs.ext.footnotes"], | ||
}, | ||
) | ||
def test_dirrevealjs(app: SphinxTestApp, status, warning): # noqa | ||
app.build() | ||
css_path = app.outdir / "_static/sphinx-revealjs/css/footnotes.css" | ||
assert css_path.exists() |