feat: katex chemical equations support
This commit is contained in:
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) {
|
||||
|
Reference in New Issue
Block a user