From 90c861d7f366972d04470ac4f65669f36e8ca3be Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Tue, 14 Apr 2020 17:59:33 +0200 Subject: [PATCH 1/2] basic theme: CSS spacing for code blocks with captions and line numbers --- sphinx/themes/basic/static/basic.css_t | 39 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index e72db1249..08a3ad980 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -645,21 +645,47 @@ span.pre { } td.linenos pre { - padding: 5px 0px; border: 0; background-color: transparent; color: #aaa; } table.highlighttable { - margin-left: 0.5em; + display: block; + margin: 1em 0; +} + +table.highlighttable tbody { + display: block; +} + +table.highlighttable tr { + display: flex; } table.highlighttable td { - padding: 0 0.5em 0 0.5em; + margin: 0; + padding: 0; +} + +table.highlighttable td.linenos { + padding: 0 0.5em; +} + +table.highlighttable td.code { + overflow: hidden; +} + +table.highlighttable pre { + margin: 0; +} + +div.code-block-caption + div > table.highlighttable { + margin-top: 0; } div.code-block-caption { + margin-top: 1em; padding: 2px 5px; font-size: small; } @@ -672,6 +698,7 @@ div.code-block-caption + div > div.highlight > pre { margin-top: 0; } +table.highlighttable td.linenos, div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */ user-select: none; } @@ -685,11 +712,7 @@ div.code-block-caption span.caption-text { } div.literal-block-wrapper { - padding: 1em 1em 0; -} - -div.literal-block-wrapper div.highlight { - margin: 0; + margin: 1em 0; } code.descname { From c795793d41d7ae0d13f2ab4ab5acf95f0e6551ec Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Tue, 14 Apr 2020 19:20:06 +0200 Subject: [PATCH 2/2] FIXUP: code blocks: full-width highlighted lines --- sphinx/themes/basic/static/basic.css_t | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index 08a3ad980..72864bffd 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -673,9 +673,14 @@ table.highlighttable td.linenos { } table.highlighttable td.code { + flex: 1; overflow: hidden; } +.highlight .hll { + display: block; +} + table.highlighttable pre { margin: 0; }