Skip to content

Commit

Permalink
feat: Added code syntax highlighting for use in articles
Browse files Browse the repository at this point in the history
  • Loading branch information
ripixel committed Jun 7, 2020
1 parent ba1659f commit 9dd2dd4
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 2 deletions.
76 changes: 76 additions & 0 deletions assets/styles/syntax_highlight.css
@@ -0,0 +1,76 @@
/*
Darcula color scheme from the JetBrains family of IDEs
*/

.hljs {
display: block;
overflow-x: auto;
padding: 1em;
background: #2b2b2b;
color: #bababa;
margin-bottom: 20px;
margin-left: 10px;
font-family: "Inconsolata", monospace;
}

.hljs-strong,
.hljs-emphasis {
color: #a8a8a2;
}

.hljs-bullet,
.hljs-quote,
.hljs-link,
.hljs-number,
.hljs-regexp,
.hljs-literal {
color: #6896ba;
}

.hljs-code,
.hljs-selector-class {
color: #a6e22e;
}

.hljs-emphasis {
font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-attribute,
.hljs-name,
.hljs-variable {
color: #cb7832;
}

.hljs-params {
color: #b9b9b9;
}

.hljs-string {
color: #6a8759;
}

.hljs-subst,
.hljs-type,
.hljs-built_in,
.hljs-builtin-name,
.hljs-symbol,
.hljs-selector-id,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-template-tag,
.hljs-template-variable,
.hljs-addition {
color: #e0c46c;
}

.hljs-comment,
.hljs-deletion,
.hljs-meta {
color: #7f7f7f;
}
46 changes: 46 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -36,6 +36,7 @@
"firebase-tools": "^8.2.0",
"nodemon": "^2.0.3",
"showdown": "^1.9.1",
"showdown-highlight": "^2.1.4",
"standard-version": "^8.0.0",
"ts-node": "^8.10.1",
"typescript": "^3.8.3",
Expand Down
5 changes: 4 additions & 1 deletion scripts/generateThoughts.ts
@@ -1,5 +1,6 @@
import * as fs from "fs";
import showdown from "showdown";
import showdownHighlight from "showdown-highlight";
import { format as dateFormat } from "date-fns";

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

const mdConverter = new showdown.Converter();
const mdConverter = new showdown.Converter({
extensions: [showdownHighlight],
});

const articlesGenerated: Array<{
title: string;
Expand Down
2 changes: 1 addition & 1 deletion templates/head.html
Expand Up @@ -37,7 +37,7 @@
{meta.html}

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

Expand Down

0 comments on commit 9dd2dd4

Please sign in to comment.