2016-09-04 17:11:58 +02:00
|
|
|
////
|
2020-02-10 12:34:58 +01:00
|
|
|
/// Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
|
2016-09-04 17:11:58 +02:00
|
|
|
///
|
|
|
|
/// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
/// copy of this software and associated documentation files (the "Software"),
|
|
|
|
/// to deal in the Software without restriction, including without limitation
|
|
|
|
/// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
/// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
/// Software is furnished to do so, subject to the following conditions:
|
|
|
|
///
|
|
|
|
/// The above copyright notice and this permission notice shall be included in
|
|
|
|
/// all copies or substantial portions of the Software.
|
|
|
|
///
|
|
|
|
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
/// DEALINGS
|
|
|
|
////
|
|
|
|
|
2016-10-21 21:15:35 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Variables
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2016-10-30 10:36:18 +01:00
|
|
|
// Operators
|
|
|
|
$codehilite-operator: inherit;
|
|
|
|
$codehilite-operator-word: inherit;
|
|
|
|
|
|
|
|
// Generics
|
|
|
|
$codehilite-generic-emph: #000000;
|
|
|
|
$codehilite-generic-error: #AA0000;
|
|
|
|
$codehilite-generic-heading: #999999;
|
|
|
|
$codehilite-generic-output: #888888;
|
|
|
|
$codehilite-generic-prompt: #555555;
|
|
|
|
$codehilite-generic-strong: inherit;
|
|
|
|
$codehilite-generic-subheading: #AAAAAA;
|
|
|
|
$codehilite-generic-traceback: #AA0000;
|
|
|
|
|
|
|
|
// Diffs
|
|
|
|
$codehilite-diff-deleted: #FFDDDD;
|
|
|
|
$codehilite-diff-inserted: #DDFFDD;
|
|
|
|
|
2016-10-21 21:15:35 +02:00
|
|
|
// Keywords
|
|
|
|
$codehilite-keyword: #3B78E7;
|
2016-10-30 10:36:18 +01:00
|
|
|
$codehilite-keyword-constant: #A71D5D;
|
2016-10-21 21:15:35 +02:00
|
|
|
$codehilite-keyword-declaration: #3B78E7;
|
|
|
|
$codehilite-keyword-namespace: #3B78E7;
|
2016-10-30 10:36:18 +01:00
|
|
|
$codehilite-keyword-pseudo: #A71D5D;
|
2016-10-21 21:15:35 +02:00
|
|
|
$codehilite-keyword-reserved: #3E61A2;
|
|
|
|
$codehilite-keyword-type: #3E61A2;
|
|
|
|
|
|
|
|
// Comments
|
|
|
|
$codehilite-comment: #999999;
|
|
|
|
$codehilite-comment-multiline: #999999;
|
|
|
|
$codehilite-comment-preproc: #666666;
|
|
|
|
$codehilite-comment-single: #999999;
|
2016-10-30 10:36:18 +01:00
|
|
|
$codehilite-comment-shebang: #999999;
|
2016-10-21 21:15:35 +02:00
|
|
|
$codehilite-comment-special: #999999;
|
|
|
|
|
|
|
|
// Names
|
|
|
|
$codehilite-name-attribute: #C2185B;
|
|
|
|
$codehilite-name-builtin: #C2185B;
|
|
|
|
$codehilite-name-builtin-pseudo: #3E61A2;
|
|
|
|
$codehilite-name-class: #C2185B;
|
|
|
|
$codehilite-name-constant: #3E61A2;
|
|
|
|
$codehilite-name-decorator: #666666;
|
|
|
|
$codehilite-name-entity: #666666;
|
|
|
|
$codehilite-name-exception: #C2185B;
|
|
|
|
$codehilite-name-function: #C2185B;
|
|
|
|
$codehilite-name-label: #3B5179;
|
|
|
|
$codehilite-name-namespace: #EC407A;
|
|
|
|
$codehilite-name-tag: #3B78E7;
|
|
|
|
$codehilite-name-variable: #3E61A2;
|
|
|
|
$codehilite-name-variable-class: #3E61A2;
|
|
|
|
$codehilite-name-variable-instance: #3E61A2;
|
|
|
|
$codehilite-name-variable-global: #3E61A2;
|
|
|
|
$codehilite-name-extension: #EC407A;
|
|
|
|
|
|
|
|
// Numbers
|
|
|
|
$codehilite-literal-number: #E74C3C;
|
|
|
|
$codehilite-literal-number-float: #E74C3C;
|
|
|
|
$codehilite-literal-number-hex: #E74C3C;
|
|
|
|
$codehilite-literal-number-integer: #E74C3C;
|
|
|
|
$codehilite-literal-number-integer-long: #E74C3C;
|
|
|
|
$codehilite-literal-number-oct: #E74C3C;
|
|
|
|
|
2016-10-30 10:36:18 +01:00
|
|
|
// Strings
|
|
|
|
$codehilite-literal-string: #0D904F;
|
|
|
|
$codehilite-literal-string-backticks: #0D904F;
|
|
|
|
$codehilite-literal-string-char: #0D904F;
|
|
|
|
$codehilite-literal-string-doc: #999999;
|
|
|
|
$codehilite-literal-string-double: #0D904F;
|
|
|
|
$codehilite-literal-string-escape: #183691;
|
|
|
|
$codehilite-literal-string-heredoc: #183691;
|
|
|
|
$codehilite-literal-string-interpol: #183691;
|
|
|
|
$codehilite-literal-string-other: #183691;
|
|
|
|
$codehilite-literal-string-regex: #009926;
|
|
|
|
$codehilite-literal-string-single: #0D904F;
|
|
|
|
$codehilite-literal-string-symbol: #0D904F;
|
|
|
|
|
|
|
|
// Miscellaneous
|
|
|
|
$codehilite-error: #A61717;
|
|
|
|
$codehilite-whitespace: transparent;
|
|
|
|
|
2016-09-04 17:32:12 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2016-10-30 11:02:18 +01:00
|
|
|
// Rules: syntax highlighting
|
2016-09-04 17:32:12 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2016-09-04 17:11:58 +02:00
|
|
|
|
2016-10-06 12:14:33 +02:00
|
|
|
// Codehilite extension
|
2016-10-30 11:02:18 +01:00
|
|
|
.codehilite {
|
2016-08-07 18:01:56 +02:00
|
|
|
|
2016-09-04 17:32:12 +02:00
|
|
|
// Operators
|
2017-01-01 15:59:44 +01:00
|
|
|
.o { color: $codehilite-operator; }
|
2016-10-30 10:36:18 +01:00
|
|
|
.ow { color: $codehilite-operator-word; }
|
2016-08-07 18:01:56 +02:00
|
|
|
|
2016-09-04 17:32:12 +02:00
|
|
|
// Generics
|
2016-10-30 10:36:18 +01:00
|
|
|
.ge { color: $codehilite-generic-emph; }
|
|
|
|
.gr { color: $codehilite-generic-error; }
|
|
|
|
.gh { color: $codehilite-generic-heading; }
|
|
|
|
.go { color: $codehilite-generic-output; }
|
|
|
|
.gp { color: $codehilite-generic-prompt; }
|
|
|
|
.gs { color: $codehilite-generic-strong; }
|
|
|
|
.gu { color: $codehilite-generic-subheading; }
|
|
|
|
.gt { color: $codehilite-generic-traceback; }
|
|
|
|
|
|
|
|
// Diffs
|
|
|
|
.gd { background-color: $codehilite-diff-deleted; }
|
|
|
|
.gi { background-color: $codehilite-diff-inserted; }
|
2016-09-04 17:32:12 +02:00
|
|
|
|
|
|
|
// Keywords
|
2016-10-21 21:15:35 +02:00
|
|
|
.k { color: $codehilite-keyword; }
|
2016-10-30 10:36:18 +01:00
|
|
|
.kc { color: $codehilite-keyword-constant; }
|
2016-10-21 21:15:35 +02:00
|
|
|
.kd { color: $codehilite-keyword-declaration; }
|
|
|
|
.kn { color: $codehilite-keyword-namespace; }
|
2016-10-30 10:36:18 +01:00
|
|
|
.kp { color: $codehilite-keyword-pseudo; }
|
2016-10-21 21:15:35 +02:00
|
|
|
.kr { color: $codehilite-keyword-reserved; }
|
|
|
|
.kt { color: $codehilite-keyword-type; }
|
2016-09-04 17:32:12 +02:00
|
|
|
|
|
|
|
// Comments
|
2016-10-21 21:15:35 +02:00
|
|
|
.c { color: $codehilite-comment; }
|
|
|
|
.cm { color: $codehilite-comment-multiline; }
|
|
|
|
.cp { color: $codehilite-comment-preproc; }
|
|
|
|
.c1 { color: $codehilite-comment-single; }
|
2016-10-30 10:36:18 +01:00
|
|
|
.ch { color: $codehilite-comment-shebang; }
|
2016-10-21 21:15:35 +02:00
|
|
|
.cs { color: $codehilite-comment-special; }
|
2016-09-04 17:32:12 +02:00
|
|
|
|
|
|
|
// Names
|
2016-10-21 21:15:35 +02:00
|
|
|
.na { color: $codehilite-name-attribute; }
|
|
|
|
.nb { color: $codehilite-name-builtin; }
|
|
|
|
.bp { color: $codehilite-name-builtin-pseudo; }
|
|
|
|
.nc { color: $codehilite-name-class; }
|
|
|
|
.no { color: $codehilite-name-constant; }
|
|
|
|
.nd { color: $codehilite-name-entity; }
|
|
|
|
.ni { color: $codehilite-name-entity; }
|
|
|
|
.ne { color: $codehilite-name-exception; }
|
|
|
|
.nf { color: $codehilite-name-function; }
|
|
|
|
.nl { color: $codehilite-name-label; }
|
|
|
|
.nn { color: $codehilite-name-namespace; }
|
|
|
|
.nt { color: $codehilite-name-tag; }
|
|
|
|
.nv { color: $codehilite-name-variable; }
|
|
|
|
.vc { color: $codehilite-name-variable-class; }
|
|
|
|
.vg { color: $codehilite-name-variable-global; }
|
|
|
|
.vi { color: $codehilite-name-variable-instance; }
|
|
|
|
.nx { color: $codehilite-name-extension; }
|
2016-09-04 17:32:12 +02:00
|
|
|
|
|
|
|
// Numbers
|
2016-10-21 21:15:35 +02:00
|
|
|
.m { color: $codehilite-literal-number; }
|
|
|
|
.mf { color: $codehilite-literal-number-float; }
|
|
|
|
.mh { color: $codehilite-literal-number-hex; }
|
|
|
|
.mi { color: $codehilite-literal-number-integer; }
|
|
|
|
.il { color: $codehilite-literal-number-integer-long; }
|
|
|
|
.mo { color: $codehilite-literal-number-oct; }
|
2016-09-04 17:32:12 +02:00
|
|
|
|
|
|
|
// Strings
|
2016-10-21 21:15:35 +02:00
|
|
|
.s { color: $codehilite-literal-string; }
|
|
|
|
.sb { color: $codehilite-literal-string-backticks; }
|
|
|
|
.sc { color: $codehilite-literal-string-char; }
|
|
|
|
.sd { color: $codehilite-literal-string-doc; }
|
|
|
|
.s2 { color: $codehilite-literal-string-double; }
|
2016-10-30 10:36:18 +01:00
|
|
|
.se { color: $codehilite-literal-string-escape; }
|
|
|
|
.sh { color: $codehilite-literal-string-heredoc; }
|
|
|
|
.si { color: $codehilite-literal-string-interpol; }
|
|
|
|
.sx { color: $codehilite-literal-string-other; }
|
|
|
|
.sr { color: $codehilite-literal-string-regex; }
|
2016-10-21 21:15:35 +02:00
|
|
|
.s1 { color: $codehilite-literal-string-single; }
|
|
|
|
.ss { color: $codehilite-literal-string-symbol; }
|
2016-09-04 17:32:12 +02:00
|
|
|
|
|
|
|
// Miscellaneous
|
2016-10-30 10:36:18 +01:00
|
|
|
.err { color: $codehilite-error; }
|
|
|
|
.w { color: $codehilite-whitespace; }
|
|
|
|
|
|
|
|
// Highlighted lines
|
|
|
|
.hll {
|
|
|
|
display: block;
|
2019-02-12 19:13:08 +01:00
|
|
|
margin: 0 px2rem(-12px);
|
|
|
|
padding: 0 px2rem(12px);
|
2016-12-17 12:53:24 +01:00
|
|
|
background-color: transparentize($clr-yellow-500, 0.5);
|
2016-10-30 10:36:18 +01:00
|
|
|
|
|
|
|
// [mobile -]: Stretch to whole width
|
|
|
|
@include break-to-device(mobile) {
|
2019-02-12 19:13:08 +01:00
|
|
|
margin: 0 px2rem(-16px);
|
|
|
|
padding: 0 px2rem(16px);
|
2016-10-30 10:36:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-30 11:02:18 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Rules: layout
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2016-11-02 19:21:14 +01:00
|
|
|
// Scoped in typesetted content to match specificity of regular content
|
2016-10-30 10:36:18 +01:00
|
|
|
.md-typeset {
|
|
|
|
|
|
|
|
// Block with line numbers
|
|
|
|
.codehilitetable {
|
|
|
|
display: block;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
// Set table elements to block layout, because otherwise the whole flexbox
|
|
|
|
// hacking won't work correctly
|
|
|
|
tbody,
|
|
|
|
td {
|
|
|
|
display: block;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need to use flexbox layout, because otherwise it's not possible to
|
|
|
|
// make the code container scroll while keeping the line numbers static
|
|
|
|
tr {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The pre tags are nested inside a table, so we need to remove the
|
|
|
|
// margin because it collapses below all the overflows
|
2020-02-10 12:34:58 +01:00
|
|
|
pre,
|
2016-10-30 10:36:18 +01:00
|
|
|
.linenodiv {
|
|
|
|
margin: 0;
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add spacing to line number container
|
|
|
|
.linenodiv {
|
2019-02-12 19:13:08 +01:00
|
|
|
padding: px2rem(10.5px) px2rem(12px);
|
2016-10-30 10:36:18 +01:00
|
|
|
}
|
|
|
|
|
2017-01-06 18:57:43 +01:00
|
|
|
// Disable user selection, so code can be easily copied without
|
2016-10-30 10:36:18 +01:00
|
|
|
// accidentally also copying the line numbers
|
|
|
|
.linenos {
|
|
|
|
color: $md-color-black--lighter;
|
2020-02-15 22:59:29 +01:00
|
|
|
box-shadow: inset 0 0 0 px2rem(1px) $md-code-background;
|
2016-10-30 10:36:18 +01:00
|
|
|
user-select: none;
|
|
|
|
|
|
|
|
// Reset spacings
|
|
|
|
pre {
|
2016-12-17 12:53:24 +01:00
|
|
|
background-color: transparent;
|
2016-10-30 10:36:18 +01:00
|
|
|
color: inherit;
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The table cell containing the code container wrapper and code should
|
|
|
|
// stretch horizontally to the remaining space
|
|
|
|
.code {
|
|
|
|
flex: 1;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-19 00:55:44 -07:00
|
|
|
[data-linenos] {
|
|
|
|
&::before {
|
|
|
|
display: inline-block;
|
|
|
|
position: sticky;
|
|
|
|
left: px2rem(-12px);
|
|
|
|
margin-right: px2rem(12px);
|
|
|
|
margin-left: px2rem(-12px);
|
|
|
|
padding-left: px2rem(12px);
|
|
|
|
border-right: px2rem(1px) solid $md-color-black--lightest;
|
|
|
|
background-color: $md-code-gutter;
|
|
|
|
color: $md-color-black--lighter;
|
|
|
|
content: attr(data-linenos);
|
|
|
|
user-select: none;
|
|
|
|
|
|
|
|
@include break-to-device(mobile) {
|
|
|
|
left: px2rem(-32px);
|
|
|
|
margin-left: px2rem(-32px);
|
|
|
|
padding-left: px2rem(32px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-10 12:34:58 +01:00
|
|
|
// Block with line numbers
|
|
|
|
> .codehilitetable {
|
|
|
|
margin: 1em 0;
|
|
|
|
border-radius: 0.2em;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [mobile -]: Stretch to whole width
|
|
|
|
@include break-to-device(mobile) {
|
2016-11-05 23:26:07 +01:00
|
|
|
|
2020-02-10 12:34:58 +01:00
|
|
|
// Full-width container
|
|
|
|
> .codehilite {
|
2019-02-12 19:13:08 +01:00
|
|
|
margin: 1em px2rem(-16px);
|
2017-05-31 12:25:31 +02:00
|
|
|
|
|
|
|
// Actual container with code, overflowing
|
|
|
|
code {
|
2019-02-12 19:13:08 +01:00
|
|
|
padding: px2rem(10.5px) px2rem(16px);
|
2017-05-31 12:25:31 +02:00
|
|
|
}
|
2016-11-05 23:26:07 +01:00
|
|
|
}
|
|
|
|
|
2020-02-10 12:34:58 +01:00
|
|
|
// Full-width container on top-level
|
|
|
|
> .codehilitetable {
|
2019-02-12 19:13:08 +01:00
|
|
|
margin: 1em px2rem(-16px);
|
2016-10-30 10:36:18 +01:00
|
|
|
border-radius: 0;
|
|
|
|
|
|
|
|
// Increase spacing
|
|
|
|
.linenodiv {
|
2019-02-12 19:13:08 +01:00
|
|
|
padding: px2rem(10px) px2rem(16px);
|
2016-10-30 10:36:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-31 16:34:20 +02:00
|
|
|
|
2018-06-18 02:11:11 -06:00
|
|
|
// When pymdownx.superfences is enabled but codehilite is disabled,
|
|
|
|
// pymdownx.highlight will be used. When this happens, the outer
|
2020-02-14 09:52:22 +01:00
|
|
|
// container and tables get this class names by default
|
2017-05-31 16:34:20 +02:00
|
|
|
.highlight {
|
|
|
|
@extend .codehilite;
|
|
|
|
}
|
2018-06-18 02:11:11 -06:00
|
|
|
|
2018-06-18 10:14:10 +02:00
|
|
|
// Same as above, but for code blocks with line numbers enabled
|
2018-06-18 02:11:11 -06:00
|
|
|
.highlighttable {
|
|
|
|
@extend .codehilitetable;
|
|
|
|
}
|
2016-09-04 17:11:58 +02:00
|
|
|
}
|