Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/mathjax-utils-2.js
1447 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/*
7
Additional mathjax utilities.
8
*/
9
10
import { remove_math, replace_math } from "./mathjax-utils";
11
import { is_array } from "./misc";
12
13
// string -- a string
14
// v -- either a single function or an array of functions
15
// First strips out math, applies all the functions, then puts the math back.
16
export function apply_without_math(string, v) {
17
let math;
18
if (!is_array(v)) {
19
v = [v];
20
}
21
[string, math] = remove_math(string);
22
for (let f of v) {
23
string = f(string);
24
}
25
return replace_math(string, math);
26
}
27
28