Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
d393a954
Commit
d393a954
authored
Sep 16, 2018
by
Nicolas Giard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: code highlighting client-side
parent
1bc98068
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
81 deletions
+32
-81
app.vue
client/themes/default/components/app.vue
+5
-1
app.scss
client/themes/default/scss/app.scss
+18
-68
definition.yml
server/modules/rendering/html-codehighlighter/definition.yml
+2
-2
renderer.js
server/modules/rendering/html-codehighlighter/renderer.js
+4
-7
renderer.js
server/modules/rendering/markdown-core/renderer.js
+1
-1
definition.yml
server/modules/rendering/markdown-mathjax/definition.yml
+2
-2
No files found.
client/themes/default/components/app.vue
View file @
d393a954
...
...
@@ -49,7 +49,7 @@
.headline.grey--text.text--darken-3
{{
title
}}
.caption.grey--text.text--darken-1
{{
description
}}
v-divider
.contents
.contents
(ref='container')
slot(name='contents')
v-flex(lg3, xl2, fill-height, v-if='$vuetify.breakpoint.lgAndUp')
...
...
@@ -111,6 +111,7 @@
<
script
>
import
{
StatusIndicator
}
from
'vue-status-indicator'
import
Prism
from
'@/libs/prism/prism.js'
export
default
{
components
:
{
...
...
@@ -206,6 +207,9 @@ export default {
}
}
},
mounted
()
{
Prism
.
highlightAllUnder
(
this
.
$refs
.
container
)
},
methods
:
{
toggleNavigation
()
{
this
.
navOpen
=
!
this
.
navOpen
...
...
client/themes/default/scss/app.scss
View file @
d393a954
...
...
@@ -77,75 +77,25 @@
}
}
.
hl
js
{
display
:
block
;
overflow-x
:
auto
;
padding
:
1rem
;
background
:
#232323
;
color
:
#e6e1dc
;
.
prism
js
{
border
:
none
;
border-radius
:
5px
;
box-shadow
:
initial
;
background
-color
:
mc
(
'grey'
,
'900'
)
;
padding
:
1rem
1rem
1rem
3rem
;
margin
:
1rem
24px
;
border-radius
:
.5rem
;
}
.hljs-comment
,
.hljs-quote
{
color
:
#bc9458
;
font-style
:italic
}
.hljs-keyword
,
.hljs-selector-tag
{
color
:
#c26230
}
.hljs-string
,
.hljs-number
,
.hljs-regexp
,
.hljs-variable
,
.hljs-template-variable
{
color
:
#a5c261
}
.hljs-subst
{
color
:
#519f50
}
.hljs-tag
,
.hljs-name
{
color
:
#e8bf6a
}
.hljs-type
{
color
:
#da4939
}
.hljs-symbol
,
.hljs-bullet
,
.hljs-built_in
,
.hljs-builtin-name
,
.hljs-attr
,
.hljs-link
{
color
:
#6d9cbe
}
.hljs-params
{
color
:
#d0d0ff
}
.hljs-attribute
{
color
:
#cda869
}
.hljs-meta
{
color
:
#9b859d
}
.hljs-title
,
.hljs-section
{
color
:
#ffc66d
}
.hljs-addition
{
background-color
:
#144212
;
color
:
#e6e1dc
;
display
:inline-block
;
width
:
100%
}
.hljs-deletion
{
background-color
:
#600
;
color
:
#e6e1dc
;
display
:inline-block
;
width
:
100%
}
.hljs-selector-class
{
color
:
#9b703f
}
.hljs-selector-id
{
color
:
#8b98ab
}
.hljs-emphasis
{
font-style
:italic
}
.hljs-strong
{
font-weight
:bold
}
.hljs-link
{
text-decoration
:underline
>
code
{
box-shadow
:
initial
;
display
:
block
;
font-size
:
.85rem
;
font-family
:
'Source Code Pro'
,
monospace
;
&
:after
,
&
:before
{
content
:
initial
;
letter-spacing
:
initial
;
}
}
}
}
server/modules/rendering/html-codehighlighter/definition.yml
View file @
d393a954
key
:
htmlCodehighlighter
title
:
Code Highlighting
description
:
Syntax
highlighte
r for programming code
title
:
Code Highlighting
Post-Processor
description
:
Syntax
detecto
r for programming code
author
:
requarks.io
icon
:
palette
enabledDefault
:
true
...
...
server/modules/rendering/html-codehighlighter/renderer.js
View file @
d393a954
...
...
@@ -3,15 +3,12 @@ const hljs = require('highlight.js')
module
.
exports
=
{
async
init
(
$
,
config
)
{
$
(
'pre > code'
).
each
((
idx
,
elm
)
=>
{
const
lang
=
$
(
elm
).
attr
(
'lang'
)
if
(
lang
)
{
$
(
elm
).
html
(
hljs
.
highlight
(
lang
,
$
(
elm
).
text
(),
true
).
value
)
}
else
{
const
codeClasses
=
$
(
elm
).
attr
(
'class'
)
||
''
if
(
codeClasses
.
indexOf
(
'language-'
)
<
0
)
{
const
result
=
hljs
.
highlightAuto
(
$
(
elm
).
text
())
$
(
elm
).
html
(
result
.
value
)
$
(
elm
).
attr
(
'lang'
,
result
.
language
)
$
(
elm
).
addClass
(
'language-'
,
result
.
language
)
}
$
(
elm
).
parent
().
addClass
(
'
hlj
s'
)
$
(
elm
).
parent
().
addClass
(
'
prismjs line-number
s'
)
})
}
}
server/modules/rendering/markdown-core/renderer.js
View file @
d393a954
...
...
@@ -25,7 +25,7 @@ module.exports = {
typographer
:
this
.
config
.
typographer
,
quotes
:
_
.
get
(
quoteStyles
,
this
.
config
.
quotes
,
quoteStyles
.
English
),
highlight
(
str
,
lang
)
{
return
`<pre><code
lang="
${
lang
}
">
${
_
.
escape
(
str
)}
</code></pre>`
return
`<pre><code
class="language-
${
lang
}
">
${
_
.
escape
(
str
)}
</code></pre>`
}
})
...
...
server/modules/rendering/markdown-mathjax/definition.yml
View file @
d393a954
key
:
markdownMathjax
title
:
Mathjax Pre
-P
rocessor
description
:
Pre
-pars
e TeX blocks for Mathjax
title
:
Mathjax Pre
p
rocessor
description
:
Pre
par
e TeX blocks for Mathjax
author
:
requarks.io
icon
:
functions
enabledDefault
:
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment