Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlighting for doc target #311

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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