isodoc 1.0.16 → 1.0.17

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: 9b8b0f152601a2bbeb84c54de21063c1c8a3153b80a8d7c9e7e72af587afadf2
4
- data.tar.gz: 8e3f19d7bc9d426db9bd2bd49ebd4005bc24ba03ce9add831341780cf2f24b7d
3
+ metadata.gz: 10a62178041dae35a25c840c632a5b2bc6dc60e16c30db960e6d6781fbb3e7a6
4
+ data.tar.gz: 201fe7bf7a28f28e76115f8085f4bbce97e10d84395c46064a7e592776146bfa
5
5
  SHA512:
6
- metadata.gz: fac36a308df3caa41ed65253c0248f74d6bd21cd1341f7996ef30195ac8cadbd2679ac6806c82dbabe9b2f355c39e42c2687d0569c35de8a29e3f16d8f077755
7
- data.tar.gz: ad99d78fcce5692491b593e3d415f1520120e32a2440d350504040a779dc2bd9b636a316d6e27851c72fb5ec314dab4ad4c41abf06e87b773102ee950a681c3a
6
+ metadata.gz: c5cd5437cdd28778c167fef661f99dbeb2f290ab767046c0e0ffb944c83e8aebde8e5e96920dd2f09b6240d9f727478292127ad9aac3c44b76c7a81eba0fee37
7
+ data.tar.gz: 74105a704d901c656aa19b06718803bac9bd76bf5209277c96dfabbe7fed23ac561b0d938295a32f224b1ec25056cd3b6c88e568df4f98ed15739145f04173bd
data/lib/isodoc.rb CHANGED
@@ -19,6 +19,7 @@ require "isodoc/metadata"
19
19
  require "isodoc/html_convert"
20
20
  require "isodoc/word_convert"
21
21
  require "isodoc/pdf_convert"
22
+ require "isodoc/xslfo_convert"
22
23
  require "isodoc/headlesshtml_convert"
23
24
 
24
25
  module IsoDoc
@@ -159,34 +159,7 @@ module IsoDoc::Function
159
159
  docxml
160
160
  end
161
161
 
162
- # We assume AsciiMath is being used in the terms & definitions.
163
- # Indices sort after letter but before any following
164
- # letter (x, x_m, x_1, xa); we use colon to force that sort order.
165
- # Numbers sort *after* letters; we use thorn to force that sort order.
166
- def symbol_key(x)
167
- HTMLEntities.new.decode(x.text).gsub(/_/, ":").gsub(/`/, "").
168
- gsub(/[0-9]+/, "þ\\1")
169
- end
170
-
171
- def extract_symbols_list(dl)
172
- dl_out = []
173
- dl.xpath("./dt | ./dd").each do |dtd|
174
- if dtd.name == "dt"
175
- dl_out << { dt: dtd.remove, key: symbol_key(dtd) }
176
- else
177
- dl_out.last[:dd] = dtd.remove
178
- end
179
- end
180
- dl_out
181
- end
182
-
183
162
  def symbols_cleanup(docxml)
184
- dl = docxml.at("//div[@class = 'Symbols']/dl")
185
- return docxml unless dl
186
- dl_out = extract_symbols_list(dl)
187
- dl_out.sort! { |a, b| a[:key] <=> b[:key] }
188
- dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
189
- docxml
190
163
  end
191
164
  end
192
165
  end
@@ -94,6 +94,7 @@ module IsoDoc::Function
94
94
  @meta.subtitle isoxml, out
95
95
  @meta.docstatus isoxml, out
96
96
  @meta.docid isoxml, out
97
+ @meta.docnumeric isoxml, out
97
98
  @meta.doctype isoxml, out
98
99
  @meta.author isoxml, out
99
100
  @meta.bibdate isoxml, out
@@ -138,7 +138,7 @@ module IsoDoc::Function
138
138
  v
139
139
  end
140
140
 
141
- def populate_template(docxml, _format)
141
+ def populate_template(docxml, _format = nil)
142
142
  meta = @meta.get.merge(@labels || {})
143
143
  template = liquid(docxml)
144
144
  template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h).
@@ -113,9 +113,16 @@ module IsoDoc
113
113
  i = isoxml&.at(ns("//bibdata/status/iteration"))&.text and
114
114
  set(:iteration, i)
115
115
  set(:unpublished, unpublished(docstatus.text))
116
+ unpublished(docstatus.text) and
117
+ set(:stageabbr, stage_abbr(docstatus.text))
116
118
  end
117
119
  end
118
120
 
121
+ def stage_abbr(docstatus)
122
+ status_print(docstatus).split(/ /).
123
+ map { |s| s[0].upcase }.join("")
124
+ end
125
+
119
126
  def unpublished(status)
120
127
  !(status.downcase == "published")
121
128
  end
@@ -129,6 +136,11 @@ module IsoDoc
129
136
  set(:docnumber, dn&.text)
130
137
  end
131
138
 
139
+ def docnumeric(isoxml, _out)
140
+ dn = isoxml.at(ns("//bibdata/docnumber"))
141
+ set(:docnumeric, dn&.text)
142
+ end
143
+
132
144
  def draftinfo(draft, revdate)
133
145
  draftinfo = ""
134
146
  if draft
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.0.16".freeze
2
+ VERSION = "1.0.17".freeze
3
3
  end
@@ -0,0 +1,29 @@
1
+ require "metanorma"
2
+
3
+ module IsoDoc
4
+ class XslfoPdfConvert < ::IsoDoc::Convert
5
+
6
+ def initialize(options)
7
+ super
8
+ @maxwidth = 500
9
+ @maxheight = 800
10
+ end
11
+
12
+ def tmpimagedir_suffix
13
+ "_pdfimages"
14
+ end
15
+
16
+ def convert(filename, file = nil, debug = false)
17
+ file = File.read(filename, encoding: "utf-8") if file.nil?
18
+ docxml, outname_html, dir = convert_init(file, filename, debug)
19
+ FileUtils.rm_rf dir
20
+ ::Metanorma::Output::XslfoPdf.new.convert(filename, outname_html + ".pdf", nil)
21
+ end
22
+
23
+ def xref_parse(node, out)
24
+ target = /#/.match(node["target"]) ? node["target"].sub(/#/, ".pdf#") :
25
+ "##{node["target"]}"
26
+ out.a(**{ "href": target }) { |l| l << get_linkend(node) }
27
+ end
28
+ end
29
+ end
@@ -715,52 +715,4 @@ INPUT
715
715
  OUTPUT
716
716
  end
717
717
 
718
- it "cleans up symbols lists" do
719
- expect(xmlpp(IsoDoc::WordConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s)).to be_equivalent_to xmlpp(<<~"OUTPUT")
720
- <div id="L" class="Symbols">
721
- <h1>4.<span style="mso-tab-count:1">&#160; </span>Symbols and Abbreviated Terms</h1>
722
- <dl>
723
- <dt><p><span class="stem">(#(&#x3b1;)#)</span></p></dt><dd>Definition 1</dd>
724
- <dt><p><span class="stem">(#(xa)#)</span></p></dt><dd>Definition 2</dd>
725
- <dt><p><span class="stem">(#(x_1)#)</span></p></dt><dd>Definition 3</dd>
726
- <dt><p><span class="stem">(#(x_m)#)</span></p></dt><dd>Definition 4</dd>
727
- <dt><p><span class="stem">(#(x)#)</span></p></dt><dd>Definition 5</dd>
728
- </dl>
729
- </div>
730
- INPUT
731
- <?xml version="1.0"?>
732
- <div id="L" class="Symbols">
733
- <h1>4.<span style="mso-tab-count:1">&#xA0; </span>Symbols and Abbreviated Terms</h1>
734
- <dl>
735
- <dt>
736
- <p>
737
- <span class="stem">(#(x)#)</span>
738
- </p>
739
- </dt><dd>Definition 5</dd>
740
- <dt>
741
- <p>
742
- <span class="stem">(#(x_m)#)</span>
743
- </p>
744
- </dt><dd>Definition 4</dd>
745
- <dt>
746
- <p>
747
- <span class="stem">(#(x_1)#)</span>
748
- </p>
749
- </dt><dd>Definition 3</dd>
750
- <dt>
751
- <p>
752
- <span class="stem">(#(xa)#)</span>
753
- </p>
754
- </dt><dd>Definition 2</dd>
755
- <dt>
756
- <p>
757
- <span class="stem">(#(&#x3B1;)#)</span>
758
- </p>
759
- </dt><dd>Definition 1</dd>
760
- </dl>
761
- </div>
762
-
763
- OUTPUT
764
- end
765
-
766
718
  end
@@ -92,7 +92,7 @@ RSpec.describe IsoDoc do
92
92
  </bibdata>
93
93
  </iso-standard>
94
94
  INPUT
95
- {:accesseddate=>"2012", :activateddate=>"2013", :agency=>"ISO", :authors=>["Barney Rubble", "Fred Flintstone"], :authors_affiliations=>{"Slate Inc., Bedrock"=>["Barney Rubble"], ""=>["Fred Flintstone"]}, :circulateddate=>"2015", :confirmeddate=>"2017", :copieddate=>"2016", :createddate=>"2010&ndash;2011", :doc=>"URL E", :docnumber=>"17301-1", :doctitle=>"Cereals and pulses", :doctype=>"International Standard", :docyear=>"2016", :draft=>"0.4", :draftinfo=>" (draft 0.4, 2016-05-01)", :edition=>"2", :html=>"URL B", :implementeddate=>"XXX", :issueddate=>"XXX", :iteration=>"2", :obsoleteddate=>"2014", :pdf=>"URL D", :publisheddate=>"2011", :receiveddate=>"XXX", :revdate=>"2016-05-01", :stage=>"Committee draft", :substage=>"Withdrawn", :transmitteddate=>"2020", :unchangeddate=>"2019", :unpublished=>true, :updateddate=>"2018", :url=>"URL A", :xml=>"URL C"}
95
+ {:accesseddate=>"2012", :activateddate=>"2013", :agency=>"ISO", :authors=>["Barney Rubble", "Fred Flintstone"], :authors_affiliations=>{"Slate Inc., Bedrock"=>["Barney Rubble"], ""=>["Fred Flintstone"]}, :circulateddate=>"2015", :confirmeddate=>"2017", :copieddate=>"2016", :createddate=>"2010&ndash;2011", :doc=>"URL E", :docnumber=>"17301-1", :docnumeric=>"17301", :doctitle=>"Cereals and pulses", :doctype=>"International Standard", :docyear=>"2016", :draft=>"0.4", :draftinfo=>" (draft 0.4, 2016-05-01)", :edition=>"2", :html=>"URL B", :implementeddate=>"XXX", :issueddate=>"XXX", :iteration=>"2", :obsoleteddate=>"2014", :pdf=>"URL D", :publisheddate=>"2011", :receiveddate=>"XXX", :revdate=>"2016-05-01", :stage=>"Committee draft", :stageabbr=>"CD", :substage=>"Withdrawn", :transmitteddate=>"2020", :unchangeddate=>"2019", :unpublished=>true, :updateddate=>"2018", :url=>"URL A", :xml=>"URL C"}
96
96
  OUTPUT
97
97
  end
98
98
 
@@ -153,7 +153,7 @@ OUTPUT
153
153
  </version>
154
154
  </iso-standard>
155
155
  INPUT
156
- {:accesseddate=>"XXX", :agency=>"ISO/IEC", :authors=>[], :authors_affiliations=>{}, :circulateddate=>"XXX", :confirmeddate=>"XXX", :copieddate=>"XXX", :createddate=>"XXX", :docnumber=>"17301-1-3", :doctitle=>"Cereals and pulses", :doctype=>"International Standard", :docyear=>"2016", :draft=>"12", :draftinfo=>" (draft 12, 2016-05-01)", :edition=>nil, :implementeddate=>"XXX", :issueddate=>"XXX", :obsoleteddate=>"XXX", :obsoletes=>"IEC 8121", :obsoletes_part=>"3.1", :partof=>"IEC 8122", :publisheddate=>"XXX", :receiveddate=>"XXX", :revdate=>"2016-05-01", :stage=>"Published", :transmitteddate=>"XXX", :unchangeddate=>"XXX", :unpublished=>false, :updateddate=>"XXX"}
156
+ {:accesseddate=>"XXX", :agency=>"ISO/IEC", :authors=>[], :authors_affiliations=>{}, :circulateddate=>"XXX", :confirmeddate=>"XXX", :copieddate=>"XXX", :createddate=>"XXX", :docnumber=>"17301-1-3", :docnumeric=>"17301", :doctitle=>"Cereals and pulses", :doctype=>"International Standard", :docyear=>"2016", :draft=>"12", :draftinfo=>" (draft 12, 2016-05-01)", :edition=>nil, :implementeddate=>"XXX", :issueddate=>"XXX", :obsoleteddate=>"XXX", :obsoletes=>"IEC 8121", :obsoletes_part=>"3.1", :partof=>"IEC 8122", :publisheddate=>"XXX", :receiveddate=>"XXX", :revdate=>"2016-05-01", :stage=>"Published", :transmitteddate=>"XXX", :unchangeddate=>"XXX", :unpublished=>false, :updateddate=>"XXX"}
157
157
  OUTPUT
158
158
  end
159
159
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-08 00:00:00.000000000 Z
11
+ date: 2020-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -353,6 +353,7 @@ files:
353
353
  - lib/isodoc/word_function/postprocess.rb
354
354
  - lib/isodoc/word_function/postprocess_cover.rb
355
355
  - lib/isodoc/word_function/table.rb
356
+ - lib/isodoc/xslfo_convert.rb
356
357
  - spec/assets/header.html
357
358
  - spec/assets/html.css
358
359
  - spec/assets/htmlcover.html