Files
KaTeX/Makefile
Erik Demaine 484d44ee70 Unicode accents (#992)
* Unicode accents

* Lexer now looks for combining dicritical marks and adds them to the same character
* Parser's `parseSymbol` now recognizes both combined and uncombined forms of Unicode accents, and builds accent objects just like the accent functions
* Added CJK support to math mode (not just text mode)

* Add invalid combining character test

* Add MathML test

* Add weak support for other Latin-1 characters

This maintains backwards compatibility, but it uses the wrong font.
There's a TODO to fix this later.

Also refactor symbol code to use for..of

* Update Unicode screenshot

* Remove dot from accented i and j (in math mode)

Also add dotless Unicode characters to support some accented i's and j's

* Fix \imath, \jmath, \pounds, and more tests

* Switch from for..of to .split().forEach()

Save around 800 bytes in minified code

* Fix split

* normalize() detection

* Convert back to vanilla for loops

* Fix merge

* Move normalize dependency to unicodeMake.js

* Make unicodeSymbols into a lookup table instead of macros

This is important for multi-accented characters.

* Add comments about when to run

* Move symbols definition into unicodeMake/Symbols.js

* Remove CJK support in text mode

* Add missing semicolon

* Refactor unicodeAccents to its own file

* Dotless i/j support in text mode

* Remove excess character mappings

* Fix Åå in math mode (still via Times)

* Update to support #1030

* Add accented Greek letter support (for supported Greek symbols)

* Update screenshot

* remove Æ, æ, Ø, ø, and ß from math mode test
2017-12-28 23:32:45 -07:00

135 lines
3.6 KiB
Makefile

.PHONY: build dist lint setup copy serve clean metrics test coverage zip contrib flow
build: test build/katex.min.js build/katex.min.css contrib zip compress
ifeq ($(KATEX_DIST),skip)
dist:
else
dist: build
rm -rf dist/
cp -R build/katex/ dist/
endif
NODE := node # pass NODE=nodejs on Debian without package nodejs-legacy
NPM := npm
NODECHK := $(shell $(NODE) ./check-node-version.js)
ifneq ($(NODECHK),OK)
$(error "Node not found or wrong version")
endif
# Export these variables for use in contrib Makefiles
export BUILDDIR = $(realpath build)
export BROWSERIFY = $(realpath ./node_modules/.bin/browserify)
export UGLIFYJS = $(realpath ./node_modules/.bin/uglifyjs) \
--mangle \
--beautify \
ascii_only=true,beautify=false
export CLEANCSS = $(realpath ./node_modules/.bin/cleancss)
# The prepublish script in package.json will override the following variable,
# setting it to the empty string and thereby avoiding an infinite recursion
NIS = .npm-install.stamp
$(NIS) setup: package.json
KATEX_DIST=skip npm install # dependencies only, don't build
@touch $(NIS)
lint: $(NIS)
$(NPM) run lint
build/katex.js: katex.js $(wildcard src/*.js) $(NIS)
mkdir -p build
$(BROWSERIFY) -t [ babelify ] $< --standalone katex > $@
build/katex.min.js: build/katex.js
mkdir -p build
$(UGLIFYJS) < $< > $@
build/katex.css: static/katex.less $(wildcard static/*.less) $(NIS)
mkdir -p build
./node_modules/.bin/lessc $< $@
build/katex.min.css: build/katex.css
mkdir -p build
$(CLEANCSS) -o $@ $<
.PHONY: build/fonts
build/fonts:
rm -rf $@
mkdir $@
for font in $(shell grep "font" static/katex.less | grep -o "KaTeX_\w\+" | cut -d" " -f 2 | sort | uniq); do \
cp submodules/katex-fonts/fonts/$$font* $@; \
done
test/screenshotter/unicode-fonts:
git clone https://github.com/Khan/KaTeX-test-fonts test/screenshotter/unicode-fonts
cd test/screenshotter/unicode-fonts && \
git checkout 99fa66a2da643218754c8236b9f9151cac71ba7c && \
cd ../../../
contrib: build/contrib
.PHONY: build/contrib
build/contrib:
mkdir -p build/contrib
@# Since everything in build/contrib is put in the built files, make sure
@# there's nothing in there we don't want.
rm -rf build/contrib/*
$(MAKE) -C contrib/auto-render
$(MAKE) -C contrib/copy-tex
$(MAKE) -C contrib/mathtex-script-type
.PHONY: build/katex
build/katex: build/katex.js build/katex.min.js build/katex.css build/katex.min.css build/fonts README.md build/contrib
mkdir -p build/katex
rm -rf build/katex/*
cp -r $^ build/katex
build/katex.tar.gz: build/katex
cd build && tar czf katex.tar.gz katex/
build/katex.zip: build/katex
rm -f $@
cd build && zip -rq katex.zip katex/
zip: build/katex.tar.gz build/katex.zip
compress: build/katex.min.js build/katex.min.css
@JSSIZE=`gzip -c build/katex.min.js | wc -c`; \
CSSSIZE=`gzip -c build/katex.min.css | wc -c`; \
TOTAL=`echo $${JSSIZE}+$${CSSSIZE} | bc`; \
printf "Minified, gzipped js: %6d\n" "$${JSSIZE}"; \
printf "Minified, gzipped css: %6d\n" "$${CSSSIZE}"; \
printf "Total: %6d\n" "$${TOTAL}"
serve: $(NIS)
$(NPM) start
flow: $(NIS)
$(NPM) run flow
test: $(NIS)
$(NPM) test
coverage: $(NIS)
$(NPM) run coverage
PERL=perl
PYTHON=$(shell python2 --version >/dev/null 2>&1 && echo python2 || echo python)
metrics:
cd metrics && $(PERL) ./mapping.pl | $(PYTHON) ./extract_tfms.py | $(PYTHON) ./extract_ttfs.py | $(PYTHON) ./format_json.py --width > ../src/fontMetricsData.js
unicode:
cd src && $(NODE) unicodeMake.js >unicodeSymbols.js
src/unicodeSymbols.js: unicode
clean:
rm -rf build/* $(NIS)
screenshots: test/screenshotter/unicode-fonts $(NIS)
dockers/Screenshotter/screenshotter.sh