Skip to content

Commit 9dd2dd4

Browse files
committed
feat: Added code syntax highlighting for use in articles
1 parent ba1659f commit 9dd2dd4

File tree

5 files changed

+128
-2
lines changed

5 files changed

+128
-2
lines changed

assets/styles/syntax_highlight.css

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
3+
Darcula color scheme from the JetBrains family of IDEs
4+
5+
*/
6+
7+
.hljs {
8+
display: block;
9+
overflow-x: auto;
10+
padding: 1em;
11+
background: #2b2b2b;
12+
color: #bababa;
13+
margin-bottom: 20px;
14+
margin-left: 10px;
15+
font-family: "Inconsolata", monospace;
16+
}
17+
18+
.hljs-strong,
19+
.hljs-emphasis {
20+
color: #a8a8a2;
21+
}
22+
23+
.hljs-bullet,
24+
.hljs-quote,
25+
.hljs-link,
26+
.hljs-number,
27+
.hljs-regexp,
28+
.hljs-literal {
29+
color: #6896ba;
30+
}
31+
32+
.hljs-code,
33+
.hljs-selector-class {
34+
color: #a6e22e;
35+
}
36+
37+
.hljs-emphasis {
38+
font-style: italic;
39+
}
40+
41+
.hljs-keyword,
42+
.hljs-selector-tag,
43+
.hljs-section,
44+
.hljs-attribute,
45+
.hljs-name,
46+
.hljs-variable {
47+
color: #cb7832;
48+
}
49+
50+
.hljs-params {
51+
color: #b9b9b9;
52+
}
53+
54+
.hljs-string {
55+
color: #6a8759;
56+
}
57+
58+
.hljs-subst,
59+
.hljs-type,
60+
.hljs-built_in,
61+
.hljs-builtin-name,
62+
.hljs-symbol,
63+
.hljs-selector-id,
64+
.hljs-selector-attr,
65+
.hljs-selector-pseudo,
66+
.hljs-template-tag,
67+
.hljs-template-variable,
68+
.hljs-addition {
69+
color: #e0c46c;
70+
}
71+
72+
.hljs-comment,
73+
.hljs-deletion,
74+
.hljs-meta {
75+
color: #7f7f7f;
76+
}

package-lock.json

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"firebase-tools": "^8.2.0",
3737
"nodemon": "^2.0.3",
3838
"showdown": "^1.9.1",
39+
"showdown-highlight": "^2.1.4",
3940
"standard-version": "^8.0.0",
4041
"ts-node": "^8.10.1",
4142
"typescript": "^3.8.3",

scripts/generateThoughts.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from "fs";
22
import showdown from "showdown";
3+
import showdownHighlight from "showdown-highlight";
34
import { format as dateFormat } from "date-fns";
45

56
import findInDir from "./findInDir";
@@ -28,7 +29,9 @@ templates.forEach((template) => {
2829
console.log(`Processing articles`);
2930
const articles = findInDir("./thoughts/articles", ".md");
3031

31-
const mdConverter = new showdown.Converter();
32+
const mdConverter = new showdown.Converter({
33+
extensions: [showdownHighlight],
34+
});
3235

3336
const articlesGenerated: Array<{
3437
title: string;

templates/head.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{meta.html}
3838

3939
<link
40-
href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&family=Fredoka+One&display=swap"
40+
href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&family=Fredoka+One&family=Inconsolata:wght@300&display=swap"
4141
rel="stylesheet"
4242
/>
4343

0 commit comments

Comments
 (0)