Sha256: 098f5aae1b55780d14f6268a6091667f1213103fdb12ae0dbc61e2089335bd8f

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

require_relative "./requirement"

module Metanorma
  module Standoc
    class LatexmlRequirement < Requirement
      def initialize
        @recommended_version = '0.8.4'
        @minimal_version = '0.8.0'
        version_output, = Open3.capture2e("latexml --VERSION")
        @actual_version = version_output&.match(%r{\d+(.\d+)*})
      end

      def satisfied
        version = @actual_version

        if version.to_s.empty?
          abort "LaTeXML not found in PATH, please make sure that you installed LaTeXML"
        end

        if Gem::Version.new(version) < Gem::Version.new(@minimal_version)
          abort "Minimal supported LaTeXML version is #{@minimal_version} "\
                "found #{version}, recommended version is #{@recommended_version}"
        end
        
        if Gem::Version.new(version) < Gem::Version.new(@recommended_version)
          version = "unknown" if version.to_s.empty?
          header_msg = "WARNING 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

          warn "#{header_msg} Please sure that #{suggestion} command"

          @cmd = "latexmlmath --preload=amsmath -- -"
        else
          @cmd = "latexmlmath --preload=amsmath --inputencoding=UTF-8 -- -"
        end
      end

      def cmd
        @cmd
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metanorma-standoc-1.2.4 lib/metanorma/standoc/latexml_requirement.rb
metanorma-standoc-1.2.3 lib/metanorma/standoc/latexml_requirement.rb