feat: katex chemical equations support
This commit is contained in:
parent
c69a92a02a
commit
44a0f69a78
@ -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)
|
||||
|
1677
server/modules/rendering/markdown-katex/mhchem.js
Normal file
1677
server/modules/rendering/markdown-katex/mhchem.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user