-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
47 lines (43 loc) · 1.64 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'test'
end
desc "Run tests"
task default: [:test]
namespace :dev do
desc "Check for SsKaTeX availability"
task :test_sskatex_deps do
katexjs = 'katex/katex.min.js'
raise (<<TKJ) unless File.exists? katexjs
Cannot find file '#{katexjs}'.
You need to download KaTeX e.g. from https://github.com/Khan/KaTeX/releases/
and extract at least '#{katexjs}'.
Alternatively, if you have a copy of KaTeX unpacked somewhere else,
you can create a symbolic link 'katex' pointing to that KaTeX directory.
TKJ
html = `echo a | #{RbConfig.ruby} -Ilib bin/sskatex -v`
raise (<<KTC) unless $?.success?
Some requirement by SsKaTeX or the employed JS engine has not been satisfied.
Cf. the above error messages.
If you 'gem install sskatex', also make sure that some JS engine is available,
e.g. by installing one of the gems 'duktape', 'therubyracer', or 'therubyrhino'.
KTC
raise (<<XJS) unless / class="katex"/ === html
Hmmm... SsKaTeX produces output which does not seem like KaTeX output.
You are experimenting, huh?
XJS
puts "SsKaTeX is available, and its default configuration works."
end
desc "Update SsKaTeX test reference outputs"
task update_katex_tests: [:test_sskatex_deps] do
# Not framed in terms of rake file tasks to prevent accidental overwrites.
['block', 'span'].each do |display|
Dir['test/tex/*.tex'].each do |texfile|
stem = File.basename(texfile, '.tex')
html = File.join('test', display, stem + '.html')
disp = "--#{'no-' if display != 'block'}display"
ruby "-Ilib bin/sskatex #{disp} #{texfile} #{html}"
end
end
end
end