isodoc 1.0.8 → 1.0.9

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: ef21cf58dadc44402088da8688039f145c7c772d2241207790e22721d4509acf
4
- data.tar.gz: 5ba2928a7dd29b05b5042bec243d40ef5bc0b57c4cbbf9062469bef4f89ec6e1
3
+ metadata.gz: a81fec6b1ecfd841b735e5b0b36fca370a1928f7f7a79ee4a1348fd183eb087c
4
+ data.tar.gz: 82fe58f01f7b8315eb3a1d99863084e7f53c2dc1d30220b1a6940f9cc8a23b02
5
5
  SHA512:
6
- metadata.gz: 4d20eccad075ca4cafff9e8b873514d7d955fe19c02f21b032a7c578b5441b414cb5d3e1f8abbe701b686b2e5ff56d1c8dc6b1fa86e6707727b2a76d05b9b513
7
- data.tar.gz: f69deb2000b76e5e24902aad3d11179395f6930a446b5b10244510f7d1be26667164ef1acb16e1c44233d617a1368e53b2d4f15ba4640e83c82be13d66f5e4fa
6
+ metadata.gz: 986f56381b796b2107885544234df9d0e5716953a59c6af9f3b706473f16eec46eb5abbf5132324c237a6f7749f75264be71c84c6e576aa302eeed89f10aa56f
7
+ data.tar.gz: b07f326e9ff729e8cc2b964cea990c4fb51524887690797d42cb4e87fa324e77a4c6d1130f365e55d3bc455aaa76d18409241f43b3af89586305d0a0282683d5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isodoc (1.0.8)
4
+ isodoc (1.0.9)
5
5
  asciimath
6
6
  html2doc (~> 0.9.0)
7
7
  htmlentities (~> 4.3.4)
@@ -26,7 +26,7 @@ GEM
26
26
  docile (1.3.2)
27
27
  equivalent-xml (0.6.0)
28
28
  nokogiri (>= 1.4.3)
29
- ffi (1.11.2)
29
+ ffi (1.11.3)
30
30
  formatador (0.2.5)
31
31
  guard (2.16.1)
32
32
  formatador (>= 0.2.4)
@@ -58,7 +58,7 @@ GEM
58
58
  rb-fsevent (~> 0.10, >= 0.10.3)
59
59
  rb-inotify (~> 0.9, >= 0.9.10)
60
60
  lumberjack (1.0.13)
61
- metanorma (0.3.17)
61
+ metanorma (0.3.18)
62
62
  asciidoctor
63
63
  htmlentities
64
64
  method_source (0.9.2)
@@ -72,7 +72,7 @@ GEM
72
72
  notiffany (0.1.3)
73
73
  nenv (~> 0.1)
74
74
  shellany (~> 0.0)
75
- parallel (1.19.0)
75
+ parallel (1.19.1)
76
76
  parser (2.6.5.0)
77
77
  ast (~> 2.4.0)
78
78
  powerpack (0.1.2)
@@ -177,7 +177,7 @@ module IsoDoc::Function
177
177
  return docxml unless dl
178
178
  dl_out = extract_symbols_list(dl)
179
179
  dl_out.sort! { |a, b| a[:key] <=> b[:key] }
180
- dl.replace(dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n"))
180
+ dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
181
181
  docxml
182
182
  end
183
183
  end
@@ -62,8 +62,12 @@ module IsoDoc::Function
62
62
  %w{dt dd}.include? n.name
63
63
  end
64
64
 
65
+ def dl_attr(node)
66
+ attr_code(id: node["id"])
67
+ end
68
+
65
69
  def dl_parse(node, out)
66
- out.dl **attr_code(id: node["id"]) do |v|
70
+ out.dl **dl_attr(node) do |v|
67
71
  node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
68
72
  v.dt **attr_code(id: dt["id"]) do |term|
69
73
  dt_parse(dt, term)
@@ -25,6 +25,7 @@ module IsoDoc::Function
25
25
  end
26
26
 
27
27
  def anchor(id, lbl, warning = true)
28
+ return nil if id.nil? || id.empty?
28
29
  unless @anchors[id]
29
30
  if warning
30
31
  @seen ||= Seen_Anchor.instance
@@ -269,7 +269,7 @@ module IsoDoc::HtmlFunction
269
269
 
270
270
  def datauri(i)
271
271
  type = i["src"].split(".")[-1]
272
- bin = IO.binread(File.join(@localdir, i["src"]))
272
+ bin = IO.binread(image_localfile(i))
273
273
  data = Base64.strict_encode64(bin)
274
274
  i["src"] = "data:image/#{type};base64,#{data}"
275
275
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.0.8".freeze
2
+ VERSION = "1.0.9".freeze
3
3
  end
@@ -731,6 +731,7 @@ INPUT
731
731
  <?xml version="1.0"?>
732
732
  <div id="L" class="Symbols">
733
733
  <h1>4.<span style="mso-tab-count:1">&#xA0; </span>Symbols and Abbreviated Terms</h1>
734
+ <dl>
734
735
  <dt>
735
736
  <p>
736
737
  <span class="stem">(#(x)#)</span>
@@ -756,6 +757,7 @@ INPUT
756
757
  <span class="stem">(#(&#x3B1;)#)</span>
757
758
  </p>
758
759
  </dt><dd>Definition 1</dd>
760
+ </dl>
759
761
  </div>
760
762
 
761
763
  OUTPUT
@@ -300,7 +300,7 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
300
300
  IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
301
301
  <iso-standard xmlns="http://riboseinc.com/isoxml">
302
302
  <sections>
303
- <clause inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
303
+ <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
304
304
 
305
305
  <title>Introduction<bookmark id="Q"/> to this<fn reference="1">
306
306
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
@@ -382,7 +382,7 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
382
382
  IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html", doctoclevels: 3}).convert("test", <<~"INPUT", false)
383
383
  <iso-standard xmlns="http://riboseinc.com/isoxml">
384
384
  <sections>
385
- <clause inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
385
+ <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
386
386
 
387
387
  <title>Introduction<bookmark id="Q"/> to this<fn reference="1">
388
388
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
@@ -496,7 +496,7 @@ TOCLEVEL
496
496
  IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
497
497
  <iso-standard xmlns="http://riboseinc.com/isoxml">
498
498
  <sections>
499
- <clause inline-header="false" obligation="normative"><title>Clause 4</title><fn reference="3">
499
+ <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><fn reference="3">
500
500
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">This is a footnote.</p>
501
501
  </fn><clause id="N" inline-header="false" obligation="normative">
502
502
 
@@ -518,7 +518,7 @@ TOCLEVEL
518
518
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
519
519
  <main xmlns:epub="epub" class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
520
520
  <p class="zzSTDTitle1"></p>
521
- <div>
521
+ <div id="A">
522
522
  <h1>1.&#xA0; Clause 4</h1>
523
523
  <a rel="footnote" href="#fn:3" epub:type="footnote" id="fnref:1">
524
524
  <sup>1</sup>
@@ -629,6 +629,7 @@ TOCLEVEL
629
629
  <preface><foreword>
630
630
  <figure id="_">
631
631
  <name>Split-it-right sample divider</name>
632
+ <image src="#{File.expand_path(File.join(File.dirname(__FILE__), "..", "assets/rice_image1.png"))}" id="_" mimetype="image/png"/>
632
633
  <image src="assets/rice_image1.png" id="_" mimetype="image/png"/>
633
634
  <image src="assets/rice_image1.png" id="_" width="20000" height="300000" mimetype="image/png"/>
634
635
  <image src="assets/rice_image1.png" id="_" width="99" height="auto" mimetype="image/png"/>
@@ -646,6 +647,7 @@ TOCLEVEL
646
647
  <h1 class="ForewordTitle">Foreword</h1>
647
648
  <div id="_" class="figure">
648
649
  <img src="test_htmlimages/_.png" height="776" width="922" />
650
+ <img src="test_htmlimages/_.png" height="776" width="922" />
649
651
  <img src="test_htmlimages/_.png" height="800" width="53" />
650
652
  <img src="test_htmlimages/_.png" height="83" width="99" />
651
653
  <p class="FigureTitle" style="text-align:center;">Figure 1&#xA0;&#x2014; Split-it-right sample divider</p></div>
@@ -664,6 +666,7 @@ TOCLEVEL
664
666
  <preface><foreword>
665
667
  <figure id="_">
666
668
  <name>Split-it-right sample divider</name>
669
+ <image src="#{File.expand_path(File.join(File.dirname(__FILE__), "..", "assets/rice_image1.png"))}" id="_" mimetype="image/png"/>
667
670
  <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/>
668
671
  </figure>
669
672
  </foreword></preface>
@@ -678,6 +681,39 @@ TOCLEVEL
678
681
  <h1 class="ForewordTitle">Foreword</h1>
679
682
  <div id="_" class="figure">
680
683
  <img src="data:image/png;base64,_" height="776" width="922" />
684
+ <img src="data:image/png;base64,_" height="776" width="922" />
685
+ <p class="FigureTitle" style="text-align:center;">Figure 1&#xA0;&#x2014; Split-it-right sample divider</p></div>
686
+ </div>
687
+ <p class="zzSTDTitle1"></p>
688
+ </main>
689
+ OUTPUT
690
+
691
+ end
692
+
693
+ it "encodes images in HTML as data URIs, using relative file location" do
694
+ FileUtils.rm_f "spec/test.html"
695
+ FileUtils.rm_rf "spec/test_htmlimages"
696
+ IsoDoc::HtmlConvert.new({htmlstylesheet: "spec/assets/html.css", datauriimage: true}).convert("spec/test", <<~"INPUT", false)
697
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
698
+ <preface><foreword>
699
+ <figure id="_">
700
+ <name>Split-it-right sample divider</name>
701
+ <image src="#{File.expand_path(File.join(File.dirname(__FILE__), "..", "assets/rice_image1.png"))}" id="_" mimetype="image/png"/>
702
+ <image src="assets/rice_image1.png" id="_" mimetype="image/png"/>
703
+ </figure>
704
+ </foreword></preface>
705
+ </iso-standard>
706
+ INPUT
707
+ html = File.read("spec/test.html").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
708
+ sub(%r{</main>.*$}m, "</main>")
709
+ expect(xmlpp(html.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"}))).to be_equivalent_to xmlpp(<<~"OUTPUT")
710
+ <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
711
+ <br />
712
+ <div>
713
+ <h1 class="ForewordTitle">Foreword</h1>
714
+ <div id="_" class="figure">
715
+ <img src="data:image/png;base64,_" height="776" width="922" />
716
+ <img src="data:image/png;base64,_" height="776" width="922" />
681
717
  <p class="FigureTitle" style="text-align:center;">Figure 1&#xA0;&#x2014; Split-it-right sample divider</p></div>
682
718
  </div>
683
719
  <p class="zzSTDTitle1"></p>
@@ -686,6 +722,7 @@ TOCLEVEL
686
722
 
687
723
  end
688
724
 
725
+
689
726
  it "processes IsoXML terms for HTML" do
690
727
  FileUtils.rm_f "test.html"
691
728
  FileUtils.rm_f "test.doc"
@@ -475,6 +475,32 @@ OUTPUT
475
475
  OUTPUT
476
476
  end
477
477
 
478
+ it "processes section titles without ID" do
479
+ expect(xmlpp(IsoDoc::HtmlConvert.new({suppressheadingnumbers: true}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
480
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
481
+ <preface>
482
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause obligation="informative">
483
+ <title>Introduction Subsection</title>
484
+ </clause>
485
+ </introduction>
486
+ </preface>
487
+ </iso-standard>
488
+ INPUT
489
+ #{HTML_HDR}
490
+ <br/>
491
+ <div class='Section3' id='B'>
492
+ <h1 class='IntroTitle'>Introduction</h1>
493
+ <div>
494
+ <h1>Introduction Subsection</h1>
495
+ </div>
496
+ </div>
497
+ <p class='zzSTDTitle1'/>
498
+ </div>
499
+ </body>
500
+ </html>
501
+ OUTPUT
502
+ end
503
+
478
504
  it "processes simple terms & definitions" do
479
505
  expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
480
506
  <iso-standard xmlns="http://riboseinc.com/isoxml">
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.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath