Skip to content

Commit 014a2a7

Browse files
authored
Merge pull request #111 from freedomofpress/better-code-blocks
Have better code blocks and spacing
2 parents f323d57 + 378b703 commit 014a2a7

File tree

6 files changed

+158
-11
lines changed

6 files changed

+158
-11
lines changed

eleventy.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import pluginRss from "@11ty/eleventy-plugin-rss";
2+
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
3+
import markdownPrismJs from "@11ty/eleventy-plugin-syntaxhighlight/src/markdownSyntaxHighlightOptions.js";
24
import { gte } from "semver";
35
import markdownIt from "markdown-it";
46

57
export default function (eleventyConfig) {
8+
const markdown = markdownIt({
9+
html: true,
10+
highlight: markdownPrismJs({ lineSeparator: "\n" }),
11+
});
612
eleventyConfig.addPassthroughCopy("src/assets");
713
eleventyConfig.addPassthroughCopy("src/favicon.ico");
814
eleventyConfig.addPlugin(pluginRss);
15+
eleventyConfig.addPlugin(syntaxHighlight);
916

1017
eleventyConfig.setFrontMatterParsingOptions({
1118
excerpt: true,
1219
});
1320

1421
eleventyConfig.addFilter("md", function (content = "") {
15-
return markdownIt({ html: true }).render(content);
22+
return markdown.render(content);
1623
});
1724

1825
eleventyConfig.addFilter("dateIso", (date) => {

package-lock.json

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"author": "",
1212
"license": "ISC",
1313
"devDependencies": {
14-
"@11ty/eleventy": "^3.0.0"
14+
"@11ty/eleventy": "^3.0.0",
15+
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2"
1516
},
1617
"dependencies": {
1718
"@11ty/eleventy-plugin-rss": "^1.0.5",

src/_layouts/base.njk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<link rel="stylesheet" href="/assets/css/reset.css">
99
<link rel="stylesheet" href="/assets/css/style.css">
10+
<link rel="stylesheet" href="/assets/css/prism.css">
1011
<link rel="icon" type="image/x-icon" href="/favicon.ico">
1112
<meta name="description"
1213
content="Take potentially dangerous PDFs, office documents, or images and convert them to a safe PDF.">
@@ -53,7 +54,7 @@
5354
</nav>
5455
</header>
5556
<main>
56-
{{ content | safe | indent(4)}}
57+
{{ content | safe }}
5758
</main>
5859
<footer>
5960
<div class="wrapper" id="features">

src/assets/css/prism.css

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/* Prism syntax highlighting (okaidia theme) */
2+
code[class*="language-"],
3+
pre[class*="language-"] {
4+
color: #f8f8f2;
5+
background: none;
6+
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
7+
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
8+
font-size: 1em;
9+
text-align: left;
10+
white-space: pre;
11+
word-spacing: normal;
12+
word-break: normal;
13+
word-wrap: normal;
14+
line-height: 1.5;
15+
tab-size: 4;
16+
hyphens: none;
17+
}
18+
19+
pre[class*="language-"] {
20+
padding: 1rem;
21+
margin: 2em 0;
22+
overflow: auto;
23+
border-radius: 0.3em;
24+
background: #000;
25+
}
26+
27+
:not(pre) > code[class*="language-"] {
28+
background: #272822;
29+
}
30+
31+
:not(pre) > code[class*="language-"] {
32+
padding: 0.1em;
33+
border-radius: 0.3em;
34+
white-space: normal;
35+
}
36+
37+
.token.comment,
38+
.token.prolog,
39+
.token.doctype,
40+
.token.cdata {
41+
color: #8292a2;
42+
}
43+
44+
.token.punctuation {
45+
color: #f8f8f2;
46+
}
47+
48+
.token.namespace {
49+
opacity: 0.7;
50+
}
51+
52+
.token.property,
53+
.token.tag,
54+
.token.constant,
55+
.token.symbol,
56+
.token.deleted {
57+
color: #f92672;
58+
}
59+
60+
.token.boolean,
61+
.token.number {
62+
color: #ae81ff;
63+
}
64+
65+
.token.selector,
66+
.token.attr-name,
67+
.token.string,
68+
.token.char,
69+
.token.builtin,
70+
.token.inserted {
71+
color: #a6e22e;
72+
}
73+
74+
.token.operator,
75+
.token.entity,
76+
.token.url,
77+
.language-css .token.string,
78+
.style .token.string,
79+
.token.variable {
80+
color: #f8f8f2;
81+
}
82+
83+
.token.atrule,
84+
.token.attr-value,
85+
.token.function,
86+
.token.class-name {
87+
color: #e6db74;
88+
}
89+
90+
.token.keyword {
91+
color: #66d9ef;
92+
}
93+
94+
.token.regex,
95+
.token.important {
96+
color: #fd971f;
97+
}
98+
99+
.token.important,
100+
.token.bold {
101+
font-weight: bold;
102+
}
103+
104+
.token.italic {
105+
font-style: italic;
106+
}
107+
108+
.token.entity {
109+
cursor: help;
110+
}

src/assets/css/style.css

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ body {
5252
}
5353

5454
h1 {
55-
font-size: 2.8rem;
55+
font-size: 3rem;
5656
line-height: 5.25rem;
5757
margin-bottom: 1rem;
5858
}
5959

6060
h2, h3 {
61-
margin-bottom: 1.5rem;
62-
margin-top: 1.5rem;
61+
margin-bottom: 3rem;
62+
margin-top: 3rem;
6363
}
6464

6565
h2 {
@@ -548,23 +548,27 @@ code {
548548
background-color: #f3f5f7;
549549
color: #333;
550550
border-radius: 0.25rem;
551-
padding: 0.375rem;
551+
padding: 0.2rem;
552552
}
553553

554554
pre {
555555
display: block;
556556
padding: 1rem;
557557
overflow-x: auto;
558-
background-color: #f3f5f7;
558+
background-color: #000;
559+
margin-bottom: 2em;
560+
margin-top: 2em;
559561
}
560562

561563
pre code {
562564
font-size: 1em;
563565
display: block;
564566
padding: 0;
565567
background: none;
568+
color: #fff;
566569
}
567570

571+
568572
figure img.mid {
569573
width: 50%;
570574
}
@@ -596,4 +600,4 @@ video {
596600
width: 100%;
597601
height: auto;
598602
display: block;
599-
}
603+
}

0 commit comments

Comments
 (0)