Fix: adapt to inline line numbering

This commit is contained in:
Kujiu 2020-06-22 14:57:19 +02:00
parent cf9a89b07b
commit a90025fcb3
Signed by: kujiu
GPG key ID: ABBB2CAC6855599F
10 changed files with 230 additions and 3 deletions

View file

@ -2,6 +2,11 @@
Changes
=======
1.2.0 (*2020-06-??*)
====================
- Compatibility with inline line numbering
1.1.2 (*2020-06-21*)
====================

179
code.less Normal file
View file

@ -0,0 +1,179 @@
pre {
white-space: pre-wrap;
overflow-wrap: break-word;
}
.content {
td.linenos, td.code {
border: none;
padding: 0;
margin: 0;
> .highlight pre {
border: none;
}
}
code {
color: @CdTClr;
padding: 0.25rem 0.1rem;
margin: 0;
font-size: 0.85em;
background-color: @CdBgClr;
border-bottom: @CdBClr solid 0.2em;
a, a:visited {
color: @CdLClr;
&:hover {
color: @CdLHClr;
}
}
}
td.linenos pre, pre span.lineno {
border-right: solid 0.3em @CdLnBClr;
background-color: @CdLnBgClr;
color: @CdLnTClr;
white-space: pre;
overflow-wrap: normal;
margin: 0;
}
pre span.lineno {
float: left;
margin: 0 0.5rem 0 -0.5rem;
padding-left: 0.5rem;
}
pre, pre[class*="language-"] {
line-height: 1.4;
padding: 1.25rem 1.5rem 1.25rem 0.5rem;
margin: 0.85rem 0;
background-color: @PrBgClr;
color: @PrTClr;
border-left: @PrBClr solid 0.5em;
code {
color: @PrTClr;
padding: 0;
background-color: transparent;
}
a, a:visited {
color: @PrLClr;
&:hover {
color: @PrLHClr;
}
}
}
}
div[class*="language-"] {
position: relative;
background-color: @CdBgClr;
.highlight-lines {
padding-top: 1.3rem;
width: 100%;
line-height: 1.4;
.highlighted {
background-color: @CdBgAClr;
color: @CdAClr;
}
}
pre, pre[class*="language-"] {
background: transparent;
position: relative;
z-index: 1;
}
&::before {
z-index: 3;
font-size: 0.75rem;
color: @CdT2Clr;
}
&:not(.line-numbers-mode) {
.line-numbers-wrapper {
display: none;
}
}
&.line-numbers-mode {
.highlight-lines {
.highlighted {
position: relative;
&:before {
content: ' ';
z-index: 3;
display: block;
width: @lineNumbersWrapperWidth;
height: 100%;
background-color: @CdBgAClr;
color: @CdBgClr;
}
}
}
pre {
padding-left: @lineNumbersWrapperWidth;
vertical-align: middle;
}
.line-numbers-wrapper {
width: @lineNumbersWrapperWidth;
text-align: center;
color: @PrLNClr;
padding: 1.25rem 0;
line-height: 1.4;
.line-number {
position: relative;
z-index: 4;
font-size: 0.85em;
}
}
&::after {
content: '';
z-index: 2;
width: @lineNumbersWrapperWidth;
height: 100%;
border-left: 0.5rem solid @PrB2Clr;
background-color: @PrBgClr;
}
}
}
//for lang in js ts html md vue css sass scss less stylus go java c sh yaml rst rust zsh gdscript esc
// div{'[class~="language-' + lang + '"]'}
// &:before
// content ('' + lang)
div[class~="language-javascript"] {
&:before {
content: "js";
}
}
div[class~="language-typescript"] {
&:before {
content: "ts";
}
}
div[class~="language-markup"] {
&:before {
content: "html";
}
}
div[class~="language-markdown"] {
&:before {
content: "md";
}
}
div[class~="language-json"]:before {
content: "json";
}
div[class~="language-ruby"]:before {
content: "rb";
}
div[class~="language-python"]:before {
content: "py";
}
div[class~="language-bash"]:before {
content: "sh";
}

View file

@ -1,6 +1,6 @@
{
"name": "sphinx_nervproject_theme",
"version": "1.1.2",
"version": "1.2.0",
"description": "Sphinx Nerv Project Theme",
"main": "index.js",
"directories": {

View file

@ -28,7 +28,7 @@ with open("README.rst", "r") as fh:
setup(
name="sphinx_nervproject_theme",
version="1.1.2",
version="1.2.0",
url="https://procrastinator.nerv-project.eu/nerv-project/communication/sphinx_nervproject_theme",
license="EUPL 1.2",
author="Kujiu",

View file

@ -6,7 +6,7 @@ from sphinx.environment.collectors import EnvironmentCollector
from sphinx import addnodes
from sphinx.util.osutil import relative_uri
__version__ = (1, 1, 2)
__version__ = (1, 2, 0)
sys.setrecursionlimit(15000)

View file

@ -36,6 +36,7 @@ Bh: ButtonHover
Bq: Blockquote
Btn: Button
Cd: Code
CdLn: Code line column
Fo: Footer
In: Input
Pr: Pre
@ -156,6 +157,9 @@ Nv: Navbar
@baseCdT2Clr: hsla(211, 29%, 27%, 0.4);
@baseCdLClr: @baseAaLClr;
@baseCdLHClr: @baseAaLHClr;
@baseCdLnTClr: @baseFoTClr;
@baseCdLnBClr: @baseFoBClr;
@baseCdLnBgClr: @baseFoBgClr;
@basePrAClr: @baseCdAClr;
@ -327,6 +331,9 @@ Nv: Navbar
@highContrastBaseCdT2Clr: hsla(206, 99%, 2%, 0.4);
@highContrastBaseCdLClr: @highContrastBaseAaLClr;
@highContrastBaseCdLHClr: @highContrastBaseAaLHClr;
@highContrastBaseCdLnTClr: @highContrastBaseFoTClr;
@highContrastBaseCdLnBClr: @highContrastBaseFoBClr;
@highContrastBaseCdLnBgClr: @highContrastBaseFoBgClr;
@highContrastBasePrAClr: @highContrastBaseCdAClr;
@ -497,6 +504,9 @@ Nv: Navbar
@darkBaseCdT2Clr: hsla(206, 99%, 90%, 0.4);
@darkBaseCdLClr: @darkBaseAaLClr;
@darkBaseCdLHClr: @darkBaseAaLHClr;
@darkBaseCdLnTClr: @darkBaseFoTClr;
@darkBaseCdLnBClr: @darkBaseFoBClr;
@darkBaseCdLnBgClr: @darkBaseFoBgClr;
@darkBasePrAClr: @darkBaseCdAClr;
@darkBasePrBgAClr: @darkBaseCdBgAClr;
@ -666,6 +676,9 @@ Nv: Navbar
@darkHighContrastBaseCdT2Clr: hsla(211, 29%, 98%, 0.4);
@darkHighContrastBaseCdLClr: @darkHighContrastBaseAaLClr;
@darkHighContrastBaseCdLHClr: @darkHighContrastBaseAaLHClr;
@darkHighContrastBaseCdLnTClr: @darkHighContrastBaseFoTClr;
@darkHighContrastBaseCdLnBClr: @darkHighContrastBaseFoBClr;
@darkHighContrastBaseCdLnBgClr: @darkHighContrastBaseFoBgClr;
@darkHighContrastBasePrAClr: @darkHighContrastBaseCdAClr;
@darkHighContrastBasePrBgAClr: @darkHighContrastBaseCdBgAClr;
@ -836,6 +849,9 @@ Nv: Navbar
@printBaseCdT2Clr: @baseCdT2Clr;
@printBaseCdLClr: @printBaseAaLClr;
@printBaseCdLHClr: @printBaseAaLHClr;
@printBaseCdLnTClr: @printBaseFoTClr;
@printBaseCdLnBClr: @printBaseFoBClr;
@printBaseCdLnBgClr: @printBaseFoBgClr;
@printBasePrAClr: @printBaseCdAClr;

View file

@ -11,6 +11,9 @@
.no-print {
display: none;
}
.no-columns {
column-span: all;
}
main.content {
width: 100%;

View file

@ -114,6 +114,9 @@
@CdTClr: @baseCdTClr;
@CdLClr: @baseCdLClr;
@CdLHClr: @baseCdLHClr;
@CdLnTClr: @baseCdLnTClr;
@CdLnBClr: @baseCdLnBClr;
@CdLnBgClr: @baseCdLnBgClr;
@PrAClr: @basePrAClr;

View file

@ -114,6 +114,9 @@
@CdTClr: @printBaseCdTClr;
@CdLClr: @printBaseCdLClr;
@CdLHClr: @printBaseCdLHClr;
@CdLnTClr: @printBaseCdLnTClr;
@CdLnBClr: @printBaseCdLnBClr;
@CdLnBgClr: @printBaseCdLnBgClr;
@PrAClr: @printBasePrAClr;

View file

@ -120,6 +120,9 @@
--CdTClr: @baseCdTClr;
--CdLClr: @baseCdLClr;
--CdLHClr: @baseCdLHClr;
--CdLnTClr: @baseCdLnTClr;
--CdLnBClr: @baseCdLnBClr;
--CdLnBgClr: @baseCdLnBgClr;
--PrAClr: @basePrAClr;
@ -295,6 +298,9 @@
--CdTClr: @highContrastBaseCdTClr;
--CdLClr: @highContrastBaseCdLClr;
--CdLHClr: @highContrastBaseCdLHClr;
--CdLnTClr: @highContrastBaseCdLnTClr;
--CdLnBClr: @highContrastBaseCdLnBClr;
--CdLnBgClr: @highContrastBaseCdLnBgClr;
--PrAClr: @highContrastBasePrAClr;
@ -471,6 +477,9 @@
--CdTClr: @darkBaseCdTClr;
--CdLClr: @darkBaseCdLClr;
--CdLHClr: @darkBaseCdLHClr;
--CdLnTClr: @darkBaseCdLnTClr;
--CdLnBClr: @darkBaseCdLnBClr;
--CdLnBgClr: @darkBaseCdLnBgClr;
--PrAClr: @darkBasePrAClr;
@ -646,6 +655,9 @@
--CdTClr: @darkHighContrastBaseCdTClr;
--CdLClr: @darkHighContrastBaseCdLClr;
--CdLHClr: @darkHighContrastBaseCdLHClr;
--CdLnTClr: @darkHighContrastBaseCdLnTClr;
--CdLnBClr: @darkHighContrastBaseCdLnBClr;
--CdLnBgClr: @darkHighContrastBaseCdLnBgClr;
--PrAClr: @darkHighContrastBasePrAClr;
@ -823,6 +835,9 @@
--CdTClr: @printBaseCdTClr !important;
--CdLClr: @printBaseCdLClr !important;
--CdLHClr: @printBaseCdLHClr !important;
--CdLnTClr: @printBaseCdLnTClr !important;
--CdLnBClr: @printBaseCdLnBClr !important;
--CdLnBgClr: @printBaseCdLnBgClr !important;
--PrAClr: @printBasePrAClr !important;
@ -1002,6 +1017,9 @@
@CdTClr: var(--CdTClr);
@CdLClr: var(--CdLClr);
@CdLHClr: var(--CdLHClr);
@CdLnTClr: var(--CdLnTClr);
@CdLnBClr: var(--CdLnBClr);
@CdLnBgClr: var(--CdLnBgClr);
@PrAClr: var(--PrAClr);