web/_sass/addon/syntax.scss

177 lines
3.3 KiB
SCSS
Raw Normal View History

2019-11-15 19:01:33 +03:00
/*
2019-09-30 15:38:41 +03:00
* The syntax highlight.
2020-01-02 16:17:49 +03:00
* v2.0
* https://github.com/cotes2020/jekyll-theme-chirpy
2019-09-30 15:38:41 +03:00
* © 2018-2019 Cotes Chung
* MIT Licensed
*/
2021-01-23 08:20:58 +03:00
@import "colors/light-syntax";
@import "colors/dark-syntax";
2020-01-03 15:18:19 +03:00
2020-08-19 16:18:14 +03:00
html:not([mode]),
html[mode=light] {
@include light-syntax;
}
html[mode=dark] {
@include dark-syntax;
}
@media (prefers-color-scheme: dark) {
2020-08-19 16:18:14 +03:00
html:not([mode]),
html[mode=dark] {
@include dark-syntax;
}
html[mode=light] {
@include light-syntax;
}
}
2020-08-19 16:18:14 +03:00
/* -- Codes Snippet -- */
2019-09-30 15:38:41 +03:00
%code-snippet-bg {
background: var(--highlight-bg-color);
2019-09-30 15:38:41 +03:00
}
2020-02-25 12:56:03 +03:00
%code-snippet-radius {
2020-12-18 15:24:14 +03:00
border-radius: 6px;
2019-09-30 15:38:41 +03:00
}
%code-snippet-padding {
2020-12-18 15:24:14 +03:00
padding: 1.5rem;
2020-08-19 16:18:14 +03:00
}
2020-08-23 11:09:35 +03:00
$code-font-size: 0.85rem;
2020-08-19 16:18:14 +03:00
div > pre {
@extend %code-snippet-bg;
@extend %code-snippet-radius;
@extend %code-snippet-padding;
}
2020-02-25 12:56:03 +03:00
.highlighter-rouge {
@extend %code-snippet-bg;
2020-02-25 12:56:03 +03:00
@extend %code-snippet-radius;
2020-08-19 16:18:14 +03:00
color: var(--highlighter-rouge-color);
margin-top: 0.5rem;
2020-02-25 12:56:03 +03:00
margin-bottom: 1.2em; /* Override BS Inline-code style */
2019-09-30 15:38:41 +03:00
}
2020-02-25 12:56:03 +03:00
.highlight {
@extend %code-snippet-radius;
@extend %code-snippet-bg;
2020-08-19 16:18:14 +03:00
2020-02-25 12:56:03 +03:00
@at-root figure#{&} {
@extend %code-snippet-bg;
2020-02-25 12:56:03 +03:00
}
2020-08-19 16:18:14 +03:00
2020-02-25 12:56:03 +03:00
overflow: auto;
.lineno {
2020-12-18 15:54:18 +03:00
margin-left: 0.2rem;
padding-right: 0.5rem;
2020-02-25 12:56:03 +03:00
min-width: 2.2rem;
text-align: right;
color: var(--highlight-lineno-color);
border-right: 1px solid var(--highlight-lineno-border-color);
2020-02-25 12:56:03 +03:00
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
2020-08-19 16:18:14 +03:00
pre {
margin-bottom: 0;
2020-08-23 11:09:35 +03:00
font-size: $code-font-size;
2020-08-19 16:18:14 +03:00
line-height: 1.4rem;
word-wrap: normal; /* Fixed Safari overflow-x */
}
2020-02-25 12:56:03 +03:00
table {
padding: 0;
border: 0;
td pre {
overflow: visible; /* Fixed iOS safari overflow-x */
word-break: normal; /* Fixed iOS safari linenos code break */
}
}
td {
padding: 0;
border: 0;
}
} //.highlight
2019-09-30 15:38:41 +03:00
code {
-webkit-hyphens: none;
-ms-hyphens: none;
-moz-hyphens: none;
hyphens: none;
2020-08-19 16:18:14 +03:00
2020-02-25 12:56:03 +03:00
&.highlighter-rouge {
2020-08-23 11:09:35 +03:00
font-size: $code-font-size;
2020-06-22 16:08:36 +03:00
padding: 3px 5px;
2020-02-25 12:56:03 +03:00
border-radius: 4px;
2020-06-22 16:08:36 +03:00
background-color: var(--inline-code-bg);
2020-02-28 19:16:47 +03:00
}
2020-08-19 16:18:14 +03:00
@at-root a > &.highlighter-rouge {
2020-02-28 19:16:47 +03:00
padding-bottom: 0; // show link's underlinke
2020-06-22 16:08:36 +03:00
color: inherit;
2020-02-28 19:16:47 +03:00
}
2020-08-19 16:18:14 +03:00
@at-root a:hover > &.highlighter-rouge {
2020-02-28 19:16:47 +03:00
border-bottom: none;
2020-02-25 12:56:03 +03:00
}
2020-08-19 16:18:14 +03:00
2020-06-22 16:08:36 +03:00
blockquote &.highlighter-rouge {
color: inherit;
}
2019-09-30 15:38:41 +03:00
}
td.rouge-code {
2020-12-18 15:24:14 +03:00
padding: 1.5rem 1.5rem 1.5rem 1rem;
// Prevent some browser extends from
// changing the URL string of code block.
a {
color: inherit !important;
border-bottom: none !important;
pointer-events: none;
}
2019-09-30 15:38:41 +03:00
}
2020-06-08 16:44:59 +03:00
/* Hide line numbers for default, console, and terminal code snippets */
div {
&[class^='highlighter-rouge'],
&.language-plaintext.highlighter-rouge,
&.language-console.highlighter-rouge,
&.language-terminal.highlighter-rouge {
pre.lineno {
display: none;
}
td.rouge-code {
@extend %code-snippet-padding;
}
}
}
2020-12-28 14:38:24 +03:00
div[class^='language-']::before {
content: attr(lang);
position: absolute;
right: 1.8rem;
margin-top: 3px;
2020-12-18 15:54:18 +03:00
font-size: 0.7rem;
font-weight: 600;
color: var(--highlight-lineno-color);
text-transform: uppercase;
}
@media (min-width: 768px) {
2020-12-28 14:38:24 +03:00
div[class^='language-']::before {
right: 3.1rem;
}
}