Skip to content

Commit 610e613

Browse files
authored
Add language tags to code blocks (#67)
1 parent 59475fc commit 610e613

File tree

3 files changed

+64
-5
lines changed

3 files changed

+64
-5
lines changed

_css/custom.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,61 @@
5555
padding: 0.5em;
5656
margin-bottom: 1em;
5757
}
58+
59+
60+
/* ==================================================================
61+
HLJS CODE BLOCKS
62+
================================================================== */
63+
64+
.hljs {
65+
position: relative;
66+
font-size: var(--small);
67+
line-height: 1.35em;
68+
border-radius: 10px;
69+
}
70+
71+
.hljs-meta { font-weight: bold;}
72+
73+
/* Use colors from theme specified in style.html */
74+
.hljs-meta.prompt_ {color: #7ee787;}
75+
.hljs-meta.help_ {color: #f2cc60;}
76+
.hljs-meta.shell_ {color: #ff7b72;}
77+
.hljs-meta.infiltrator_ {color: #ffa657;}
78+
.hljs-meta.debugger_ {color: #ffa657;}
79+
.hljs-meta.debuggereval_ {color: #ffa657;}
80+
81+
/* Add language name to code blocks */
82+
.hljs::before {
83+
content: "";
84+
position: absolute;
85+
top: 0;
86+
left: 0;
87+
padding: 0.2rem 0.5rem 0.1rem;
88+
background-color: #27303c; /* brighter than #0d1117 */
89+
border-bottom-right-radius:10px;
90+
font-size: 0.7rem;
91+
font-weight: 700;
92+
text-transform: uppercase;
93+
}
94+
95+
/* Define language names shown in code blocks */
96+
.language-bash::before {content: "Shell";}
97+
.language-toml::before {content: "TOML";}
98+
.language-julia::before {content: "Julia";}
99+
/* Special Franklin tags for Julia REPL modes */
100+
.language-julia-repl::before {content: "Julia REPL";}
101+
.julia-repl::before {content: "Julia REPL";}
102+
.julia-repl-pkg::before {content: "Julia REPL: Pkg mode";}
103+
.julia-repl-help::before {content: "Julia REPL: Help mode";}
104+
.julia-repl-shell::before {content: "Julia REPL: Shell mode";}
105+
/* Julia code after REPL prompts doesn't need a language tag */
106+
.language-julia-repl .language-julia::before {content: "";}
107+
.julia-repl .language-julia::before {content: "";}
108+
.julia-repl-pkg .language-julia::before {content: "";}
109+
.julia-repl-help .language-julia::before {content: "";}
110+
.julia-repl-shell .language-julia::before {content: "";}
111+
/* Julia code in doc strings printed via REPL Help mode is sometimes incorrectly
112+
recognized as Ruby code. Since we don't have any Ruby code in MJW, this is a quick fix.
113+
TODO: remove when not required in Xranklin.
114+
*/
115+
.language-ruby::before {content: "Julia";}

_css/franklin.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ code {
302302

303303
/* font-size: 90%; } */
304304

305+
/* NOTE:
306+
The highlight.js (hljs) styling of Modern Julia Workflows is in _css/custom.css.
307+
The following commented-out code is the original Franklin CSS:
308+
305309
.hljs {
306310
font-size: var(--small);
307311
line-height: 1.35em;
@@ -312,10 +316,7 @@ code {
312316
313317
.hljs-meta.shell_ {color: crimson;}
314318
.hljs-meta.prompt_ {color: rgb(25, 179, 51);}
315-
.hljs-meta.help_ {color: yellow;}
316-
.hljs-meta.infiltrator_ {color: rgb(240, 150, 30);}
317-
.hljs-meta.debugger_ {color: rgb(240, 150, 30);}
318-
.hljs-meta.debuggereval_ {color: rgb(240, 150, 30);}
319+
*/
319320

320321
.code-output {
321322
background: var(--output-background);

_libs/highlight/styles/github-dark.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)