isodoc 0.8.3 → 0.8.4

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: 0321e7f3851982b8a41f0b4ad71cb942c8e559121780f3089bc3954ea06438d4
4
- data.tar.gz: 5f86453bbf454a1d430a31b8cfaa5bab753b19b7117e5fec70ae34b15dad419b
3
+ metadata.gz: 7021ada69c40cacdfa9a54827a70bf9a949ea194a75c5a9bc9818cc76d458b95
4
+ data.tar.gz: 2f046c37b8094b3288f257f22e7efea00513bdafc09b6f9b2fa1ec4848a9bbe8
5
5
  SHA512:
6
- metadata.gz: '01875c7a9de4657a22eec95a6a9a613e1f227ab5d345015d8ff83478cb03019a5dec57fea43e8c08e114fd05ac3597e285c1d0cdf757d6a51a71a73ab8e6522d'
7
- data.tar.gz: a7160ab90056650b4e72ab7df23549442f9938ec1a3c9b96cb8ef32b6b700fa4dd6c30edadb380bf85d3e131b0ddb4871c2e005c5b135cdbc3435bd19eea5725
6
+ metadata.gz: 0ae6effbeb78bce850bfe83a84bb311509e9f2f04ad7627e64f69c020974c6c6977768302b14ee13c5515f2da497dae17021aa9596e4525f58878e9b65b5d7a1
7
+ data.tar.gz: ccb84fc0e38711603a797dfa2560d3066291122c6a9fc6b1f71407999936a06e24611f075df121115025af70800a0cbd4008f346c22807564c587433f5edcc7b
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ribose.gemspec
4
- gem "html2doc",
5
- git: "https://github.com/riboseinc/html2doc.git"
6
4
  gemspec
@@ -1,17 +1,3 @@
1
- GIT
2
- remote: https://github.com/riboseinc/html2doc.git
3
- revision: e9c0077be0c3d36bb09fa35743a79b00dd5ac560
4
- specs:
5
- html2doc (0.8.1)
6
- asciimath
7
- htmlentities (~> 4.3.4)
8
- image_size
9
- mime-types
10
- nokogiri
11
- ruby-xslt
12
- thread_safe
13
- uuidtools
14
-
15
1
  PATH
16
2
  remote: .
17
3
  specs:
@@ -54,6 +40,15 @@ GEM
54
40
  guard (~> 2.1)
55
41
  guard-compat (~> 1.1)
56
42
  rspec (>= 2.99.0, < 4.0)
43
+ html2doc (0.8.2)
44
+ asciimath
45
+ htmlentities (~> 4.3.4)
46
+ image_size
47
+ mime-types
48
+ nokogiri
49
+ ruby-xslt
50
+ thread_safe
51
+ uuidtools
57
52
  htmlentities (4.3.4)
58
53
  image_size (2.0.0)
59
54
  jaro_winkler (1.5.1)
@@ -138,7 +133,6 @@ DEPENDENCIES
138
133
  equivalent-xml (~> 0.6)
139
134
  guard (~> 2.14)
140
135
  guard-rspec (~> 4.7)
141
- html2doc!
142
136
  isodoc!
143
137
  rake (~> 12.0)
144
138
  rspec (~> 3.6)
@@ -19,6 +19,7 @@ require "isodoc/convert"
19
19
  require "isodoc/metadata"
20
20
  require "isodoc/html_convert"
21
21
  require "isodoc/word_convert"
22
+ require "isodoc/pdf_convert"
22
23
  require "isodoc/iso/html_convert"
23
24
  require "isodoc/iso/word_convert"
24
25
 
@@ -3,6 +3,7 @@ require "sass"
3
3
 
4
4
  module IsoDoc
5
5
  class Convert < ::IsoDoc::Common
6
+ attr_reader :options
6
7
 
7
8
  # htmlstylesheet: Generic stylesheet for HTML
8
9
  # wordstylesheet: Generic stylesheet for Word
@@ -16,6 +17,7 @@ module IsoDoc
16
17
  # ulstyle: list style in Word CSS for unordered lists
17
18
  # olstyle: list style in Word CSS for ordered lists
18
19
  def initialize(options)
20
+ @options = options
19
21
  @htmlstylesheet = options[:htmlstylesheet]
20
22
  @wordstylesheet = options[:wordstylesheet]
21
23
  @standardstylesheet = options[:standardstylesheet]
@@ -46,6 +48,9 @@ module IsoDoc
46
48
  @lang = "en"
47
49
  @script = "Latn"
48
50
  @files_to_delete = []
51
+ @tmpimagedir = "_images"
52
+ @maxwidth = 1200
53
+ @maxheight = 800
49
54
  end
50
55
 
51
56
  def html_doc_path(file)
@@ -74,8 +74,8 @@ module IsoDoc::Function
74
74
  end
75
75
 
76
76
  EXAMPLE_TBL_ATTR =
77
- { width: "110pt", valign: "top", class: "example_label",
78
- style: "width:82.8pt;padding:.75pt .75pt .75pt .75pt" }.freeze
77
+ { valign: "top", class: "example_label",
78
+ style: "width:82.8pt;" }.freeze
79
79
 
80
80
  # used if we are boxing examples
81
81
  def example_div_parse(node, out)
@@ -204,8 +204,8 @@ module IsoDoc::Function
204
204
  end
205
205
 
206
206
  def image_parse(node, out, caption)
207
- attrs = { src: node["src"],
208
- height: node["height"] || "auto",
207
+ attrs = { src: node["src"],
208
+ height: node["height"] || "auto",
209
209
  width: node["width"] || "auto" }
210
210
  out.img **attr_code(attrs)
211
211
  image_title_parse(out, caption)
@@ -8,5 +8,7 @@ module IsoDoc
8
8
  include HtmlFunction::Comments
9
9
  include HtmlFunction::Footnotes
10
10
  include HtmlFunction::Html
11
+
12
+ @tmpimagedir = "_images"
11
13
  end
12
14
  end
@@ -28,7 +28,7 @@ module IsoDoc::HtmlFunction
28
28
  def postprocess(result, filename, dir)
29
29
  result = from_xhtml(cleanup(to_xhtml(result)))
30
30
  toHTML(result, filename)
31
- @files_to_delete.each { |f| system "rm #{f}" }
31
+ @files_to_delete.each { |f| system "rm -r #{f}" }
32
32
  end
33
33
 
34
34
  def script_cdata(result)
@@ -49,7 +49,7 @@ module IsoDoc::HtmlFunction
49
49
  def html_cleanup(x)
50
50
  footnote_backlinks(html_toc(
51
51
  term_header(move_images(html_footnote_filter(html_preface(htmlstyle(x))))))
52
- )
52
+ )
53
53
  end
54
54
 
55
55
  MATHJAX_ADDR =
@@ -188,12 +188,12 @@ module IsoDoc::HtmlFunction
188
188
 
189
189
  # presupposes that the image source is local
190
190
  def move_images(docxml)
191
- system "rm -r _images; mkdir _images"
191
+ system "rm -r #{@tmpimagedir}; mkdir #{@tmpimagedir}"
192
192
  docxml.xpath("//*[local-name() = 'img']").each do |i|
193
193
  next if /^data:image/.match? i["src"]
194
194
  matched = /\.(?<suffix>\S+)$/.match i["src"]
195
195
  uuid = UUIDTools::UUID.random_create.to_s
196
- new_full_filename = File.join("_images", "#{uuid}.#{matched[:suffix]}")
196
+ new_full_filename = File.join(@tmpimagedir, "#{uuid}.#{matched[:suffix]}")
197
197
  move_image1(i, new_full_filename)
198
198
  end
199
199
  docxml
@@ -202,9 +202,7 @@ module IsoDoc::HtmlFunction
202
202
  def move_image1(i, new_full_filename)
203
203
  system "cp #{i['src']} #{new_full_filename}"
204
204
  i["src"] = new_full_filename
205
- if i["width"] != "auto" && i["height"] != "auto"
206
- i["width"], i["height"] = Html2Doc.image_resize(i, 800, 1200)
207
- end
205
+ i["width"], i["height"] = Html2Doc.image_resize(i, @maxheight, @maxwidth)
208
206
  end
209
207
 
210
208
  def html_toc(docxml)
@@ -0,0 +1,31 @@
1
+ require_relative "html_function/comments.rb"
2
+ require_relative "html_function/footnotes.rb"
3
+ require_relative "html_function/html.rb"
4
+
5
+ module IsoDoc
6
+ class PdfConvert < ::IsoDoc::Convert
7
+
8
+ include HtmlFunction::Comments
9
+ include HtmlFunction::Footnotes
10
+ include HtmlFunction::Html
11
+
12
+ def initialize(options)
13
+ super
14
+ @tmpimagedir = "_pdfimages"
15
+ @maxwidth = 500
16
+ @maxheight = 800
17
+ end
18
+
19
+ def convert(filename, file = nil, debug = false)
20
+ file = File.read(filename, encoding: "utf-8") if file.nil?
21
+ @openmathdelim, @closemathdelim = extract_delims(file)
22
+ docxml, outname_html, dir = convert_init(file, filename, debug)
23
+ result = convert1(docxml, filename, dir)
24
+ return result if debug
25
+ postprocess(result, filename, dir)
26
+ system "rm -fr #{dir}"
27
+ Metanorma::Output::Pdf.new.convert(filename + ".html", filename)
28
+ system "rm -r #{filename + '.html'} #{@tmpimagedir}"
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "0.8.3".freeze
2
+ VERSION = "0.8.4".freeze
3
3
  end
@@ -335,7 +335,7 @@ INPUT
335
335
  <h1 class="ForewordTitle">Foreword</h1>
336
336
  <table id="samplecode" class="example">
337
337
  <tr>
338
- <td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE</td>
338
+ <td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE</td>
339
339
  <td valign="top" class="example">
340
340
  <p>Hello</p>
341
341
  </td>
@@ -369,7 +369,7 @@ INPUT
369
369
  <h1 class="ForewordTitle">Foreword</h1>
370
370
  <table id="samplecode" class="example">
371
371
  <tr>
372
- <td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td>
372
+ <td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td>
373
373
  <td valign="top" class="example">
374
374
  <p>Hello</p>
375
375
  </td>
@@ -377,7 +377,7 @@ INPUT
377
377
  </table>
378
378
  <table id="samplecode2" class="example">
379
379
  <tr>
380
- <td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 2</td>
380
+ <td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 2</td>
381
381
  <td valign="top" class="example">
382
382
  <p>Hello</p>
383
383
  </td>
@@ -425,10 +425,9 @@ CkZJTEVOQU1FOiB0ZXN0Cgo=
425
425
  <h1 class="ForewordTitle">Foreword</h1>
426
426
  <div id="_" class="figure">
427
427
 
428
- <img src="_images/_.png" height="auto" width="auto" />
429
- <img src="_images/_.png" height="1200" width="80" />
430
- <img src="_images/_.png" height="auto" width="99" />
431
-
428
+ <img src="_images/_.png" height="673" width="800" />
429
+ <img src="_images/_.png" height="1200" width="80" />
430
+ <img src="_images/_.png" height="83" width="99" />
432
431
  <p class="FigureTitle" align="center">Figure 1&#xA0;&#x2014; Split-it-right sample divider</p></div>
433
432
  </div>
434
433
  <p class="zzSTDTitle1"></p>
@@ -68,13 +68,13 @@ RSpec.describe IsoDoc do
68
68
  <p class="TermNum" id="paddy1">1.1</p><p class="Terms" style="text-align:left;">paddy</p>
69
69
 
70
70
  <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&lt;rice&gt; rice retaining its husk after threshing</p>
71
- <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td><td valign="top" class="example">
71
+ <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td><td valign="top" class="example">
72
72
  <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
73
73
  <ul>
74
74
  <li>A</li>
75
75
  </ul>
76
76
  </td></tr></table>
77
- <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 2</td><td valign="top" class="example">
77
+ <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 2</td><td valign="top" class="example">
78
78
  <ul>
79
79
  <li>A</li>
80
80
  </ul>
@@ -87,7 +87,7 @@ RSpec.describe IsoDoc do
87
87
  <p class="AltTerms" style="text-align:left;">rough rice</p>
88
88
  <p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
89
89
  <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
90
- <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td><td valign="top" class="example">
90
+ <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td><td valign="top" class="example">
91
91
  <ul>
92
92
  <li>A</li>
93
93
  </ul>
@@ -171,13 +171,13 @@ OUTPUT
171
171
  <p class="TermNum" id="paddy1">1.1</p><p class="Terms" style="text-align:left;">paddy</p>
172
172
 
173
173
  <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&lt;rice&gt; rice retaining its husk after threshing</p>
174
- <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td><td valign="top" class="example">
174
+ <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td><td valign="top" class="example">
175
175
  <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
176
176
  <ul>
177
177
  <li>A</li>
178
178
  </ul>
179
179
  </td></tr></table>
180
- <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 2</td><td valign="top" class="example">
180
+ <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f894" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 2</td><td valign="top" class="example">
181
181
  <ul>
182
182
  <li>A</li>
183
183
  </ul>
@@ -190,7 +190,7 @@ OUTPUT
190
190
  <p class="AltTerms" style="text-align:left;">rough rice</p>
191
191
  <p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
192
192
  <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
193
- <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td><td valign="top" class="example">
193
+ <table id="_bd57bbf1-f948-4bae-b0ce-73c00431f893" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td><td valign="top" class="example">
194
194
  <ul>
195
195
  <li>A</li>
196
196
  </ul>
@@ -436,7 +436,7 @@ RSpec.describe IsoDoc do
436
436
  <h1>1.&#160; Scope</h1>
437
437
  <table id="N" class="example">
438
438
  <tr>
439
- <td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE</td>
439
+ <td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE</td>
440
440
  <td valign="top" class="example">
441
441
  <p>Hello</p>
442
442
  </td>
@@ -460,10 +460,10 @@ RSpec.describe IsoDoc do
460
460
  <div id="widgets">
461
461
  <h1>3.&#160; Widgets</h1>
462
462
  <div id="widgets1">
463
- <table id="note1" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td><td valign="top" class="example">
463
+ <table id="note1" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td><td valign="top" class="example">
464
464
  <p>Hello</p>
465
465
  </td></tr></table>
466
- <table id="note2" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 2</td><td valign="top" class="example">
466
+ <table id="note2" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 2</td><td valign="top" class="example">
467
467
  <p>Hello</p>
468
468
  </td></tr></table>
469
469
  <p> <a href="#note1">Example 1</a> <a href="#note2">Example 2</a> </p>
@@ -472,15 +472,15 @@ RSpec.describe IsoDoc do
472
472
  <br/>
473
473
  <div id="annex1" class="Section3">
474
474
  <div id="annex1a">
475
- <table id="AN" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE</td><td valign="top" class="example">
475
+ <table id="AN" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE</td><td valign="top" class="example">
476
476
  <p>Hello</p>
477
477
  </td></tr></table>
478
478
  </div>
479
479
  <div id="annex1b">
480
- <table id="Anote1" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 1</td><td valign="top" class="example">
480
+ <table id="Anote1" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 1</td><td valign="top" class="example">
481
481
  <p>Hello</p>
482
482
  </td></tr></table>
483
- <table id="Anote2" class="example"><tr><td width="110pt" valign="top" class="example_label" style="width:82.8pt;padding:.75pt .75pt .75pt .75pt">EXAMPLE 2</td><td valign="top" class="example">
483
+ <table id="Anote2" class="example"><tr><td valign="top" class="example_label" style="width:82.8pt;">EXAMPLE 2</td><td valign="top" class="example">
484
484
  <p>Hello</p>
485
485
  </td></tr></table>
486
486
  </div>
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: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -355,6 +355,7 @@ files:
355
355
  - lib/isodoc/iso/html_convert.rb
356
356
  - lib/isodoc/iso/word_convert.rb
357
357
  - lib/isodoc/metadata.rb
358
+ - lib/isodoc/pdf_convert.rb
358
359
  - lib/isodoc/version.rb
359
360
  - lib/isodoc/word_convert.rb
360
361
  - lib/isodoc/word_function.rb