Skip to content

Commit a2d1f4d

Browse files
authored
Update katex to v0.10.0 (#949)
This includes a fix for italic fonts. Running katex from the commandline has a dependency, so `npm install` must be run. See issue #669.
1 parent 36c9014 commit a2d1f4d

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "document/core/util/katex"]
22
path = document/core/util/katex
3-
url = https://github.com/Khan/KaTeX.git
3+
url = https://github.com/KaTeX/KaTeX.git

document/core/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ bikeshed:
147147
mkdir -p $(BUILDDIR)/bikeshed_mathjax/
148148
bikeshed spec index.bs $(BUILDDIR)/bikeshed_mathjax/index.html
149149
mkdir -p $(BUILDDIR)/html/bikeshed/
150+
(cd util/katex/ && npm install --only=prod)
150151
python util/mathjax2katex.py $(BUILDDIR)/bikeshed_mathjax/index.html \
151152
>$(BUILDDIR)/html/bikeshed/index.html
152153
mkdir -p $(BUILDDIR)/html/bikeshed/katex/dist/

document/core/util/katex

Submodule katex updated 557 files

document/core/util/katex_fix.patch

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
113c113
2-
< .katex-display {
3-
---
4-
> div > .katex-display {
51
123c123,126
62
< font: normal 1.21em KaTeX_Main, Times New Roman, serif;
73
---
84
> /* font: normal 1.21em KaTeX_Main, Times New Roman, serif; */
95
> font-weight: normal;
106
> font-size: 1.21em;
117
> font-family: KaTeX_Main, Times New Roman, serif;
12-
127d129
8+
126d128
139
< text-rendering: auto;
14-
133c135
15-
< display: inline-block;
10+
989c991
11+
< .katex-display {
12+
---
13+
> div > .katex-display {
14+
994c996
15+
< .katex-display > .katex {
16+
---
17+
> div > .katex-display > .katex {
18+
999c1001
19+
< .katex-display > .katex > .katex-html {
20+
---
21+
> div > .katex-display > .katex > .katex-html {
22+
1003c1005
23+
< .katex-display > .katex > .katex-html > .tag {
24+
---
25+
> div > .katex-display > .katex > .katex-html > .tag {
26+
1007c1009,1022
27+
<
1628
---
17-
> /* display: inline-block; */
18-
1060,1065d1061
19-
< .katex svg path {
20-
< fill: currentColor;
21-
< }
22-
< .katex svg line {
23-
< stroke: currentColor;
24-
< }
25-
1142a1139,1152
26-
> }
2729
> /* Force borders on tables */
2830
> table {
2931
> border-collapse: collapse;
@@ -37,3 +39,4 @@
3739
> }
3840
> .codepre {
3941
> white-space: pre;
42+
> }

document/core/util/mathjax2katex.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212

1313
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
14+
# Update this to invalidate the cache; e.g. when updating katex.
15+
CACHE_VERSION = 2
1416

1517

1618
def FindMatching(data, prefix):
@@ -67,7 +69,7 @@ def ReplaceMath(cache, data):
6769
data = data.replace('’', '\\text{’}')
6870
data = data.replace('‘', '\\text{‘}')
6971
data = data.replace('\\hfill', '')
70-
data = data.replace('\\mbox', '\\mathrel')
72+
data = data.replace('\\mbox', '\\text')
7173
data = data.replace('\\begin{split}', '\\begin{aligned}')
7274
data = data.replace('\\end{split}', '\\end{aligned}')
7375
data = data.replace('&amp;', '&')
@@ -121,13 +123,6 @@ def ReplaceMath(cache, data):
121123
# Fix stray spans that come out of katex.
122124
ret = re.sub('[<]span class="vlist" style="height:[0-9.]+em;"[>]',
123125
'<span class="vlist">', ret)
124-
# Drop bad italic font adjustment.
125-
# https://github.com/WebAssembly/spec/issues/669
126-
# https://github.com/Khan/KaTeX/issues/1259
127-
ret = re.sub(
128-
'mathit" style="margin-right:0.[0-9]+em', 'mathit" style="', ret)
129-
ret = re.sub(
130-
'mainit" style="margin-right:0.[0-9]+em', 'mathit" style="', ret)
131126
assert HasBalancedTags(ret)
132127

133128
cache[data] = ret
@@ -152,7 +147,7 @@ def ExtractMath(match):
152147
return 'x' * len(match.group())
153148

154149
data = open(sys.argv[1]).read()
155-
cache = shelve.open(sys.argv[1] + '.cache')
150+
cache = shelve.open('%s.%d.cache' % (sys.argv[1], CACHE_VERSION))
156151
# Drop index + search links.
157152
data = data.replace(
158153
'<link href="genindex.html" rel="index" title="Index">', '')

0 commit comments

Comments
 (0)