.PHONY: test-all test-internal SHELL=/bin/bash return_statement_line_number := $(shell grep -nE '^return' text-crossrefs.lua | cut -d ':' -f 1) line_before_return := $(shell echo $$(($(return_statement_line_number) - 1))) README.pdf: README.md sed -E 's/(C?[Lo]?[an]?TeXt?)/\\\1{}/g' $< | \ sed '7s/^/\\def\\ConTeXt{C\\kern-.0333em on\\kern-.0667em\\TeX\\kern-.0333em t}\\pagebreak /' | \ pandoc -M colorlinks=true --toc -N --syntax-highlighting=none -o $@ test-all: test-internal test-context test-latex test-opendocument test-typst test-internal: text-crossrefs.lua -rm --interactive=never test/tmp.lua sed -n 1,$(line_before_return)p text-crossrefs.lua > test/tmp.lua cat test/test-functions.lua >> test/tmp.lua chmod -w test/tmp.lua pandoc -L test/tmp.lua <<< '' @echo -e '==========================\nAll internal tests passed.\n==========================\n' rm --interactive=never test/tmp.lua samples := '' -with-options test-%: text-crossrefs.lua sample.md @$(foreach suffix,$(samples), \ TESTED_FORMAT=$* pandoc -t native -L text-crossrefs.lua sample$(suffix).md > test/tmp-$*$(suffix).native ;\ diff test/tmp-$*$(suffix).native test/sample-$*$(suffix).native ;\ if [[ $$? == 0 ]]; then \ echo -e '\n=== $*$(suffix): passed\n' ;\ else \ echo -e '\n=== $*$(suffix): FAILED\n' ;\ fi ;\ rm test/tmp-$*$(suffix).native ;\ ) update-test-files: for f in typst opendocument latex context ; do \ for v in '' -with-options ; do \ TESTED_FORMAT=$$f pandoc -L text-crossrefs.lua -t native \ -o test/sample-$$f$$v.native sample$$v.md ; \ done ; \ done