isodoc 0.9.19 → 0.9.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee247cb9d9b705d6a00ec5a27a2cb20295f16c48ffbe4cb6152e934b7c16893b
4
- data.tar.gz: b4ddb650b8fcc3fd95f3f6104956cba1e96639158eaf19874704e51bc48aed60
3
+ metadata.gz: 55728058640cb9c26a315460436606766b1cf09796a64e301bb8081ee325ed31
4
+ data.tar.gz: 40317b9fbed10a3d553eca0f0ebbf6e268195757aebde5429fa8565fda2fe1ab
5
5
  SHA512:
6
- metadata.gz: cfc35a27e441b0f50dcb24aed67e1576024e2246c8784193541532361aaa068981ac1bcfc31a35fc8625149daec18c55fbd14ccd231c9ea8ab155c9193100421
7
- data.tar.gz: 73c4c6f98f010ad651d86b834514af80f90fcc9b50d5d50a26bf066a3c9a09d9d888494f732f1458dcb6eac0e098d25e911fb97fd43548da43881c412cd00776
6
+ metadata.gz: e69af0fcd60d7fd7f6f52318d29d4a603172d018d1f926f0bae2aeb4cfa32a099d782acf4d0876e83bbcef06dcb3099824a2751d887187c8ebccf050d1468eab
7
+ data.tar.gz: 47cb08b0e0fd6f560d119f16fb5070b4b4153ea7f02b5adfb603e42cec1a159b1540950be2351628f315a551f68514e30b7ef782eb0f950a5d1acc0b879e790c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isodoc (0.9.19)
4
+ isodoc (0.9.20)
5
5
  asciimath
6
6
  html2doc (~> 0.8.6)
7
7
  htmlentities (~> 4.3.4)
@@ -10,7 +10,6 @@ PATH
10
10
  nokogiri (>= 1)
11
11
  rake (~> 12.0)
12
12
  roman-numerals
13
- ruby-xslt
14
13
  sassc (~> 1.12.1)
15
14
  thread_safe
16
15
  uuidtools
@@ -18,7 +17,7 @@ PATH
18
17
  GEM
19
18
  remote: https://rubygems.org/
20
19
  specs:
21
- asciidoctor (2.0.0)
20
+ asciidoctor (2.0.5)
22
21
  asciimath (1.0.8)
23
22
  ast (2.4.0)
24
23
  byebug (9.1.0)
@@ -61,21 +60,21 @@ GEM
61
60
  rb-inotify (~> 0.9, >= 0.9.7)
62
61
  ruby_dep (~> 1.2)
63
62
  lumberjack (1.0.13)
64
- metanorma (0.3.9)
63
+ metanorma (0.3.10)
65
64
  asciidoctor
66
65
  htmlentities
67
66
  method_source (0.9.2)
68
67
  mime-types (3.2.2)
69
68
  mime-types-data (~> 3.2015)
70
- mime-types-data (3.2018.0812)
69
+ mime-types-data (3.2019.0331)
71
70
  mini_portile2 (2.4.0)
72
71
  nenv (0.3.0)
73
- nokogiri (1.10.1)
72
+ nokogiri (1.10.2)
74
73
  mini_portile2 (~> 2.4.0)
75
74
  notiffany (0.1.1)
76
75
  nenv (~> 0.1)
77
76
  shellany (~> 0.0)
78
- parallel (1.14.0)
77
+ parallel (1.17.0)
79
78
  parser (2.6.2.0)
80
79
  ast (~> 2.4.0)
81
80
  powerpack (0.1.2)
@@ -111,7 +110,7 @@ GEM
111
110
  ruby-progressbar (1.10.0)
112
111
  ruby-xslt (0.9.10)
113
112
  ruby_dep (1.5.0)
114
- sass (3.7.3)
113
+ sass (3.7.4)
115
114
  sass-listen (~> 4.0.0)
116
115
  sass-listen (4.0.0)
117
116
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -2,6 +2,7 @@
2
2
 
3
3
  image:https://img.shields.io/gem/v/isodoc.svg["Gem Version", link="https://rubygems.org/gems/isodoc"]
4
4
  image:https://img.shields.io/travis/metanorma/isodoc/master.svg["Build Status", link="https://travis-ci.org/metanorma/isodoc"]
5
+ image:https://ci.appveyor.com/api/projects/status/5od77sei1e1t5h68?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/isodoc"]
5
6
  image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
6
7
 
7
8
  == Purpose
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "asciimath"
32
32
  spec.add_dependency "htmlentities", "~> 4.3.4"
33
33
  spec.add_dependency "nokogiri", ">= 1"
34
- spec.add_dependency "ruby-xslt"
35
34
  spec.add_dependency "thread_safe"
36
35
  spec.add_dependency "uuidtools"
37
36
  spec.add_dependency "html2doc", "~> 0.8.6"
@@ -30,9 +30,9 @@ module IsoDoc
30
30
  merge!(default_file_locations(options)) { |_, old, new| old || new }
31
31
  @options = options
32
32
  @files_to_delete = []
33
- @htmlstylesheet = generate_css(options[:htmlstylesheet], true, extract_fonts(options))
34
- @wordstylesheet = generate_css(options[:wordstylesheet], false, extract_fonts(options))
35
- @standardstylesheet = generate_css(options[:standardstylesheet], false, extract_fonts(options))
33
+ @htmlstylesheet_name = options[:htmlstylesheet]
34
+ @wordstylesheet_name = options[:wordstylesheet]
35
+ @standardstylesheet_name = options[:standardstylesheet]
36
36
  @header = options[:header]
37
37
  @htmlcoverpage = options[:htmlcoverpage]
38
38
  @wordcoverpage = options[:wordcoverpage]
@@ -64,6 +64,17 @@ module IsoDoc
64
64
  @script = "Latn"
65
65
  @maxwidth = 1200
66
66
  @maxheight = 800
67
+ @wordToClevels = options[:doctoclevels].to_i
68
+ @wordToClevels = 2 if @wordToClevels == 0
69
+ @htmlToClevels = options[:htmltoclevels].to_i
70
+ @htmlToClevels = 2 if @htmlToClevels == 0
71
+ end
72
+
73
+ # run this after @meta is populated
74
+ def populate_css
75
+ @htmlstylesheet = generate_css(@htmlstylesheet_name, true, extract_fonts(options))
76
+ @wordstylesheet = generate_css(@wordstylesheet_name, false, extract_fonts(options))
77
+ @standardstylesheet = generate_css(@standardstylesheet_name, false, extract_fonts(options))
67
78
  end
68
79
 
69
80
  def tmpimagedir_suffix
@@ -111,6 +122,7 @@ module IsoDoc
111
122
  def generate_css(filename, stripwordcss, fontheader)
112
123
  return nil unless filename
113
124
  stylesheet = File.read(filename, encoding: "UTF-8")
125
+ stylesheet = populate_template(stylesheet, :word)
114
126
  stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, "\\1") if stripwordcss
115
127
  engine = SassC::Engine.new(fontheader + stylesheet, syntax: :scss)
116
128
  outname = File.basename(filename, ".*") + ".css"
@@ -124,6 +136,8 @@ module IsoDoc
124
136
  noko do |xml|
125
137
  xml.html do |html|
126
138
  html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
139
+ info docxml, nil
140
+ populate_css()
127
141
  define_head html, filename, dir
128
142
  make_body(html, docxml)
129
143
  end
@@ -69,7 +69,6 @@ module IsoDoc::Function
69
69
 
70
70
  def make_body2(body, docxml)
71
71
  body.div **{ class: "prefatory-section" } do |div2|
72
- info docxml, div2
73
72
  div2.p { |p| p << "&nbsp;" } # placeholder
74
73
  end
75
74
  section_break(body)
@@ -134,7 +134,7 @@ module IsoDoc::Function
134
134
  end
135
135
 
136
136
  def populate_template(docxml, _format)
137
- meta = @meta.get.merge(@labels)
137
+ meta = @meta.get.merge(@labels || {})
138
138
  docxml = docxml.
139
139
  gsub(/\[TERMREF\]\s*/, l10n("[#{@source_lbl}: ")).
140
140
  gsub(/\s*\[\/TERMREF\]\s*/, l10n("]")).
@@ -12,7 +12,6 @@ module IsoDoc::HtmlFunction
12
12
 
13
13
  def make_body2(body, docxml)
14
14
  body.div **{ class: "prefatory-section" } do |div2|
15
- info docxml, div2
16
15
  div2.p { |p| p << "&nbsp;" } # placeholder
17
16
  end
18
17
  section_break(body)
@@ -36,9 +35,9 @@ module IsoDoc::HtmlFunction
36
35
  end
37
36
 
38
37
  def script_cdata(result)
39
- result.gsub(%r{<script>\s*<!\[CDATA\[}m, "<script>").
38
+ result.gsub(%r{<script([^>]*)>\s*<!\[CDATA\[}m, "<script\\1>").
40
39
  gsub(%r{\]\]>\s*</script>}, "</script>").
41
- gsub(%r{<!\[CDATA\[\s*<script>}m, "<script>").
40
+ gsub(%r{<!\[CDATA\[\s*<script([^>]*)>}m, "<script\\1>").
42
41
  gsub(%r{</script>\s*\]\]>}, "</script>")
43
42
  end
44
43
 
@@ -83,6 +82,22 @@ module IsoDoc::HtmlFunction
83
82
  docxml
84
83
  end
85
84
 
85
+ def googlefonts()
86
+ <<~HEAD.freeze
87
+ <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
88
+ <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
89
+ HEAD
90
+ end
91
+
92
+ def toclevel
93
+ <<~HEAD.freeze
94
+ function toclevel() { var i; var text = "";
95
+ for(i = 1; i <= #{@htmlToClevels}; i++) {
96
+ if (i > 1) { text += ","; } text += "h" + i + ":not(.TermNum)"; }
97
+ return text;}
98
+ HEAD
99
+ end
100
+
86
101
  def html_head()
87
102
  <<~HEAD.freeze
88
103
  <title>{{ doctitle }}</title>
@@ -90,13 +105,14 @@ module IsoDoc::HtmlFunction
90
105
 
91
106
  <!--TOC script import-->
92
107
  <script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
108
+ <script type="text/javascript">#{toclevel}</script>
93
109
 
94
110
  <!--Google fonts-->
95
- <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
96
- <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
111
+ #{googlefonts}
97
112
  <!--Font awesome import for the link icon-->
98
113
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
99
114
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
115
+ <style class="anchorjs"></style>
100
116
  HEAD
101
117
  end
102
118
 
@@ -33,8 +33,7 @@ module IsoDoc
33
33
  end
34
34
 
35
35
  def extract_person_names(authors)
36
- ret = []
37
- authors.each do |a|
36
+ authors.inject([]) do |ret, a|
38
37
  if a.at(ns("./name/completename"))
39
38
  ret << a.at(ns("./name/completename")).text
40
39
  else
@@ -45,15 +44,22 @@ module IsoDoc
45
44
  ret << fn.join(" ") + " " + surname
46
45
  end
47
46
  end
48
- ret
47
+ end
48
+
49
+ def extract_person_affiliations(authors)
50
+ authors.inject([]) do |m, a|
51
+ name = a&.at(ns("./affiliation/org/name"))&.text
52
+ location = a&.at(ns("./affiliation/org/contact/address/"\
53
+ "formattedAddress"))&.text
54
+ m << ((!name.nil? && !location.nil?) ? "#{name}, #{location}" :
55
+ (name || location || ""))
56
+ m
57
+ end
49
58
  end
50
59
 
51
60
  def extract_person_names_affiliations(authors)
52
61
  names = extract_person_names(authors)
53
- affils = []
54
- authors.each do |a|
55
- affils << (a&.at(ns("./affiliation/org/name"))&.text || "")
56
- end
62
+ affils = extract_person_affiliations(authors)
57
63
  ret = {}
58
64
  affils.each_with_index do |a, i|
59
65
  ret[a] ||= []
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "0.9.19".freeze
2
+ VERSION = "0.9.20".freeze
3
3
  end
@@ -11,7 +11,6 @@ module IsoDoc::WordFunction
11
11
 
12
12
  def make_body2(body, docxml)
13
13
  body.div **{ class: "WordSection2" } do |div2|
14
- info docxml, div2
15
14
  abstract docxml, div2
16
15
  foreword docxml, div2
17
16
  introduction docxml, div2
@@ -55,8 +55,8 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
55
55
  end
56
56
 
57
57
  def word_cleanup(docxml)
58
- word_preface(docxml)
59
58
  word_annex_cleanup(docxml)
59
+ word_preface(docxml)
60
60
  word_table_separator(docxml)
61
61
  word_admonition_images(docxml)
62
62
  word_list_continuations(docxml)
@@ -93,17 +93,12 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
93
93
  end
94
94
  end
95
95
 
96
- # force Annex h2 to be p.h2Annex, so it is not picked up by ToC
97
96
  def word_annex_cleanup(docxml)
98
- docxml.xpath("//h2[ancestor::*[@class = 'Section3']]").each do |h2|
99
- h2.name = "p"
100
- h2["class"] = "h2Annex"
101
- end
102
97
  end
103
98
 
104
99
  def word_preface(docxml)
105
100
  word_cover(docxml) if @wordcoverpage
106
- word_intro(docxml) if @wordintropage
101
+ word_intro(docxml, @wordToClevels) if @wordintropage
107
102
  end
108
103
 
109
104
  def word_cover(docxml)
@@ -114,12 +109,12 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
114
109
  coverxml.to_xml(encoding: "US-ASCII")
115
110
  end
116
111
 
117
- def insert_toc(intro, docxml)
118
- intro.sub(/WORDTOC/, make_WordToC(docxml))
112
+ def insert_toc(intro, docxml, level)
113
+ intro.sub(/WORDTOC/, make_WordToC(docxml, level))
119
114
  end
120
115
 
121
- def word_intro(docxml)
122
- intro = insert_toc(File.read(@wordintropage, encoding: "UTF-8"), docxml)
116
+ def word_intro(docxml, level)
117
+ intro = insert_toc(File.read(@wordintropage, encoding: "UTF-8"), docxml, level)
123
118
  intro = populate_template(intro, :word)
124
119
  introxml = to_word_xhtml_fragment(intro)
125
120
  docxml.at('//div[@class="WordSection2"]').children.first.previous =
@@ -161,13 +156,15 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
161
156
  TOC
162
157
  end
163
158
 
164
- WORD_TOC_PREFACE1 = <<~TOC.freeze
159
+ def word_toc_preface(level)
160
+ <<~TOC.freeze
165
161
  <span lang="EN-GB"><span
166
162
  style='mso-element:field-begin'></span><span
167
163
  style='mso-spacerun:yes'>&#xA0;</span>TOC
168
- \\o &quot;1-2&quot; \\h \\z \\u <span
164
+ \\o &quot;1-#{level}&quot; \\h \\z \\u <span
169
165
  style='mso-element:field-separator'></span></span>
170
- TOC
166
+ TOC
167
+ end
171
168
 
172
169
  WORD_TOC_SUFFIX1 = <<~TOC.freeze
173
170
  <p class="MsoToc1"><span lang="EN-GB"><span
@@ -175,14 +172,15 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
175
172
  lang="EN-GB"><o:p>&nbsp;</o:p></span></p>
176
173
  TOC
177
174
 
178
- def make_WordToC(docxml)
175
+ def make_WordToC(docxml, level)
179
176
  toc = ""
180
- docxml.xpath("//h1 | //h2[not(ancestor::*[@class = 'Section3'])]").
181
- each do |h|
182
- toc += word_toc_entry(h.name == "h1" ? 1 : 2, header_strip(h))
177
+ #docxml.xpath("//h1 | //h2[not(ancestor::*[@class = 'Section3'])]").
178
+ xpath = (1..level).each.map { |i| "//h#{i}" }.join (" | ")
179
+ docxml.xpath(xpath).each do |h|
180
+ toc += word_toc_entry(h.name[1].to_i, header_strip(h))
183
181
  end
184
182
  toc.sub(/(<p class="MsoToc1">)/,
185
- %{\\1#{WORD_TOC_PREFACE1}}) + WORD_TOC_SUFFIX1
183
+ %{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
186
184
  end
187
185
  end
188
186
  end
@@ -49,7 +49,11 @@ RSpec.describe IsoDoc do
49
49
  <surname>Rubble</surname>
50
50
  </name>
51
51
  <affiliation>
52
- <org><name>Bedrock Inc.</name></org>
52
+ <org><name>Slate Inc.</name>
53
+ <contact><address>
54
+ <formattedAddress>Bedrock</formattedAddress>
55
+ </address></contact>
56
+ </org>
53
57
  </affiliation>
54
58
  </person>
55
59
  </contributor>
@@ -81,7 +85,7 @@ RSpec.describe IsoDoc do
81
85
  </bibdata>
82
86
  </iso-standard>
83
87
  INPUT
84
- {:accesseddate=>"2012", :activateddate=>"2013", :agency=>"ISO", :authors=>["Barney Rubble", "Fred Flintstone"], :authors_affiliations=>{"Bedrock Inc."=>["Barney Rubble"], ""=>["Fred Flintstone"]}, :confirmeddate=>"XXX", :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", :editorialgroup=>["TC 34", "SC 4", "WG 3"], :html=>"URL B", :ics=>"XXX", :implementeddate=>"XXX", :issueddate=>"XXX", :obsoleteddate=>"2014", :obsoletes=>nil, :obsoletes_part=>nil, :pdf=>"URL D", :publisheddate=>"2011", :receiveddate=>"XXX", :revdate=>"2016-05-01", :sc=>"SC 4", :secretariat=>"GB", :status=>"Committee draft", :tc=>"TC 34", :unpublished=>true, :updateddate=>"XXX", :url=>"URL A", :wg=>"WG 3", :xml=>"URL C"}
88
+ {:accesseddate=>"2012", :activateddate=>"2013", :agency=>"ISO", :authors=>["Barney Rubble", "Fred Flintstone"], :authors_affiliations=>{"Slate Inc., Bedrock"=>["Barney Rubble"], ""=>["Fred Flintstone"]}, :confirmeddate=>"XXX", :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", :editorialgroup=>["TC 34", "SC 4", "WG 3"], :html=>"URL B", :ics=>"XXX", :implementeddate=>"XXX", :issueddate=>"XXX", :obsoleteddate=>"2014", :obsoletes=>nil, :obsoletes_part=>nil, :pdf=>"URL D", :publisheddate=>"2011", :receiveddate=>"XXX", :revdate=>"2016-05-01", :sc=>"SC 4", :secretariat=>"GB", :status=>"Committee draft", :tc=>"TC 34", :unpublished=>true, :updateddate=>"XXX", :url=>"URL A", :wg=>"WG 3", :xml=>"URL C"}
85
89
  OUTPUT
86
90
  end
87
91
 
@@ -233,35 +233,6 @@ RSpec.describe IsoDoc do
233
233
  OUTPUT
234
234
  end
235
235
 
236
- it "converts annex subheadings to h2Annex class for Word" do
237
- FileUtils.rm_f "test.doc"
238
- FileUtils.rm_f "test.html"
239
- IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
240
- <iso-standard xmlns="http://riboseinc.com/isoxml">
241
- <annex id="P" inline-header="false" obligation="normative">
242
- <title>Annex</title>
243
- <clause id="Q" inline-header="false" obligation="normative">
244
- <title>Annex A.1</title>
245
- </clause>
246
- </annex>
247
- </iso-standard>
248
- INPUT
249
- word = File.read("test.doc").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
250
- sub(%r{<div style="mso-element:footnote-list"/>.*$}m, "")
251
- expect(word).to be_equivalent_to <<~"OUTPUT"
252
- <div class="WordSection3">
253
- <p class="zzSTDTitle1"></p>
254
- <p class="MsoNormal"><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
255
- <div class="Section3"><a name="P" id="P"></a>
256
- <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
257
- <div><a name="Q" id="Q"></a>
258
- <p class="h2Annex">A.1. Annex A.1</p>
259
- </div>
260
- </div>
261
- </div>
262
- OUTPUT
263
- end
264
-
265
236
  it "populates Word template with terms reference labels" do
266
237
  FileUtils.rm_f "test.doc"
267
238
  FileUtils.rm_f "test.html"
@@ -349,6 +320,9 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
349
320
  <p>A<fn reference="1">
350
321
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
351
322
  </fn></p>
323
+ <clause id="P" inline-header="false" obligation="normative">
324
+ <title>Clause 4.2.1</title>
325
+ </clause>
352
326
  </clause></clause>
353
327
  </sections>
354
328
  </iso-standard>
@@ -412,6 +386,120 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
412
386
  OUTPUT
413
387
  end
414
388
 
389
+ it "populates Word ToC with custom levels" do
390
+ FileUtils.rm_f "test.doc"
391
+ IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html", doctoclevels: 3}).convert("test", <<~"INPUT", false)
392
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
393
+ <sections>
394
+ <clause inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
395
+
396
+ <title>Introduction<bookmark id="Q"/> to this<fn reference="1">
397
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
398
+ </fn></title>
399
+ </clause>
400
+ <clause id="O" inline-header="false" obligation="normative">
401
+ <title>Clause 4.2</title>
402
+ <p>A<fn reference="1">
403
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
404
+ </fn></p>
405
+ <clause id="P" inline-header="false" obligation="normative">
406
+ <title>Clause 4.2.1</title>
407
+ </clause>
408
+ </clause></clause>
409
+ </sections>
410
+ </iso-standard>
411
+
412
+ INPUT
413
+ word = File.read("test.doc").sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">').
414
+ sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
415
+ expect(word.gsub(/_Toc\d\d+/, "_Toc")).to be_equivalent_to <<~'OUTPUT'
416
+ <div class="WordSection2">
417
+ /* an empty word intro page */
418
+
419
+ <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
420
+ \o "1-3" \h \z \u <span style="mso-element:field-separator"></span></span>
421
+ <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
422
+ <a href="#_Toc">1. Clause 4<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
423
+ <span style="mso-tab-count:1 dotted">. </span>
424
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
425
+ <span style="mso-element:field-begin"></span></span>
426
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
427
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
428
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
429
+
430
+ <p class="MsoToc2">
431
+ <span class="MsoHyperlink">
432
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
433
+ <a href="#_Toc">1.1. Introduction to this<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
434
+ <span style="mso-tab-count:1 dotted">. </span>
435
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
436
+ <span style="mso-element:field-begin"></span></span>
437
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
438
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
439
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
440
+ </span>
441
+ </p>
442
+
443
+ <p class="MsoToc2">
444
+ <span class="MsoHyperlink">
445
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
446
+ <a href="#_Toc">1.2. Clause 4.2<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
447
+ <span style="mso-tab-count:1 dotted">. </span>
448
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
449
+ <span style="mso-element:field-begin"></span></span>
450
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
451
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
452
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
453
+ </span>
454
+ </p>
455
+
456
+ <p class="MsoToc3">
457
+ <span class="MsoHyperlink">
458
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
459
+ <a href="#_Toc">1.2.1. Clause 4.2.1<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
460
+ <span style="mso-tab-count:1 dotted">. </span>
461
+ </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
462
+ <span style="mso-element:field-begin"></span></span>
463
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
464
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
465
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
466
+ </span>
467
+ </p>
468
+
469
+ <p class="MsoToc1">
470
+ <span lang="EN-GB" xml:lang="EN-GB">
471
+ <span style="mso-element:field-end"></span>
472
+ </span>
473
+ <span lang="EN-GB" xml:lang="EN-GB">
474
+ <p class="MsoNormal">&#xA0;</p>
475
+ </span>
476
+ </p>
477
+
478
+
479
+ <p class="MsoNormal">&#xA0;</p>
480
+ </div>
481
+ OUTPUT
482
+ end
483
+
484
+ it "generates HTML output with custom ToC levels function" do
485
+ FileUtils.rm_f "test.doc"
486
+ FileUtils.rm_f "test.html"
487
+ IsoDoc::HtmlConvert.new({htmltoclevels: 3}).convert("test", <<~"INPUT", false)
488
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
489
+ <preface><foreword>
490
+ <note>
491
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
492
+ </note>
493
+ </foreword></preface>
494
+ </iso-standard>
495
+ INPUT
496
+ html = File.read("test.html")
497
+ toclevel = <<~"TOCLEVEL"
498
+ function toclevel() { var i; var text = "";\n for(i = 1; i <= 3; i++) {
499
+ TOCLEVEL
500
+ expect(html).to include toclevel
501
+ end
502
+
415
503
  it "reorders footnote numbers in HTML" do
416
504
  FileUtils.rm_f "test.html"
417
505
  IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
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.9.19
4
+ version: 0.9.20
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-03-23 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1'
55
- - !ruby/object:Gem::Dependency
56
- name: ruby-xslt
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: thread_safe
71
57
  requirement: !ruby/object:Gem::Requirement