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
|
# File 'lib/metanorma/standoc/latexml_requirement.rb', line 9
def initialize
version_output, = Open3.capture2e("latexml --VERSION")
version = version_output&.match(%r{\d+(.\d+)*})
if version.to_s.empty?
@error_message = "LaTeXML is not available. (Or is PATH not setup properly?)"\
" You must upgrade/install LaTeXML to a version higher than `#{@recommended_version}`"
elsif Gem::Version.new(version) < Gem::Version.new(@minimal_version)
@error_message = "Minimal supported LaTeXML version is `#{@minimal_version}` "\
"Version `#{version}` found; recommended version is `#{@recommended_version}`"
elsif Gem::Version.new(version) < Gem::Version.new(@recommended_version)
version = "unknown" if version.to_s.empty?
= "latexmlmath version `#{version}` below `#{@recommended_version}`!"
suggestion = if Gem.win_platform?
"cmd encoding is set to UTF-8 with `chcp 65001`"
else
"terminal encoding is set to UTF-8 with `export LANG=en_US.UTF-8`"
end
@error_message = "WARNING #{} Please sure that #{suggestion} command."
@cmd = 'latexmlmath --strict --preload=amsmath -- -'
@cmd2 = 'latexmlmath --strict -- -'
else
@cmd = 'latexmlmath --strict --preload=amsmath --inputencoding=UTF-8 -- -'
@cmd2 = 'latexmlmath --strict --inputencoding=UTF-8 -- -'
end
rescue
@error_message = "LaTeXML is not available. (Or is PATH not setup properly?)"\
" You must upgrade/install LaTeXML to a version higher than `#{@recommended_version}`"
end
|