diff --git a/CHANGES b/CHANGES index d6f1d3f..1164bac 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes ======= +1.2.0 (*2020-06-??*) +==================== + +- Compatibility with inline line numbering + 1.1.2 (*2020-06-21*) ==================== diff --git a/code.less b/code.less new file mode 100644 index 0000000..192af2a --- /dev/null +++ b/code.less @@ -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"; +} diff --git a/package.json b/package.json index 6ec13c9..926053c 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/setup.py b/setup.py index 8cad011..6ecf23d 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/sphinx_nervproject_theme/__init__.py b/sphinx_nervproject_theme/__init__.py index 88c8a6d..da42b41 100644 --- a/sphinx_nervproject_theme/__init__.py +++ b/sphinx_nervproject_theme/__init__.py @@ -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) diff --git a/ui/config.less b/ui/config.less index 1a20fec..dde1c0e 100644 --- a/ui/config.less +++ b/ui/config.less @@ -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; diff --git a/ui/print.less b/ui/print.less index daf6674..f586d6b 100644 --- a/ui/print.less +++ b/ui/print.less @@ -11,6 +11,9 @@ .no-print { display: none; } + .no-columns { + column-span: all; + } main.content { width: 100%; diff --git a/ui/theme-epub.less b/ui/theme-epub.less index 62edf98..a5589bd 100644 --- a/ui/theme-epub.less +++ b/ui/theme-epub.less @@ -114,6 +114,9 @@ @CdTClr: @baseCdTClr; @CdLClr: @baseCdLClr; @CdLHClr: @baseCdLHClr; +@CdLnTClr: @baseCdLnTClr; +@CdLnBClr: @baseCdLnBClr; +@CdLnBgClr: @baseCdLnBgClr; @PrAClr: @basePrAClr; diff --git a/ui/theme-weasyprint.less b/ui/theme-weasyprint.less index 5fd040b..4a5ff4a 100644 --- a/ui/theme-weasyprint.less +++ b/ui/theme-weasyprint.less @@ -114,6 +114,9 @@ @CdTClr: @printBaseCdTClr; @CdLClr: @printBaseCdLClr; @CdLHClr: @printBaseCdLHClr; +@CdLnTClr: @printBaseCdLnTClr; +@CdLnBClr: @printBaseCdLnBClr; +@CdLnBgClr: @printBaseCdLnBgClr; @PrAClr: @printBasePrAClr; diff --git a/ui/theme.less b/ui/theme.less index bf2679d..31179ab 100644 --- a/ui/theme.less +++ b/ui/theme.less @@ -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);