Update Eric Bailey's a11y syntax highlighting stylesheet

This commit is contained in:
Helen Chong 2024-09-09 22:26:40 +08:00
parent d6c37eaa53
commit 3037127e5c
2 changed files with 207 additions and 176 deletions

View File

@ -1,27 +1,64 @@
/** /*
* a11y-dark theme for JavaScript, CSS, and HTML * a11y theme for JavaScript, CSS, and HTML
* Based on the okaidia theme: https://github.com/PrismJS/prism/blob/gh-pages/themes/prism-okaidia.css * Based on the okaidia theme: https://github.com/PrismJS/prism/blob/gh-pages/themes/prism-okaidia.css
* @author ericwbailey * @author ericwbailey
*/ */
/* /*
Theme * MARK: Setup
*/ */
@layer vendor-prism {
@media (forced-colors: none), (forced-colors: active) {
:root {
--prism-a11y-border-radius: 0.3em;
--prism-a11y-font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
--prism-a11y-line-height: 1.5;
--prism-a11y-code-block-margin: 0.5em 0;
--prism-a11y-code-block-padding: 1em;
--prism-a11y-code-inline-padding: 0.1em;
--prism-a11y-width-border: 1px;
--prism-a11y-width-tab: 2;
}
}
@media (forced-colors: none), (forced-colors: active) {
:root {
--prism-a11y-color-background: hsla(0, 0%, 17%, 1);
--prism-a11y-color-text-no-token: hsla(60, 30%, 96%, 1);
--prism-a11y-color-text-comment: hsla(54, 32%, 75%, 1);
--prism-a11y-color-text-blue: hsla(180, 100%, 44%, 1);
--prism-a11y-color-text-green: hsla(80, 75%, 55%, 1);
--prism-a11y-color-text-gray: hsla(60, 30%, 96%, 1);
--prism-a11y-color-text-purple: hsla(291, 30%, 83%, 1);
--prism-a11y-color-text-red: hsla(17, 100%, 74%, 1);
--prism-a11y-color-text-yellow: hsla(51, 100%, 50%, 1);
--prism-a11y-plugin-color-border: hsla(51, 100%, 50%, 0.55);
--prism-a11y-plugin-color-background: hsla(51, 100%, 50%, 0.1);
}
}
@media (forced-colors: none), (forced-colors: active) {
/*
* MARK: Theme
*/
:where(
code[class*="language-"], code[class*="language-"],
pre[class*="language-"] { pre[class*="language-"]
color: #f8f8f2; ) {
background: none; color: var(--prism-a11y-color-text-no-token);
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; background: var(--prism-a11y-color-background);
text-align: left; font-family: var(--prism-a11y-font-family);
text-align: start;
white-space: pre; white-space: pre;
word-spacing: normal; word-spacing: normal;
word-break: normal; word-break: normal;
word-wrap: normal; word-wrap: normal;
line-height: 1.5; line-height: var(--prism-a11y-line-height);
-moz-tab-size: 4; -moz-tab-size: var(--prism-a11y-width-tab);
-o-tab-size: 4; -o-tab-size: var(--prism-a11y-width-tab);
tab-size: 4; tab-size: var(--prism-a11y-width-tab);
-webkit-hyphens: none; -webkit-hyphens: none;
-moz-hyphens: none; -moz-hyphens: none;
@ -31,85 +68,97 @@ pre[class*="language-"] {
/* Code blocks */ /* Code blocks */
pre[class*="language-"] { pre[class*="language-"] {
padding: 1em; padding: var(--prism-a11y-code-block-padding);
margin: 0.5em 0; margin: var(--prism-a11y-code-block-margin);
overflow: auto; overflow: auto;
border-radius: 0.3em; border-radius: var(--prism-a11y-border-radius);
} }
:where(
:not(pre) > code[class*="language-"], :not(pre) > code[class*="language-"],
pre[class*="language-"] { pre[class*="language-"]
background: #2b2b2b; ) {
background: var(--prism-a11y-color-background);
} }
/* Inline code */ /* Inline code */
:not(pre) > code[class*="language-"] { :not(pre) > code[class*="language-"] {
padding: 0.1em; padding: var(--prism-a11y-code-inline-padding);
border-radius: 0.3em; border-radius: var(--prism-a11y-border-radius);
white-space: normal; white-space: normal;
} }
:where(
.token.comment, .token.comment,
.token.prolog, .token.prolog,
.token.doctype, .token.doctype,
.token.cdata { .token.cdata
color: #d4d0ab; ) {
color: var(--prism-a11y-color-text-comment);
} }
.token.punctuation { .token.punctuation {
color: #fefefe; color: var(--prism-a11y-color-text-gray);
} }
:where(
.token.property, .token.property,
.token.tag, .token.tag,
.token.constant, .token.constant,
.token.symbol, .token.symbol,
.token.deleted { .token.deleted
color: #ffa07a; ) {
} color: var(--prism-a11y-color-text-red);
.token.boolean,
.token.number {
color: #00e0e0;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #abe338;
} }
:where(
.token.operator, .token.operator,
.token.entity, .token.entity,
.token.url, .token.url,
.language-css .token.string, .language-css .token.string,
.style .token.string, .style .token.string,
.token.variable { .token.variable,
color: #00e0e0; .token.keyword
) {
color: var(--prism-a11y-color-text-blue);
} }
:where(
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted
) {
color: var(--prism-a11y-color-text-green);
}
:where(
.token.atrule, .token.atrule,
.token.attr-value, .token.attr-value,
.token.function { .token.function,
color: #ffd700;
}
.token.keyword {
color: #00e0e0;
}
.token.regex, .token.regex,
.token.important { .token.important
color: #ffd700; ) {
color: var(--prism-a11y-color-text-yellow);
} }
:where(
.token.boolean,
.token.number,
.token.keyword
) {
color: var(--prism-a11y-color-text-purple);
}
:where(
.token.important, .token.important,
.token.bold { .token.bold
) {
font-weight: bold; font-weight: bold;
} }
.token.italic { .token.italic {
font-style: italic; font-style: italic;
} }
@ -120,69 +169,50 @@ pre[class*="language-"] {
/* /*
Plugin support * MARK: Plugin support
*/ */
/* Line highlight */ /* Line highlight */
.line-highlight { .line-highlight {
background: rgba(255, 217, 0, 0.10); background: var(--prism-a11y-plugin-color-background);
border-top: 1px solid rgba(255, 217, 0, 0.55); border-top: var(--prism-a11y-width-border) solid var(--prism-a11y-plugin-color-border);
border-bottom: 1px solid rgba(255, 217, 0, 0.55); border-bottom: var(--prism-a11y-width-border) solid var(--prism-a11y-plugin-color-border);
} }
/* Line numbers */ /* Line numbers */
.line-numbers .line-numbers-rows { .line-numbers .line-numbers-rows {
border-right: 1px solid #F8F8F2; border-right: var(--prism-a11y-width-border) solid var(--prism-a11y-color-text-no-token);
} }
.line-numbers-rows > span:before { .line-numbers-rows > span:before {
color: #D4D0AB; color: var(--prism-a11y-color-text-comment);
}
} }
/* /*
High contrast mode support * MARK: Forced color mode support
*/ */
@media screen and (-ms-high-contrast: active) { @media (forced-colors: active) {
code[class*="language-"], :root {
pre[class*="language-"] { --prism-a11y-color-background: Canvas;
color: windowText; --prism-a11y-color-text-no-token: CanvasText;
background: window; --prism-a11y-color-text-comment: GrayText;
--prism-a11y-color-text-blue: LinkText;
--prism-a11y-color-text-gray: LinkText;
--prism-a11y-color-text-green: CanvasText;
--prism-a11y-color-text-purple: CanvasText;
--prism-a11y-color-text-red: CanvasText;
--prism-a11y-color-text-yellow: GrayText;
--prism-a11y-plugin-color-border: LinkText;
--prism-a11y-plugin-color-background: Canvas;
} }
:not(pre) > code[class*="language-"], :where(
pre[class*="language-"] { .token.boolean,
background: window; .token.number,
} .token.keyword
) {
.token.important {
background: highlight;
color: window;
font-weight: normal;
}
.token.atrule,
.token.attr-value,
.token.function,
.token.keyword,
.token.operator,
.token.selector {
font-weight: bold; font-weight: bold;
} }
.token.attr-value,
.token.comment,
.token.doctype,
.token.function,
.token.keyword,
.token.operator,
.token.property,
.token.string {
color: highlight;
}
.token.attr-value,
.token.url {
font-weight: normal;
} }
} }

View File

@ -96,9 +96,10 @@ code {
word-break: break-word; word-break: break-word;
} }
:not(pre) > code { padding: 0.125em 0.25em; } :not(pre) > code {
:not(pre) > code, padding: 0.125em 0.25em;
pre { background-color: var(--clr-code-bg); } background-color: var(--clr-code-bg);
}
pre { pre {
border: 0.1em solid var(--clr-code-border); border: 0.1em solid var(--clr-code-border);