Skip to content

Commit 98181f3

Browse files
k4b7Kevin Barabash
authored andcommitted
Merge branch 'master' into not_command
2 parents afb12e5 + e88256b commit 98181f3

File tree

88 files changed

+1194
-1103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1194
-1103
lines changed

Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,8 @@ build/contrib:
7474
rm -rf build/contrib/*
7575
$(MAKE) -C contrib/auto-render
7676

77-
.PHONY: build/images
78-
build/images:
79-
rm -rf $@
80-
mkdir -p build
81-
cp -r static/images $@
82-
8377
.PHONY: build/katex
84-
build/katex: build/katex.js build/katex.min.js build/katex.css build/katex.min.css build/fonts build/images README.md build/contrib
78+
build/katex: build/katex.js build/katex.min.js build/katex.css build/katex.min.css build/fonts README.md build/contrib
8579
mkdir -p build/katex
8680
rm -rf build/katex/*
8781
cp -r $^ build/katex

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edg
1616
You can [download KaTeX](https://github.com/khan/katex/releases) and host it on your server or include the `katex.min.js` and `katex.min.css` files on your page directly from a CDN:
1717

1818
```html
19-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.1/katex.min.css" integrity="sha384-BDqcjN11/6D69oC63ObubLHNvQR2fNjin6+AzxA3xalB0swTj17TxVV1tL1Q5Png" crossorigin="anonymous">
20-
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.1/katex.min.js" integrity="sha384-sKYm5us3z9/bRQA+cc3gPzqwI5RVgL8vJQx1lpBudr9IzHOR8fnFUH68dz1GsTQw" crossorigin="anonymous"></script>
19+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.2/katex.min.css" integrity="sha384-XFgyVzCwumZgSg6F85gbh6ev/BVWgP7QAb1V3GOchWQPifusZTU0ODnQsysBK61F" crossorigin="anonymous">
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.2/katex.min.js" integrity="sha384-RpxfKy6OA0Us+WtIGBbrVlfwW4HuETdB9CD8KbG6qSbYbCanfnyid62sojNvydoB" crossorigin="anonymous"></script>
2121
```
2222

2323
#### In-browser rendering

contrib/auto-render/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This extension isn't part of KaTeX proper, so the script should be separately
1010
included in the page:
1111

1212
```html
13-
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.1/contrib/auto-render.min.js" integrity="sha384-RkgGHBDdR8eyBOoWeZ/vpGg1cOvSAJRflCUDACusAAIVwkwPrOUYykglPeqWakZu" crossorigin="anonymous"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.2/contrib/auto-render.min.js" integrity="sha384-RkgGHBDdR8eyBOoWeZ/vpGg1cOvSAJRflCUDACusAAIVwkwPrOUYykglPeqWakZu" crossorigin="anonymous"></script>
1414
```
1515

1616
Then, call the exposed `renderMathInElement` function in a script tag

dockers/MathJaxFonts/Dockerfile

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ FROM ubuntu:14.04
22
MAINTAINER xymostech <xymostech@gmail.com>
33

44
# Install things
5-
RUN apt-get -qq update && apt-get -qqy install \
5+
RUN apt-get update \
6+
&& DEBIAN_FRONTEND=noninteractive apt-get -y upgrade \
7+
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
8+
--no-install-recommends --auto-remove \
69
git \
710
dvipng \
811
default-jre \
@@ -23,39 +26,41 @@ RUN apt-get -qq update && apt-get -qqy install \
2326
woff-tools \
2427
pkg-config \
2528
libharfbuzz-dev \
26-
libfreetype6-dev || true
27-
RUN gem install ttfunk --version 1.1.1
29+
libfreetype6-dev \
30+
&& apt-get clean \
31+
&& rm -rf /var/lib/apt/lists/* \
32+
&& gem install ttfunk --version 1.1.1
2833

2934
# Download yuicompressor
30-
RUN mkdir /usr/share/yui-compressor/
31-
RUN wget "https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.jar" -O /usr/share/yui-compressor/yui-compressor.jar
35+
ADD https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.jar /usr/share/yui-compressor/yui-compressor.jar
3236

3337
# Download batik-ttf2svg.jar
34-
RUN wget "https://archive.apache.org/dist/xmlgraphics/batik/batik-1.7.zip"
35-
RUN unzip -qq batik-1.7.zip
36-
RUN mv batik-1.7/batik-ttf2svg.jar /usr/share/java/
38+
RUN wget "https://archive.apache.org/dist/xmlgraphics/batik/batik-1.7.zip" \
39+
&& unzip batik-*.zip batik-*/batik-ttf2svg.jar \
40+
&& mv batik-*/batik-ttf2svg.jar /usr/share/java/ \
41+
&& rm -r batik-*
3742

3843
# Download and compile ttf2eof (note we add a patch to make it compile)
39-
RUN wget "https://ttf2eot.googlecode.com/files/ttf2eot-0.0.2-2.tar.gz"
40-
RUN tar -xzf ttf2eot-0.0.2-2.tar.gz
41-
RUN sed -i "1s/^/#include <cstddef>/" ttf2eot-0.0.2-2/OpenTypeUtilities.h
42-
RUN make -C ttf2eot-0.0.2-2/
43-
RUN mv ttf2eot-0.0.2-2/ttf2eot /usr/bin/
44+
RUN wget "https://github.com/wget/ttf2eot/archive/v0.0.2-2.tar.gz" -O ttf2eot.tar.gz\
45+
&& tar -xzf ttf2eot.tar.gz \
46+
&& sed -i "1s/^/#include <cstddef>/" ttf2eot-*/OpenTypeUtilities.h \
47+
&& make -C ttf2eot-*/ \
48+
&& mv ttf2eot-*/ttf2eot /usr/bin/ \
49+
&& rm -r ttf2eot*
4450

4551
# Download and compile ttfautohint
46-
RUN wget "http://download.savannah.gnu.org/releases/freetype/ttfautohint-1.3.tar.gz"
47-
RUN tar -xzf ttfautohint-1.3.tar.gz
48-
RUN cd ttfautohint-1.3/ && ./configure --without-qt
49-
RUN make -C ttfautohint-1.3/
50-
RUN mv ttfautohint-1.3/frontend/ttfautohint /usr/bin
52+
RUN wget "http://download.savannah.gnu.org/releases/freetype/ttfautohint-1.3.tar.gz" \
53+
&& tar -xzf ttfautohint-*.tar.gz \
54+
&& cd ttfautohint-*/ \
55+
&& ./configure --without-qt \
56+
&& make \
57+
&& mv frontend/ttfautohint /usr/bin \
58+
&& cd .. \
59+
&& rm -r ttfautohint-*
5160

5261
# Download and compile woff2_compress
53-
RUN git clone "https://code.google.com/p/font-compression-reference/" woff2_compress
54-
RUN make -C woff2_compress/woff2/
55-
RUN mv woff2_compress/woff2/woff2_compress /usr/bin/
56-
57-
# Download and setup MathJax-dev
58-
RUN git clone "https://github.com/khan/MathJax-dev.git"
59-
RUN cp MathJax-dev/default.cfg MathJax-dev/custom.cfg
60-
RUN make -C MathJax-dev custom.cfg.pl
61-
62+
RUN wget "https://github.com/google/woff2/archive/d9a74803fa884559879e3205cfe6f257a2d85519.tar.gz" -O woff2.tar.gz \
63+
&& tar -xzf woff2.tar.gz \
64+
&& make -C woff2-*/woff2/ \
65+
&& mv woff2-*/woff2/woff2_compress /usr/bin \
66+
&& rm -r woff2*

dockers/MathJaxFonts/README.md

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,22 @@
11
### How to generate MathJax fonts
22
---------------------------------
33

4-
It's really simple (now)! Just make a docker image from the included Dockerfile
5-
using a command like
6-
7-
sudo docker build --tag=mathjaxfonts .
8-
9-
from within this directory (note you need to have docker installed and running
10-
for this to work). This will build a docker image with the mathjaxfonts tag,
11-
which you can then use to run dockers based on them. Then, run a mathjaxfonts
12-
docker with
13-
14-
sudo docker run --interactive --tty --name mjf mathjaxfonts /bin/bash
15-
16-
We name this docker "mjf" so we can reference it later when we want to copy the
17-
files off. (If you get an error about the name being in use, perhaps because you
18-
are trying to create another docker, you can either delete the old docker with
19-
20-
sudo docker rm mjf
21-
22-
or use a different name.) This will get you into the docker in the root
23-
directory. From there, cd into the `/MathJax-dev/fonts/OTF/TeX` directory, and
24-
run
25-
26-
make ttf eot woff woff2
27-
28-
to build all of the fonts that we need. Finally, leave the docker and copy all
29-
the files off with the `copy_fonts.sh` script:
30-
31-
./copy_fonts.sh mjf
32-
33-
And you're good to go! Don't forget to update the font metrics with `make
34-
metrics`.
35-
36-
### General Docker Help
37-
-----------------------
38-
39-
When you quit the docker, it will stop the docker from running. If you want to
40-
reattach to the docker, you can start it again with
41-
42-
sudo docker start mjf
43-
44-
and then attach with
45-
46-
sudo docker attach mjf
47-
48-
Alternatively, if you want to detach from the docker when you're done instead of
49-
quitting and stopping it, you can detach with `C-p C-q`, and then re-attach with
50-
51-
sudo docker attach mjf
52-
53-
To see a list of your current dockers, you can run
54-
55-
docker ps
4+
The `buildFonts.sh` script should do everything automatically,
5+
as long as Docker is installed.
6+
7+
If you want to try out a change
8+
to [the MathJax-dev repository](https://github.com/Khan/MathJax-dev),
9+
create a local clone (or download and unpack the ZIP file)
10+
and specify the path to this directory as an arument to `buildFonts.sh`.
11+
You can also specify a local or remote tarball,
12+
e.g. a GitHub download of your own personal feature branch.
13+
14+
The script `buildFonts.sh` automatically creates Docker images
15+
from the supplied `Dockerfile`.
16+
It uses the hash of the file to tag the image, so a change to the file
17+
will result in the creation of a new image.
18+
If you want to see all created images, run `docker images katex/fonts`.
19+
To remove all generated images, you can run
20+
`docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' katex/fonts)`.
21+
22+
If there is a problem, file a bug report.

dockers/MathJaxFonts/buildFonts.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/usr/bin/env bash
2+
shopt -s extglob
3+
4+
usage() {
5+
while [[ $# -gt 1 ]]; do
6+
echo "$1" >&2
7+
shift
8+
done
9+
echo "Usage: ${0##*/} [OPTIONS] [SOURCE]"
10+
echo ""
11+
echo "SOURCE may be"
12+
echo " - a URL for a tarball, or"
13+
echo " - a local tarball file, or"
14+
echo " - a local directory"
15+
echo "with a layout compatible to MathJax-dev."
16+
echo "It defaults to ${URL}"
17+
echo ""
18+
echo "OPTIONS:"
19+
echo " -h|--help display this help"
20+
echo " --image NAME:TAG use the named docker image [$IMAGE]"
21+
exit $1
22+
}
23+
24+
used_fonts=(
25+
KaTeX_AMS-Regular
26+
KaTeX_Caligraphic-Bold
27+
KaTeX_Caligraphic-Regular
28+
KaTeX_Fraktur-Bold
29+
KaTeX_Fraktur-Regular
30+
KaTeX_Main-Bold
31+
KaTeX_Main-Italic
32+
KaTeX_Main-Regular
33+
KaTeX_Math-BoldItalic
34+
KaTeX_Math-Italic
35+
KaTeX_Math-Regular
36+
KaTeX_SansSerif-Bold
37+
KaTeX_SansSerif-Italic
38+
KaTeX_SansSerif-Regular
39+
KaTeX_Script-Regular
40+
KaTeX_Size1-Regular
41+
KaTeX_Size2-Regular
42+
KaTeX_Size3-Regular
43+
KaTeX_Size4-Regular
44+
KaTeX_Typewriter-Regular
45+
)
46+
47+
filetypes=( ttf eot woff woff2 )
48+
49+
set -e
50+
cd "$(dirname "$0")"
51+
52+
cleanup() {
53+
[[ "${CONTAINER}" ]] \
54+
&& docker stop "${CONTAINER}" >/dev/null \
55+
&& docker rm "${CONTAINER}" >/dev/null
56+
CONTAINER=
57+
[[ -f "${TMPFILE}" ]] && rm "${TMPFILE}"
58+
TMPFILE=
59+
}
60+
CONTAINER=
61+
trap cleanup EXIT
62+
63+
IMAGE="katex/fonts:DF-$(openssl sha1 Dockerfile | tail -c 9)"
64+
URL=https://github.com/Khan/MathJax-dev/archive/master.tar.gz
65+
TMPFILE=
66+
FILE=
67+
NARGS=0
68+
while [[ $# -gt 0 ]]; do
69+
case "$1" in
70+
-h|--help)
71+
usage 0
72+
;;
73+
--image=*)
74+
IMAGE="${1#*=}"
75+
;;
76+
--image)
77+
shift
78+
IMAGE="$1"
79+
;;
80+
-*)
81+
usage "Invalid option: $1" "" 1
82+
;;
83+
*)
84+
case $NARGS in
85+
0)
86+
if [[ -d "$1" ]]; then
87+
TMPFILE="$(mktemp "${TMPDIR:-/tmp}/mjf.XXXXXXXX")"
88+
FILE="$TMPFILE"
89+
pushd "$1"
90+
if [[ ! -f fonts/OTF/TeX/Makefile ]]; then
91+
echo "$1 does not look like MathJax-dev" >&2
92+
exit 1
93+
fi
94+
tar cf "$FILE" Makefile default.cfg fonts/OTF/TeX
95+
popd
96+
elif [[ -f "$1" ]]; then
97+
FILE="$1"
98+
elif [[ "$1" = http?(s)://* ]]; then
99+
URL="$1"
100+
else
101+
echo "'$1' is not a valid source" >&2
102+
exit 1
103+
fi
104+
NARGS=1
105+
;;
106+
*)
107+
usage "Too many arguments: $1" "" 1
108+
;;
109+
esac
110+
;;
111+
esac
112+
shift
113+
done
114+
115+
# build image if missing
116+
if [[ $(docker images "$IMAGE" | wc -l) -lt 2 ]]; then
117+
echo "Need to build docker image $IMAGE"
118+
docker build --tag "$IMAGE" .
119+
fi
120+
121+
CMDS="set -ex
122+
test -f MathJax-dev.tar.gz || wget -O MathJax-dev.tar.gz '${URL}'
123+
mk=\$(tar tf MathJax-dev.tar.gz | grep 'fonts/OTF/TeX/Makefile\$')
124+
tar xf MathJax-dev.tar.gz
125+
cd \"\${mk%fonts/*}\"
126+
cp default.cfg custom.cfg
127+
make custom.cfg.pl
128+
make -C fonts/OTF/TeX ${filetypes[*]}
129+
tar cf /fonts.tar ${filetypes[*]/#/fonts/OTF/TeX/}"
130+
131+
echo "Creating and starting docker container from image $IMAGE"
132+
CONTAINER=$(docker create "$IMAGE" /bin/sh -c "${CMDS}")
133+
if [[ ${FILE} ]]; then
134+
docker cp "${FILE}" $CONTAINER:/MathJax-dev.tar.gz
135+
fi
136+
docker start --attach $CONTAINER
137+
docker cp $CONTAINER:/fonts.tar .
138+
cleanup
139+
echo "Docker executed successfully, will now unpack the fonts"
140+
141+
tar xf fonts.tar
142+
for filetype in "${filetypes[@]}"; do
143+
for font in "${used_fonts[@]}"; do
144+
echo "$filetype/$font"
145+
mv "fonts/OTF/TeX/$filetype/$font".* ../../static/fonts/
146+
done
147+
done
148+
rm -rf fonts fonts.tar

dockers/MathJaxFonts/copy_fonts.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

hooks/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec make lint

0 commit comments

Comments
 (0)