From 5cca4d2fadf050d7bc65ab6f73f634578db26ffb Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Wed, 31 Oct 2018 19:32:49 +0100 Subject: [PATCH 1/2] Add some CSS for HTML tables (e.g. Pandas dataframes) Fixes #182. --- src/nbsphinx.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/nbsphinx.py b/src/nbsphinx.py index f4540fdf..cc75c0fb 100644 --- a/src/nbsphinx.py +++ b/src/nbsphinx.py @@ -156,6 +156,7 @@ {{ output.data['text/latex'] | indent | indent }} {%- elif datatype == 'text/html' %} + :class: rendered_html .. raw:: html @@ -556,6 +557,40 @@ .ansi-bold { font-weight: bold; } .ansi-underline { text-decoration: underline; } + +/* Some additional styling taken form the Jupyter notebook CSS */ +.rendered_html table { + border: none; + border-collapse: collapse; + border-spacing: 0; + color: black; + font-size: 12px; + table-layout: fixed; +} +.rendered_html thead { + border-bottom: 1px solid black; + vertical-align: bottom; +} +.rendered_html tr, +.rendered_html th, +.rendered_html td { + text-align: right; + vertical-align: middle; + padding: 0.5em 0.5em; + line-height: normal; + white-space: normal; + max-width: none; + border: none; +} +.rendered_html th { + font-weight: bold; +} +.rendered_html tbody tr:nth-child(odd) { + background: #f5f5f5; +} +.rendered_html tbody tr:hover { + background: rgba(66, 165, 245, 0.2); +} """ CSS_STRING_READTHEDOCS = """ From a55178464f950680757ea5f6d5485e644e888045 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Fri, 2 Nov 2018 16:29:36 +0100 Subject: [PATCH 2/2] Make notebook CSS more specific in order to overrule Sphinx CSS --- src/nbsphinx.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nbsphinx.py b/src/nbsphinx.py index cc75c0fb..0e77a063 100644 --- a/src/nbsphinx.py +++ b/src/nbsphinx.py @@ -559,7 +559,7 @@ .ansi-underline { text-decoration: underline; } /* Some additional styling taken form the Jupyter notebook CSS */ -.rendered_html table { +div.rendered_html table { border: none; border-collapse: collapse; border-spacing: 0; @@ -567,13 +567,13 @@ font-size: 12px; table-layout: fixed; } -.rendered_html thead { +div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } -.rendered_html tr, -.rendered_html th, -.rendered_html td { +div.rendered_html tr, +div.rendered_html th, +div.rendered_html td { text-align: right; vertical-align: middle; padding: 0.5em 0.5em; @@ -582,13 +582,13 @@ max-width: none; border: none; } -.rendered_html th { +div.rendered_html th { font-weight: bold; } -.rendered_html tbody tr:nth-child(odd) { +div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } -.rendered_html tbody tr:hover { +div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } """