metanorma-standoc 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f0296f73b69a974d8471004f27194fd72f0005a4b9b76ea99c5fc0ad8828734
4
- data.tar.gz: dfdba4afa101c91c4d83697876770fd2ea26da7a197702a1a3087157e257bf66
3
+ metadata.gz: 2fa7cc0e4e5c2924e92c7c4dd3cf6b55a3cc5374a9a65b1fe4a6b6f25bbe4130
4
+ data.tar.gz: 234c872403176e8a697f7e8380be547be37e774e7ac39a28aed6fc1142d31668
5
5
  SHA512:
6
- metadata.gz: 5891c907305ea29a718370385a72ae3cc8156f42562fabda70dce276d740cf20160da3d84dda0be783315b5b287bab3732bb03fb33dfdfe59587f03100347d27
7
- data.tar.gz: 11a9e73079c234d6db80af6d500ce24e8847b4c5fc40cf2e4aadd08ee520462248ccd1e1ff5c77e4dd84fb241ada3821cecc70f4d610179655d55bc49e041caf
6
+ metadata.gz: cbef9d2a3d3f39105b100bd122153af812322aec99e4b05fc83f45579d0b1cc59d8606a860be9f3a104f3169557bf61cd5949c4424fd3cd692cbb20a5b7775c6
7
+ data.tar.gz: 7c73c0f914d76af8b2b4f3be93e68c49baeea4791976f423ae4198b9d99f1066ee21616edcbfba660d0a2dc91bb87f6d014e01726018468e177db8031af550a5
@@ -4,14 +4,22 @@ os:
4
4
  - linux
5
5
  - osx
6
6
  rvm:
7
+ - 2.6
7
8
  - 2.5
8
9
  - 2.4
9
10
  - ruby-head
10
11
  before_install:
12
+ - nvm install 8
13
+ - npm install -g puppeteer
14
+ - npm install
15
+ - curl -L https://cpanmin.us | perl - --sudo App::cpanminus
16
+ - sudo cpanm --notest LaTeXML@0.8.4
17
+ - curl -L https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/travis.sh | bash
18
+ - plantuml -version
11
19
  - gem install bundler -v 2.0.1
12
20
  - bundle update
13
21
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash -c "apt-get update && curl -L https://raw.githubusercontent.com/metanorma/metanorma-linux-setup/master/ubuntu.sh | bash" ; fi
14
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install --HEAD https://raw.githubusercontent.com/metanorma/homebrew-metanorma/master/Formula/metanorma.rb ; fi
22
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then travis_wait brew install --HEAD https://raw.githubusercontent.com/metanorma/homebrew-metanorma/master/Formula/metanorma.rb ; fi
15
23
  matrix:
16
24
  allow_failures:
17
25
  - rvm: ruby-head
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-standoc (1.2.2)
4
+ metanorma-standoc (1.2.3)
5
5
  asciidoctor (~> 1.5.7)
6
6
  concurrent-ruby
7
7
  html2doc (~> 0.8.11)
8
8
  iev (~> 0.2.1)
9
9
  isodoc (~> 0.10.0)
10
- relaton (~> 0.4.0)
10
+ relaton (~> 0.5.0)
11
+ relaton-iev (~> 0.1.0)
11
12
  ruby-jing
12
13
  sterile (~> 1.0.14)
13
14
  unicode2latex (~> 0.0.1)
@@ -50,7 +51,7 @@ GEM
50
51
  guard (~> 2.1)
51
52
  guard-compat (~> 1.1)
52
53
  rspec (>= 2.99.0, < 4.0)
53
- hashdiff (0.4.0)
54
+ hashdiff (1.0.0)
54
55
  html2doc (0.8.12)
55
56
  asciimath (~> 1.0.7)
56
57
  htmlentities (~> 4.3.4)
@@ -64,7 +65,7 @@ GEM
64
65
  iev (0.2.2)
65
66
  nokogiri
66
67
  image_size (2.0.2)
67
- isodoc (0.10.2)
68
+ isodoc (0.10.3)
68
69
  asciimath
69
70
  html2doc (~> 0.8.11)
70
71
  htmlentities (~> 4.3.4)
@@ -91,10 +92,10 @@ GEM
91
92
  mime-types (3.2.2)
92
93
  mime-types-data (~> 3.2015)
93
94
  mime-types-data (3.2019.0331)
94
- mini_portile2 (2.3.0)
95
+ mini_portile2 (2.4.0)
95
96
  nenv (0.3.0)
96
- nokogiri (1.8.5)
97
- mini_portile2 (~> 2.3.0)
97
+ nokogiri (1.10.3)
98
+ mini_portile2 (~> 2.4.0)
98
99
  notiffany (0.1.1)
99
100
  nenv (~> 0.1)
100
101
  shellany (~> 0.0)
@@ -108,44 +109,44 @@ GEM
108
109
  method_source (~> 0.9.0)
109
110
  public_suffix (3.1.1)
110
111
  rainbow (3.0.0)
111
- rake (12.3.2)
112
+ rake (12.3.3)
112
113
  rb-fsevent (0.10.3)
113
114
  rb-inotify (0.10.0)
114
115
  ffi (~> 1.0)
115
- relaton (0.4.3)
116
+ relaton (0.5.0)
116
117
  algoliasearch
117
- relaton-gb (~> 0.5.0)
118
- relaton-iec (~> 0.3.0)
119
- relaton-ietf (~> 0.5.0)
120
- relaton-iso (~> 0.5.0)
121
- relaton-iso-bib (~> 0.2.0)
122
- relaton-itu (~> 0.2.0)
123
- relaton-nist (~> 0.2.0)
124
- relaton-bib (0.2.4)
118
+ relaton-gb (~> 0.6.0)
119
+ relaton-iec (~> 0.4.0)
120
+ relaton-ietf (~> 0.6.0)
121
+ relaton-iso (~> 0.6.0)
122
+ relaton-iso-bib (~> 0.3.0)
123
+ relaton-itu (~> 0.3.0)
124
+ relaton-nist (~> 0.3.0)
125
+ relaton-bib (0.3.1)
125
126
  addressable
126
- nokogiri (~> 1.8.4)
127
- relaton-gb (0.5.1)
127
+ nokogiri (~> 1.10)
128
+ relaton-gb (0.6.0)
128
129
  cnccs (~> 0.1.1)
129
130
  gb-agencies (~> 0.0.1)
130
- relaton-iso-bib (~> 0.2.0)
131
- relaton-iec (0.3.1)
131
+ relaton-iso-bib (~> 0.3.0)
132
+ relaton-iec (0.4.1)
132
133
  addressable
133
- relaton-iso-bib (~> 0.2.0)
134
- relaton-ietf (0.5.4)
135
- relaton-iso-bib (~> 0.2.0)
136
- relaton-iso (0.5.3)
137
- algoliasearch
138
- relaton-iec (~> 0.3.0)
139
- relaton-iso-bib (~> 0.2.0)
140
- relaton-iso-bib (0.2.3)
134
+ relaton-iso-bib (~> 0.3.0)
135
+ relaton-ietf (0.6.0)
136
+ relaton-iso-bib (~> 0.3.0)
137
+ relaton-iev (0.1.1)
138
+ relaton (~> 0.5.0)
139
+ relaton-iso (0.6.1)
140
+ relaton-iec (~> 0.4.0)
141
+ relaton-iso-bib (~> 0.3.0)
142
+ relaton-iso-bib (0.3.1)
141
143
  isoics (~> 0.1.6)
142
- nokogiri (~> 1.8.4)
143
- relaton-bib (~> 0.2.0)
144
+ relaton-bib (~> 0.3.0)
144
145
  ruby_deep_clone (~> 0.8.0)
145
- relaton-itu (0.2.2)
146
- relaton-iso-bib (~> 0.2.0)
147
- relaton-nist (0.2.2)
148
- relaton-bib (~> 0.2.0)
146
+ relaton-itu (0.3.0)
147
+ relaton-iso-bib (~> 0.3.0)
148
+ relaton-nist (0.3.0)
149
+ relaton-bib (~> 0.3.0)
149
150
  rubyzip
150
151
  roman-numerals (0.3.0)
151
152
  rspec (3.8.0)
@@ -2,6 +2,7 @@ version: '{build}'
2
2
 
3
3
  environment:
4
4
  matrix:
5
+ - RUBY_VERSION: 26
5
6
  - RUBY_VERSION: 25
6
7
  - RUBY_VERSION: 24
7
8
  - RUBY_VERSION: _trunk
@@ -16,7 +17,6 @@ install:
16
17
  - refreshenv
17
18
  - set PATH=C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;%PATH%
18
19
  - where latexmlmath
19
- - chcp 65001
20
20
 
21
21
  build_script:
22
22
  - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
@@ -7,6 +7,7 @@ require "pp"
7
7
  require_relative "./cleanup_block.rb"
8
8
  require_relative "./cleanup_footnotes.rb"
9
9
  require_relative "./cleanup_ref.rb"
10
+ require "relaton_iev"
10
11
 
11
12
  module Asciidoctor
12
13
  module Standoc
@@ -42,8 +43,8 @@ module Asciidoctor
42
43
  reference_names(xmldoc)
43
44
  xref_cleanup(xmldoc)
44
45
  origin_cleanup(xmldoc)
45
- iev_cleanup(xmldoc)
46
- element_name_cleanup(xmldoc) # cleanup IEV
46
+ RelatonIev::iev_cleanup(xmldoc, @bibdb)
47
+ element_name_cleanup(xmldoc)
47
48
  bpart_cleanup(xmldoc)
48
49
  quotesource_cleanup(xmldoc)
49
50
  para_cleanup(xmldoc)
@@ -122,6 +122,7 @@ module Asciidoctor
122
122
  end
123
123
  end
124
124
 
125
+ =begin
125
126
  # converts generic IEV citation to citation of IEC 60050-n
126
127
  # assumes IEV citations are of form
127
128
  # <eref type="inline" bibitemid="a" citeas="IEC 60050">
@@ -146,7 +147,7 @@ module Asciidoctor
146
147
  parts.sort.each do |p|
147
148
  hit = @bibdb&.fetch("IEC 60050-#{p}", nil, keep_year: true) || next
148
149
  new_iev += hit.to_xml.sub(/ id="[^"]+"/, %{ id="IEC60050-#{p}"})
149
- date = hit.dates[0].on.year
150
+ date = hit.date[0].on.year
150
151
  xmldoc.xpath("//*[@citeas = 'IEC 60050-#{p}:2011']").each do |x|
151
152
  x["citeas"] = x["citeas"].sub(/:2011$/, ":#{date}")
152
153
  end
@@ -160,11 +161,11 @@ module Asciidoctor
160
161
  parts = linksIev2iec60050part(xmldoc)
161
162
  refsIev2iec60050part(xmldoc, parts, iev)
162
163
  end
164
+ =end
163
165
 
164
166
  def ref_dl_cleanup(xmldoc)
165
167
  xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
166
168
  bib = dl_bib_extract(c) or next
167
- #bibitemxml = Relaton::Bibdata.new(bib).to_xml or next
168
169
  bibitemxml = RelatonBib::BibliographicItem.new(
169
170
  RelatonBib::hash_to_bib(bib)).to_xml or next
170
171
  bibitem = Nokogiri::XML(bibitemxml)
@@ -225,13 +226,13 @@ module Asciidoctor
225
226
  end
226
227
  c.xpath("./clause").each do |c1|
227
228
  key = c1&.at("./title")&.text&.downcase&.strip
228
- next unless %w(contributors relations series).include? key
229
+ next unless %w(contributor relation series).include? key
229
230
  add_to_hash(bib, key, dl_bib_extract(c1, true))
230
231
  end
231
232
  if !nested and c.at("./title")
232
233
  title = c.at("./title").remove.children.to_xml
233
- bib["titles"] = bib["titles"] ? Array(bib["titles"]) : []
234
- bib["titles"] << title if !title.empty?
234
+ bib["title"] = bib["title"] ? Array(bib["title"]) : []
235
+ bib["title"] << title if !title.empty?
235
236
  end
236
237
  bib
237
238
  end
@@ -95,9 +95,9 @@ module Asciidoctor
95
95
 
96
96
  def xml_encode(text)
97
97
  HTMLEntities.new.encode(text, :basic, :hexadecimal).
98
- gsub(/&amp;gt;/, ">").gsub(/\&amp;lt;/, "<").gsub(/&amp;amp;/, "&").
99
- gsub(/&gt;/, ">").gsub(/&lt;/, "<").gsub(/&amp;/, "&").
100
- gsub(/&quot;/, '"').gsub(/&#xa;/, "\n")
98
+ gsub(/&amp;gt;/, ">").gsub(/\&amp;lt;/, "<").gsub(/&amp;amp;/, "&").
99
+ gsub(/&gt;/, ">").gsub(/&lt;/, "<").gsub(/&amp;/, "&").
100
+ gsub(/&quot;/, '"').gsub(/&#xa;/, "\n")
101
101
  end
102
102
 
103
103
  def stem_parse(text, xml, style)
@@ -106,8 +106,9 @@ module Asciidoctor
106
106
  math = xml_encode(text)
107
107
  xml.stem math, **{ type: "MathML" }
108
108
  elsif style == :latexmath
109
+ latex_cmd = Metanorma::Standoc::Requirements[:latexml].cmd
109
110
  latexmlmath_input = Unicode2LaTeX::unicode2latex(text).gsub(/'/, '\\').gsub(/\n/, " ")
110
- latex = IO.popen('latexmlmath --preload=amsmath -- -', 'r+', :external_encoding=>'UTF-8') do |io|
111
+ latex = IO.popen(latex_cmd, "r+", external_encoding: "UTF-8") do |io|
111
112
  io.write(latexmlmath_input)
112
113
  io.close_write
113
114
  io.read
@@ -86,13 +86,15 @@ module Asciidoctor
86
86
  def self.generate_file parent, reader
87
87
  localdir = Utils::localdir(parent.document)
88
88
  fn = save_plantuml parent, reader, localdir
89
- system "plantuml #{localdir}plantuml/#{fn}.pml"
89
+ umlfile = Pathname.new(localdir) + "plantuml" + "#{fn}.pml"
90
+ system "plantuml #{umlfile}"
90
91
  outfile = parent.image_uri("#{fn}.png")
91
92
  if outfile == "#{fn}.png"
92
- "plantuml/#{fn}.png"
93
+ (Pathname.new("plantuml") + "#{fn}.png").to_s
93
94
  else
94
- FileUtils.mv "#{localdir}plantuml/#{fn}.png", "#{localdir}#{outfile}"
95
- "#{fn}.png"
95
+ FileUtils.mv (Pathname.new(localdir) + "plantuml" + "#{fn}.png").to_s,
96
+ (Pathname.new(localdir) + outfile).to_s
97
+ (Pathname.new("#{fn}.png")).to_s
96
98
  end
97
99
  end
98
100
 
@@ -102,8 +104,10 @@ module Asciidoctor
102
104
  src = "@startuml\n#{src}\n@enduml\n"
103
105
  /^@startuml (?<fn>[^\n]+)\n/ =~ src
104
106
  fn ||= UUIDTools::UUID.random_create
105
- FileUtils.mkdir_p "#{localdir}/plantuml"
106
- File.open("#{localdir}plantuml/#{fn}.pml", "w") { |f| f.write src }
107
+ path = Pathname.new(localdir) + "plantuml"
108
+ FileUtils.mkdir_p path.to_s # "#{localdir}/plantuml"
109
+ #File.open("#{localdir}plantuml/#{fn}.pml", "w") { |f| f.write src }
110
+ File.open((path + "#{fn}.pml").to_s, "w") { |f| f.write src }
107
111
  fn
108
112
  end
109
113
 
@@ -109,9 +109,6 @@ module Asciidoctor
109
109
  return nil if hit.nil?
110
110
  xml.parent.add_child(Utils::smart_render_xml(hit))
111
111
  xml
112
- rescue Algolia::AlgoliaProtocolError
113
- warn "Could not retrieve #{code}: no access to online site"
114
- nil
115
112
  rescue RelatonBib::RequestError
116
113
  warn "Could not retrieve #{code}: no access to online site"
117
114
  nil
@@ -40,7 +40,7 @@ module Asciidoctor
40
40
  begin
41
41
  errors = Jing.new(filename).validate(".tmp.xml")
42
42
  rescue Jing::Error => e
43
- abort "what what what #{e}"
43
+ abort "Jing failed with error: #{e}"
44
44
  end
45
45
  warn "Valid!" if errors.none?
46
46
  errors.each do |error|
@@ -1,7 +1,11 @@
1
1
  require_relative "./standoc/processor"
2
+ require_relative "./standoc/requirement"
3
+ require_relative "./standoc/latexml_requirement"
2
4
 
3
5
  module Metanorma
4
6
  module Standoc
5
-
7
+ Requirements = {
8
+ latexml: LatexmlRequirement.new
9
+ }
6
10
  end
7
11
  end
@@ -0,0 +1,47 @@
1
+ require_relative "./requirement"
2
+
3
+ module Metanorma
4
+ module Standoc
5
+ class LatexmlRequirement < Requirement
6
+ def initialize
7
+ @recommended_version = '0.8.4'
8
+ @minimal_version = '0.8.0'
9
+ version_output, = Open3.capture2e("latexml --VERSION")
10
+ @actual_version = version_output&.match(%r{\d+(.\d+)*})
11
+ end
12
+
13
+ def satisfied
14
+ version = @actual_version
15
+
16
+ if version.to_s.empty?
17
+ abort "LaTeXML not found in PATH, please make sure that you installed LaTeXML"
18
+ end
19
+
20
+ if Gem::Version.new(version) < Gem::Version.new(@minimal_version)
21
+ abort "Minimal supported LaTeXML version is #{@minimal_version} "\
22
+ "found #{version}, recommended version is #{@recommended_version}"
23
+ end
24
+
25
+ if Gem::Version.new(version) < Gem::Version.new(@recommended_version)
26
+ version = "unknown" if version.to_s.empty?
27
+ header_msg = "WARNING latexmlmath version #{version} below #{@recommended_version}!"
28
+ suggestion = if Gem.win_platform?
29
+ "cmd encoding is set to UTF-8 with `chcp 65001`"
30
+ else
31
+ "terminal encoding is set to UTF-8 with `export LANG=en_US.UTF-8`"
32
+ end
33
+
34
+ warn "#{header_msg} Please sure that #{suggestion} command"
35
+
36
+ @cmd = "latexmlmath --preload=amsmath -- -"
37
+ else
38
+ @cmd = "latexmlmath --preload=amsmath --inputencoding=UTF-8 -- -"
39
+ end
40
+ end
41
+
42
+ def cmd
43
+ @cmd
44
+ end
45
+ end
46
+ end
47
+ end
@@ -8,6 +8,8 @@ module Metanorma
8
8
  @short = :standoc
9
9
  @input_format = :asciidoc
10
10
  @asciidoctor_backend = :standoc
11
+
12
+ Metanorma::Standoc::Requirements[:latexml].satisfied
11
13
  end
12
14
 
13
15
  def output_formats
@@ -0,0 +1,13 @@
1
+ module Metanorma
2
+ module Standoc
3
+ class Requirement
4
+ def satisfied
5
+ raise NotImplementedError("abstract method")
6
+ end
7
+
8
+ def cmd
9
+ raise NotImplementedError("abstract method")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.2.2".freeze
3
+ VERSION = "1.2.3".freeze
4
4
  end
5
5
  end
@@ -30,7 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "ruby-jing"
31
31
  spec.add_dependency "isodoc", "~> 0.10.0"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
- spec.add_dependency "relaton", "~> 0.4.0"
33
+ spec.add_dependency "relaton", "~> 0.5.0"
34
+ spec.add_dependency "relaton-iev", "~> 0.1.0"
34
35
  spec.add_dependency "sterile", "~> 1.0.14"
35
36
  spec.add_dependency "concurrent-ruby"
36
37
  spec.add_dependency "html2doc", "~> 0.8.11"
@@ -974,10 +974,9 @@ r = 1 %</stem>
974
974
  </term></terms></sections><bibliography><references id="_" obligation="informative">
975
975
  <title>Normative References</title>
976
976
  <bibitem type="standard" id="IEC60050-102">
977
- <title type="title-main" format="text/plain" language="en" script="Latn">Part 102: Mathematics</title>
978
- <title type="title-intro" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
979
- <title type="title-part" format="text/plain" language="en" script="Latn">General concepts and linear algebra</title>
980
- <title type="main" format="text/plain" language="en" script="Latn">Part 102: Mathematics - International Electrotechnical Vocabulary - General concepts and linear algebra</title>
977
+ <title type="title-main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)</title>
978
+ <title type="title-part" format="text/plain" language="en" script="Latn">Part 102: Mathematics - General concepts and linear algebra</title>
979
+ <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) - Part 102: Mathematics - General concepts and linear algebra</title>
981
980
  <uri type="src">https://webstore.iec.ch/publication/160</uri>
982
981
  <uri type="obp">/preview/info_iec60050-102%7Bed1.0%7Db.pdf</uri>
983
982
  <docidentifier type="IEC">IEC 60050-102:2007</docidentifier>
@@ -1011,10 +1010,9 @@ r = 1 %</stem>
1011
1010
  </owner>
1012
1011
  </copyright>
1013
1012
  </bibitem><bibitem type="standard" id="IEC60050-103">
1014
- <title type="title-main" format="text/plain" language="en" script="Latn">Part 103: Mathematics</title>
1015
- <title type="title-intro" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
1016
- <title type="title-part" format="text/plain" language="en" script="Latn">Functions </title>
1017
- <title type="main" format="text/plain" language="en" script="Latn">Part 103: Mathematics - International Electrotechnical Vocabulary - Functions </title>
1013
+ <title type="title-main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)</title>
1014
+ <title type="title-part" format="text/plain" language="en" script="Latn">Part 103: Mathematics - Functions</title>
1015
+ <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) - Part 103: Mathematics - Functions </title>
1018
1016
  <uri type="src">https://webstore.iec.ch/publication/161</uri>
1019
1017
  <uri type="obp">/preview/info_iec60050-103%7Bed1.0%7Db.pdf</uri>
1020
1018
  <docidentifier type="IEC">IEC 60050-103:2009</docidentifier>