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
db2ad81a
You need to sign in or sign up before continuing.
Unverified
Commit
db2ad81a
authored
Nov 13, 2022
by
cannorin
Committed by
GitHub
Nov 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: katex persistent macro support (#5838)
Co-authored-by:
cannorin
<
cannorin@users.noreply.github.com
>
parent
dc90e0b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
editor-markdown.vue
client/components/editor/editor-markdown.vue
+3
-2
renderer.js
server/modules/rendering/markdown-katex/renderer.js
+3
-2
No files found.
client/components/editor/editor-markdown.vue
View file @
db2ad81a
...
...
@@ -348,11 +348,12 @@ plantuml.init(md, {})
// KATEX
// ========================================
const
macros
=
{
}
md
.
inline
.
ruler
.
after
(
'escape'
,
'katex_inline'
,
katexHelper
.
katexInline
)
md
.
renderer
.
rules
.
katex_inline
=
(
tokens
,
idx
)
=>
{
try
{
return
katex
.
renderToString
(
tokens
[
idx
].
content
,
{
displayMode
:
false
displayMode
:
false
,
macros
}
)
}
catch
(
err
)
{
console
.
warn
(
err
)
...
...
@@ -365,7 +366,7 @@ md.block.ruler.after('blockquote', 'katex_block', katexHelper.katexBlock, {
md
.
renderer
.
rules
.
katex_block
=
(
tokens
,
idx
)
=>
{
try
{
return
`<p>`
+
katex
.
renderToString
(
tokens
[
idx
].
content
,
{
displayMode
:
true
displayMode
:
true
,
macros
}
)
+
`</p>`
}
catch
(
err
)
{
console
.
warn
(
err
)
...
...
server/modules/rendering/markdown-katex/renderer.js
View file @
db2ad81a
...
...
@@ -24,12 +24,13 @@ katex.__defineMacro('\\tripledash', '{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2m
module
.
exports
=
{
init
(
mdinst
,
conf
)
{
const
macros
=
{}
if
(
conf
.
useInline
)
{
mdinst
.
inline
.
ruler
.
after
(
'escape'
,
'katex_inline'
,
katexInline
)
mdinst
.
renderer
.
rules
.
katex_inline
=
(
tokens
,
idx
)
=>
{
try
{
return
katex
.
renderToString
(
tokens
[
idx
].
content
,
{
displayMode
:
false
displayMode
:
false
,
macros
})
}
catch
(
err
)
{
WIKI
.
logger
.
warn
(
err
)
...
...
@@ -44,7 +45,7 @@ module.exports = {
mdinst
.
renderer
.
rules
.
katex_block
=
(
tokens
,
idx
)
=>
{
try
{
return
`<p>`
+
katex
.
renderToString
(
tokens
[
idx
].
content
,
{
displayMode
:
true
displayMode
:
true
,
macros
})
+
`</p>`
}
catch
(
err
)
{
WIKI
.
logger
.
warn
(
err
)
...
...
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