forked from gethyas/doks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gethyas#180 from h-enk/syntax-highlighting
Add highlight.js as an option
- Loading branch information
Showing
16 changed files
with
251 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import hljs from 'highlight.js/lib/core'; | ||
|
||
import javascript from 'highlight.js/lib/languages/javascript'; | ||
import json from 'highlight.js/lib/languages/json'; | ||
import bash from 'highlight.js/lib/languages/bash'; | ||
import htmlbars from 'highlight.js/lib/languages/htmlbars'; | ||
import ini from 'highlight.js/lib/languages/ini'; | ||
import yaml from 'highlight.js/lib/languages/yaml'; | ||
import markdown from 'highlight.js/lib/languages/markdown'; | ||
|
||
hljs.registerLanguage('javascript', javascript); | ||
hljs.registerLanguage('json', json); | ||
hljs.registerLanguage('bash', bash); | ||
hljs.registerLanguage('html', htmlbars); | ||
hljs.registerLanguage('ini', ini); | ||
hljs.registerLanguage('toml', ini); | ||
hljs.registerLanguage('yaml', yaml); | ||
hljs.registerLanguage('md', markdown); | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
document.querySelectorAll('pre code').forEach((block) => { | ||
hljs.highlightBlock(block); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Doks — based on Ascetic by (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org> | ||
*/ | ||
|
||
.hljs { | ||
display: block; | ||
overflow-x: auto; | ||
padding: 0.5em; | ||
background: $beige; | ||
color: $black; | ||
} | ||
|
||
body.dark .hljs { | ||
background: $body-overlay-dark; | ||
color: $body-color-dark; | ||
} | ||
|
||
.hljs-string, | ||
.hljs-variable, | ||
.hljs-template-variable, | ||
.hljs-symbol, | ||
.hljs-bullet, | ||
.hljs-section, | ||
.hljs-addition, | ||
.hljs-attribute, | ||
.hljs-link { | ||
color: #888; | ||
} | ||
|
||
.hljs-comment, | ||
.hljs-quote, | ||
.hljs-meta, | ||
.hljs-deletion { | ||
color: #ccc; | ||
} | ||
|
||
.hljs-keyword, | ||
.hljs-selector-tag, | ||
.hljs-section, | ||
.hljs-name, | ||
.hljs-type, | ||
.hljs-strong { | ||
font-weight: bold; | ||
} | ||
|
||
.hljs-emphasis { | ||
font-style: italic; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: "Examples" | ||
description: "Examples" | ||
lead: "" | ||
date: 2021-03-16T08:43:03+01:00 | ||
lastmod: 2021-03-16T08:43:03+01:00 | ||
draft: false | ||
images: [] | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
title: "Code" | ||
description: "Code highlighting examples" | ||
lead: "Code highlighting examples" | ||
date: 2021-03-16T08:43:34+01:00 | ||
lastmod: 2021-03-16T08:43:34+01:00 | ||
draft: false | ||
images: [] | ||
menu: | ||
docs: | ||
parent: "examples" | ||
weight: 200 | ||
toc: true | ||
--- | ||
|
||
## JavaScript | ||
|
||
```js | ||
function $initHighlight(block, cls) { | ||
try { | ||
if (cls.search(/\bno\-highlight\b/) != -1) | ||
return process(block, true, 0x0F) + | ||
` class="${cls}"`; | ||
} catch (e) { | ||
/* handle exception */ | ||
} | ||
for (var i = 0 / 2; i < classes.length; i++) { | ||
if (checkCondition(classes[i]) === undefined) | ||
console.log('undefined'); | ||
} | ||
|
||
return ( | ||
<div> | ||
<web-component>{block}</web-component> | ||
</div> | ||
) | ||
} | ||
|
||
export $initHighlight; | ||
``` | ||
|
||
## JSON | ||
|
||
```json | ||
[ | ||
{ | ||
"title": "apples", | ||
"count": [12000, 20000], | ||
"description": {"text": "...", "sensitive": false} | ||
}, | ||
{ | ||
"title": "oranges", | ||
"count": [17500, null], | ||
"description": {"text": "...", "sensitive": false} | ||
} | ||
] | ||
``` | ||
|
||
## Bash | ||
|
||
```bash | ||
#!/bin/bash | ||
|
||
###### CONFIG | ||
ACCEPTED_HOSTS="/root/.hag_accepted.conf" | ||
BE_VERBOSE=false | ||
|
||
if [ "$UID" -ne 0 ] | ||
then | ||
echo "Superuser rights required" | ||
exit 2 | ||
fi | ||
|
||
genApacheConf(){ | ||
echo -e "# Host ${HOME_DIR}$1/$2 :" | ||
} | ||
|
||
echo '"quoted"' | tr -d \" > text.txt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
<button class="btn-clipboard btn btn-sm btn-link" data-clipboard-text="{{ .Get "text" | safeHTML }}"><span class="copy-status"></span></button> | ||
{{ if .Site.Params.options.clipBoard -}} | ||
<div class="doks-clipboard"> | ||
<button class="btn-clipboard btn btn-link" data-clipboard-text="{{ .Get "text" | safeHTML }}"><span class="copy-status"></span></button> | ||
</div> | ||
{{ end -}} |
Oops, something went wrong.