Skip to content

Commit 72e894b

Browse files
committed
Add syntax highlighting. Closes #310
1 parent 9edb20d commit 72e894b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ To be released.
2828
[[#297], [#304] by Jeong Ukjae]
2929
- Added `opengraphs` option for [OpenGraph] objects on docs.
3030
[[#283], [#305] by GyuYong Jung]
31+
- Added syntax highlighting.
32+
[[#310], [#311] by MinJune Kim]
3133

3234
### Python target
3335

src/Nirum/Targets/Docs.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ $doctype 5
113113
$forall OpenGraph { ogTag, ogContent } <- docsOpenGraph $ target pkg
114114
<meta property="#{ogTag}" content="#{ogContent}">
115115
<link rel="stylesheet" href="#{root}style.css">
116+
<link rel="stylesheet" href="#{hljsCss}">
117+
<script src="#{hljsJs}"></script>
118+
<script>hljs.initHighlightingOnLoad();</script>
116119
<body>
117120
#{preEscapedToMarkup $ docsHeader $ target pkg}
118121
<nav>
@@ -169,6 +172,12 @@ $doctype 5
169172
documentSortKey ("", _) = (False, 0, "")
170173
documentSortKey (fp@(fp1 : _), _) =
171174
(isUpper fp1, length (filter (== pathSeparator) fp), fp)
175+
hljsBase :: T.Text
176+
hljsBase = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/"
177+
hljsCss :: T.Text
178+
hljsCss = T.concat [hljsBase, "styles/github.min.css"]
179+
hljsJs :: T.Text
180+
hljsJs = T.concat [hljsBase, "highlight.min.js"]
172181

173182
typeExpression :: BoundModule Docs -> TE.TypeExpression -> Html
174183
typeExpression _ expr = [shamlet|#{typeExpr expr}|]
@@ -498,7 +507,7 @@ strong code
498507
pre
499508
padding: 16px 10px
500509
background-color: #{gray1}
501-
code
510+
code, code.hljs
502511
background: none
503512
div
504513
border-top: 1px solid #{gray3}

0 commit comments

Comments
 (0)