abe2daf0f3 | ||
---|---|---|
.. | ||
fonts | ||
README.md | ||
copy-tex.min.js | ||
katex.min.css | ||
katex.min.js | ||
mhchem.min.js |
README.md
How to update KaTeX for Discourse without building
- Fetch the latest release tarball
- Copy fonts
- Copy JS and CSS
- Replace font paths in CSS
DMPATH=/path/to/discourse-math # set this to your path to the discourse-math repo
cd /tmp
wget -O- https://github.com/KaTeX/KaTeX/releases/latest/download/katex.tar.gz | tar -zx
cp katex/fonts/*.woff* $DMPATH/public/katex/fonts/
cp katex/katex.min.* katex/contrib/{mhchem,copy-tex}.min.js $DMPATH/public/katex/
sed -i "s~url(fonts/~url(/plugins/discourse-math/katex/fonts/~g" $DMPATH/public/katex/katex.min.css
How to build KaTeX for Discourse
-
git clone https://github.com/KaTeX/KaTeX.git && cd KaTeX
git submodule update --init --recursive
-
Disable TTF fonts:
export USE_TTF=false
-
Run build to fetch the fonts into
dist/fonts/
npm run build
-
Copy fonts to this plugin
cp dist/fonts/* discourse-math/public/katex/fonts/
-
Change paths to fonts ((otherwise the fonts won't load in Discourse):
sed -ri 's/@font-folder.+$/@font-folder: "\/plugins\/discourse-math\/katex\/fonts";/' submodules/katex-fonts/fonts.less
-
Build KaTeX:
yarn && yarn builld
-
Copy
katex.min.js
andkatex.min.css
fromdist/
todiscourse-math/public/katex/