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
44a0f69a
Commit
44a0f69a
authored
Mar 29, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: katex chemical equations support
parent
c69a92a0
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
editor-markdown.vue
client/components/editor/editor-markdown.vue
+1
-0
mhchem.js
server/modules/rendering/markdown-katex/mhchem.js
+0
-0
renderer.js
server/modules/rendering/markdown-katex/renderer.js
+14
-0
No files found.
client/components/editor/editor-markdown.vue
View file @
44a0f69a
...
...
@@ -216,6 +216,7 @@ import mdMark from 'markdown-it-mark'
import
mdFootnote
from
'markdown-it-footnote'
import
mdImsize
from
'markdown-it-imsize'
import
katex
from
'katex'
import
'katex/dist/contrib/mhchem'
import
twemoji
from
'twemoji'
// Prism (Syntax Highlighting)
...
...
server/modules/rendering/markdown-katex/mhchem.js
0 → 100644
View file @
44a0f69a
This diff is collapsed.
Click to expand it.
server/modules/rendering/markdown-katex/renderer.js
View file @
44a0f69a
const
katex
=
require
(
'katex'
)
const
chemParse
=
require
(
'./mhchem'
)
/* global WIKI */
...
...
@@ -8,6 +9,19 @@ const katex = require('katex')
//
// Includes code from https://github.com/liradb2000/markdown-it-katex
// Add \ce, \pu, and \tripledash to the KaTeX macros.
katex
.
__defineMacro
(
'
\\
ce'
,
function
(
context
)
{
return
chemParse
(
context
.
consumeArgs
(
1
)[
0
],
'ce'
)
})
katex
.
__defineMacro
(
'
\\
pu'
,
function
(
context
)
{
return
chemParse
(
context
.
consumeArgs
(
1
)[
0
],
'pu'
)
})
// Needed for \bond for the ~ forms
// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not
// a mathematical minus, U+2212. So we need that extra 0.56.
katex
.
__defineMacro
(
'
\\
tripledash'
,
'{
\\
vphantom{-}
\\
raisebox{2.56mu}{$
\\
mkern2mu'
+
'
\\
tiny
\\
text{-}
\\
mkern1mu
\\
text{-}
\\
mkern1mu
\\
text{-}
\\
mkern2mu$}}'
)
module
.
exports
=
{
init
(
mdinst
,
conf
)
{
if
(
conf
.
useInline
)
{
...
...
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