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 9fe340d commit 3576f31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ To be released.
crashed when a thight list item contains blocks other than paragraphs.
- Package's version became shown on the generated docs.
[[#297], [#304] by Jeong Ukjae]
- Added syntax highlighting.

### 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 @@ -105,6 +105,9 @@ $doctype 5
$forall Author { name = name' } <- authors md
<meta name="author" content="#{name'}">
<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 @@ -161,6 +164,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 @@ -490,7 +499,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 3576f31

Please sign in to comment.