-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from scroll-tech/syntax-highlighting
Syntax Highlighting
- Loading branch information
Showing
10 changed files
with
116 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
document.addEventListener("astro:page-load", () => { | ||
const preElements = document.querySelectorAll(".expressive-code") | ||
preElements.forEach((pre) => { | ||
const hasTargetClass = pre.querySelector(".mark") | ||
if (hasTargetClass) { | ||
pre.classList.add("has-focused-lines") | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import "./fix-remix-urls" | ||
import "./fix-external-links" | ||
import "./click-to-zoom" | ||
import "./copy-to-clipboard" | ||
import "./has-focused-lines" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
/** | ||
* Darcula theme | ||
* | ||
* Adapted from a theme based on: | ||
* IntelliJ Darcula Theme (https://github.com/bulenkov/Darcula) | ||
* | ||
* @author Alexandre Paradis <[email protected]> | ||
* @version 1.0 | ||
*/ | ||
|
||
code[class*="language-"], | ||
pre[class*="language-"] { | ||
code[data-language], | ||
pre[data-language] { | ||
color: #a9b7c6; | ||
font-family: var(--font-family-code); | ||
direction: ltr; | ||
|
@@ -30,142 +20,75 @@ pre[class*="language-"] { | |
} | ||
|
||
code, | ||
code[class*="language-"] *, | ||
pre[class*="language-"] * { | ||
code[data-language] *, | ||
pre[data-language] * { | ||
font-family: var(--font-family-code) !important; | ||
font-size: 16px; | ||
} | ||
|
||
pre[class*="language-"]::-moz-selection, | ||
pre[class*="language-"] ::-moz-selection, | ||
code[class*="language-"]::-moz-selection, | ||
code[class*="language-"] ::-moz-selection { | ||
pre[data-language]::-moz-selection, | ||
pre[data-language] ::-moz-selection, | ||
code[data-language]::-moz-selection, | ||
code[data-language] ::-moz-selection { | ||
color: inherit; | ||
background: rgba(33, 66, 131, 0.85); | ||
} | ||
|
||
/* Code blocks */ | ||
pre[class*="language-"] { | ||
pre[data-language] { | ||
padding: 1em; | ||
margin: 0.5em 0; | ||
overflow: auto; | ||
margin-top: 1.4em; | ||
margin-bottom: 2.2em; | ||
} | ||
|
||
:not(pre) > code[class*="language-"], | ||
pre[class*="language-"] { | ||
:not(pre) > code[data-language], | ||
pre[data-language] { | ||
background: #2b2b2b; | ||
border-radius: 27px; | ||
padding: 17px; | ||
padding-right: 70px; | ||
} | ||
|
||
/* Inline code */ | ||
:not(pre) > code[class*="language-"] { | ||
:not(pre) > code[data-language] { | ||
padding: 0.1em; | ||
border-radius: 0.3em; | ||
} | ||
|
||
.token.class-name { | ||
color: #afafaf; | ||
} | ||
|
||
.token.comment, | ||
.token.prolog, | ||
.token.cdata { | ||
color: #808080; | ||
} | ||
|
||
.token.delimiter, | ||
.token.boolean, | ||
.token.keyword, | ||
.token.selector, | ||
.token.important, | ||
.token.atrule { | ||
color: #cc7832; | ||
} | ||
|
||
.token.operator, | ||
.token.punctuation, | ||
.token.attr-name { | ||
color: #a9b7c6; | ||
} | ||
|
||
.token.tag, | ||
.token.tag .punctuation, | ||
.token.doctype, | ||
.token.builtin { | ||
color: #e8bf6a; | ||
} | ||
|
||
.token.entity, | ||
.token.number, | ||
.token.symbol { | ||
color: #6897bb; | ||
} | ||
|
||
.token.property, | ||
.token.constant, | ||
.token.variable { | ||
color: #9876aa; | ||
.frame { | ||
overflow: hidden; | ||
} | ||
|
||
.token.string, | ||
.token.char { | ||
color: #6a8759; | ||
.expressive-code pre, | ||
.expressive-code code { | ||
font-size: 16px !important; | ||
} | ||
|
||
.token.attr-value, | ||
.token.attr-value .punctuation { | ||
color: #a5c261; | ||
.expressive-code.has-focused-lines .ec-line:not(.highlight) .code { | ||
opacity: 0.7; | ||
transition: filter 0.35s, opacity 0.35s; | ||
filter: blur(0.095rem); | ||
} | ||
|
||
.token.attr-value .punctuation:first-child { | ||
color: #a9b7c6; | ||
} | ||
|
||
.token.url { | ||
color: #287bde; | ||
text-decoration: underline; | ||
} | ||
|
||
.token.function { | ||
color: #ffc66d; | ||
} | ||
|
||
.token.regex { | ||
background: #364135; | ||
.expressive-code.has-focused-lines:hover .ec-line .code { | ||
opacity: 1; | ||
filter: none; | ||
} | ||
|
||
.token.bold { | ||
font-weight: bold; | ||
.expressive-code.has-focused-lines .ec-line.mark.highlight { | ||
background: transparent; | ||
} | ||
|
||
.token.italic { | ||
font-style: italic; | ||
} | ||
|
||
.token.inserted { | ||
background: #294436; | ||
} | ||
|
||
.token.deleted { | ||
background: #484a4a; | ||
} | ||
|
||
code.language-css .token.property, | ||
code.language-css .token.property + .token.punctuation { | ||
color: #a9b7c6; | ||
.expressive-code div.copy button { | ||
border-radius: 50%; | ||
} | ||
|
||
code.language-css .token.id { | ||
color: #ffc66d; | ||
div.expressive-code pre::-webkit-scrollbar { | ||
height: 0; | ||
} | ||
|
||
code.language-css .token.selector > .token.class, | ||
code.language-css .token.selector > .token.attribute, | ||
code.language-css .token.selector > .token.pseudo-class, | ||
code.language-css .token.selector > .token.pseudo-element { | ||
color: #ffc66d; | ||
.expressive-code .ec-line div.code { | ||
border-inline-start: unset; | ||
} |