Sha256: 622bcc53530c37a9cf49a7db075bcbe182ffc1d3a42cea921f119da9b1e43447

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 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+)*})
      rescue
        warn "LaTeXML not found in PATH, please ensure that LaTeXML is installed."
      end

      def satisfied
        version = @actual_version

        if version.to_s.empty?
          abort "LaTeXML not found in PATH, please ensure that LaTeXML is installed."
        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
        if @cmd.nil?
          satisfied
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
metanorma-standoc-1.3.2 lib/metanorma/standoc/latexml_requirement.rb
metanorma-standoc-1.3.1 lib/metanorma/standoc/latexml_requirement.rb
metanorma-standoc-1.3.0 lib/metanorma/standoc/latexml_requirement.rb