1
1
mirror of https://github.com/varkor/quiver.git synced 2024-08-16 01:00:46 +03:00

Use prebuilt release of KaTeX rather than a git submodule

This commit is contained in:
varkor 2021-01-02 13:32:58 +00:00
parent c5818ced70
commit 14c85349ff
6 changed files with 13 additions and 50 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
src/KaTeX/*

4
.gitmodules vendored
View File

@ -1,4 +0,0 @@
[submodule "src/KaTeX"]
path = src/KaTeX
url = https://github.com/KaTeX/KaTeX.git
shallow = true

View File

@ -6,10 +6,10 @@
# Build KaTeX.
all:
set -e
git submodule update --init --recursive
cd src/KaTeX
yarn
yarn build
curl -L -O "https://github.com/KaTeX/KaTeX/releases/download/v0.12.0/katex.zip"
unzip katex.zip
rm katex.zip
mv katex src/KaTeX
# Update the `dev` branch from `master`.
dev:
@ -55,7 +55,6 @@ gh-pages:
# for `subtree split` later, which has to iterate through the entire history of the branch.
git reset $$TAIL
git add -A
git rm -r --cached src/KaTeX
git commit -m "Add release branch"
# Split off the `src/` directory into its own branch.
RELEASE=$$(git subtree split --prefix=src)
@ -65,7 +64,6 @@ gh-pages:
git checkout -b squashed
git reset $$TAIL
git add -A
git rm -r --cached src/KaTeX
git commit -m "Add dev branch"
DEV=$$(git subtree split --prefix=src)
@ -77,23 +75,6 @@ gh-pages:
# Reset the GitHub Pages branch so that it contains the release source code.
git reset --hard $$RELEASE
# Clone the existing version of KaTeX into the worktree.
git clone $$KATEX KaTeX
# We are assuming KaTeX has already been built.
# Remove `.git` and associated files, so KaTeX is no longer recognised as a git repository.
cd KaTeX
rm -rf .git
rm .gitignore
rm .gitmodules
# We need to be able to commit KaTeX as a plain directory, so we have to unregister it as a
# submodule. The cloned repository by default won't contain any `.gitignore`d files, but we
# actually want the `dist/`, directory, which contains various resources, e.g. fonts, so we copy
# it across ourselves.
cp -r $$KATEX/dist .
cd ../
git add -A
git commit -m "Add KaTeX"
# Merge the development branch into the `dev/` directory.
git merge -s ours --no-commit $$DEV
git read-tree --prefix=dev -u $$DEV

View File

@ -82,21 +82,12 @@ Currently, macros may be defined using `\newcommand`, and colours may be defined
`\definecolor` (using the colour modes: `rgb`, `RGB` or `gray`).
## Building
Make sure you have [installed yarn](https://yarnpkg.com/lang/en/docs/install/) and have a version of
Make that supports `.ONESHELL` (e.g. GNU Make 3.82).
Run `make` from the command land, and then open `src/index.html` in your favourite web browser.
Clone the repository, and run
```shell
make
```
which will build KaTeX. Then simply open `src/index.html` in your favourite web browser.
**Note for macOS users:** the default version of Make on macOS is GNU Make 3.81, which does not
contain support for `.ONESHELL`. You may need to update Make to run the Makefile.
**Note for Ubuntu users:** the cmdtest package that comes with Ubuntu conflicts with the yarn
installation. You may need to [uninstall cmdtest](https://github.com/varkor/quiver/issues/48) to
install yarn.
If this fails, you might be using an incompatible version of Make or Bash. In this case, you can
manually download the [latest release](https://github.com/KaTeX/KaTeX/releases) of KaTeX and place
it under `src/` as `src/KaTeX/`. Then open `src/index.html` in your favourite web browser. If KaTeX
has not been given the correct path, you will get an error telling you that KaTeX failed to load.
If you have any other problems building **quiver**, [open an
issue](https://github.com/varkor/quiver/issues/new) detailing the problem and I'll try to help.

6
src/.gitmodules vendored
View File

@ -1,6 +0,0 @@
# [submodule "MathJax"]
# path = MathJax
# url = https://github.com/mathjax/MathJax.git
[submodule "KaTeX"]
path = KaTeX
url = https://github.com/KaTeX/KaTeX.git

View File

@ -6595,7 +6595,7 @@ document.addEventListener("DOMContentLoaded", () => {
// Immediately load the KaTeX library.
const rendering_library = new DOM.Element("script", {
type: "text/javascript",
src: "KaTeX/dist/katex.js",
src: "KaTeX/katex.min.js",
}).listen("error", () => {
// Handle KaTeX not loading (somewhat) gracefully.
UI.display_error(`KaTeX failed to load.`)
@ -6614,14 +6614,14 @@ document.addEventListener("DOMContentLoaded", () => {
// Load the style sheet needed for KaTeX.
document.head.appendChild(new DOM.Element("link", {
rel: "stylesheet",
href: "KaTeX/dist/katex.css",
href: "KaTeX/katex.css",
}).element);
// Preload various fonts to avoid flashes of unformatted text.
const preload_fonts = ["Main-Regular", "Math-Italic"];
for (const font of preload_fonts) {
const attributes = {
rel: "preload",
href: `KaTeX/dist/fonts/KaTeX_${font}.woff2`,
href: `KaTeX/fonts/KaTeX_${font}.woff2`,
as: "font"
};
if (window.location.hostname !== "") {