Skip to content

Commit 1d405e6

Browse files
committed
Add syntax highlighting. Closes #310
1 parent 9fe340d commit 1d405e6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Nirum/Targets/Docs.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ $doctype 5
105105
$forall Author { name = name' } <- authors md
106106
<meta name="author" content="#{name'}">
107107
<link rel="stylesheet" href="#{root}style.css">
108+
<link rel="stylesheet" href="#{hljsCss}">
109+
<script src="#{hljsJs}"></script>
110+
<script>hljs.initHighlightingOnLoad();</script>
108111
<body>
109112
#{preEscapedToMarkup $ docsHeader $ target pkg}
110113
<nav>
@@ -161,6 +164,16 @@ $doctype 5
161164
documentSortKey ("", _) = (False, 0, "")
162165
documentSortKey (fp@(fp1 : _), _) =
163166
(isUpper fp1, length (filter (== pathSeparator) fp), fp)
167+
hljsCss :: T.Text
168+
hljsCss = T.concat
169+
[ "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0"
170+
, "/styles/github.min.css"
171+
]
172+
hljsJs :: T.Text
173+
hljsJs = T.concat
174+
[ "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/"
175+
, "highlight.min.js"
176+
]
164177

165178
typeExpression :: BoundModule Docs -> TE.TypeExpression -> Html
166179
typeExpression _ expr = [shamlet|#{typeExpr expr}|]
@@ -490,7 +503,7 @@ strong code
490503
pre
491504
padding: 16px 10px
492505
background-color: #{gray1}
493-
code
506+
code, code.hljs
494507
background: none
495508
div
496509
border-top: 1px solid #{gray3}

0 commit comments

Comments
 (0)