Skip to content

Commit

Permalink
Add syntax highlighting. Closes #310
Browse files Browse the repository at this point in the history
  • Loading branch information
qria committed Aug 16, 2018
1 parent 9edb20d commit 72e894b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ To be released.
[[#297], [#304] by Jeong Ukjae]
- Added `opengraphs` option for [OpenGraph] objects on docs.
[[#283], [#305] by GyuYong Jung]
- Added syntax highlighting.
[[#310], [#311] by MinJune Kim]

### Python target

Expand Down
11 changes: 10 additions & 1 deletion src/Nirum/Targets/Docs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ $doctype 5
$forall OpenGraph { ogTag, ogContent } <- docsOpenGraph $ target pkg
<meta property="#{ogTag}" content="#{ogContent}">
<link rel="stylesheet" href="#{root}style.css">
<link rel="stylesheet" href="#{hljsCss}">
<script src="#{hljsJs}"></script>
<script>hljs.initHighlightingOnLoad();</script>
<body>
#{preEscapedToMarkup $ docsHeader $ target pkg}
<nav>
Expand Down Expand Up @@ -169,6 +172,12 @@ $doctype 5
documentSortKey ("", _) = (False, 0, "")
documentSortKey (fp@(fp1 : _), _) =
(isUpper fp1, length (filter (== pathSeparator) fp), fp)
hljsBase :: T.Text
hljsBase = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/"
hljsCss :: T.Text
hljsCss = T.concat [hljsBase, "styles/github.min.css"]
hljsJs :: T.Text
hljsJs = T.concat [hljsBase, "highlight.min.js"]

typeExpression :: BoundModule Docs -> TE.TypeExpression -> Html
typeExpression _ expr = [shamlet|#{typeExpr expr}|]
Expand Down Expand Up @@ -498,7 +507,7 @@ strong code
pre
padding: 16px 10px
background-color: #{gray1}
code
code, code.hljs
background: none
div
border-top: 1px solid #{gray3}
Expand Down

0 comments on commit 72e894b

Please sign in to comment.