isodoc 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -1
  3. data/.rubocop.yml +6 -2
  4. data/Gemfile +2 -2
  5. data/isodoc.gemspec +11 -11
  6. data/lib/isodoc/base_style/all.css +7 -0
  7. data/lib/isodoc/base_style/metanorma_word.css +7 -0
  8. data/lib/isodoc/base_style/metanorma_word.scss +8 -0
  9. data/lib/isodoc/base_style/reset.css +7 -0
  10. data/lib/isodoc/base_style/reset.scss +9 -0
  11. data/lib/isodoc/base_style/scripts.html +187 -0
  12. data/lib/isodoc/class_utils.rb +6 -5
  13. data/lib/isodoc/convert.rb +28 -15
  14. data/lib/isodoc/css.rb +14 -4
  15. data/lib/isodoc/function/blocks.rb +4 -0
  16. data/lib/isodoc/function/inline.rb +31 -10
  17. data/lib/isodoc/function/references.rb +1 -1
  18. data/lib/isodoc/function/to_word_html.rb +19 -8
  19. data/lib/isodoc/function/utils.rb +1 -0
  20. data/lib/isodoc/html_function/postprocess.rb +8 -5
  21. data/lib/isodoc/pdf_convert.rb +1 -3
  22. data/lib/isodoc/presentation_function/block.rb +11 -5
  23. data/lib/isodoc/presentation_function/inline.rb +42 -38
  24. data/lib/isodoc/presentation_function/section.rb +1 -1
  25. data/lib/isodoc/presentation_xml_convert.rb +1 -1
  26. data/lib/isodoc/version.rb +1 -1
  27. data/lib/isodoc/word_function/inline.rb +6 -0
  28. data/lib/isodoc/word_function/postprocess.rb +16 -6
  29. data/lib/isodoc/xref.rb +1 -1
  30. data/lib/isodoc/xref/xref_gen.rb +16 -15
  31. data/lib/isodoc/xslfo_convert.rb +36 -25
  32. data/spec/assets/html_override.css +1 -0
  33. data/spec/assets/word_override.css +1 -0
  34. data/spec/isodoc/blocks_spec.rb +87 -0
  35. data/spec/isodoc/footnotes_spec.rb +1 -16
  36. data/spec/isodoc/inline_spec.rb +38 -1
  37. data/spec/isodoc/postproc_spec.rb +42 -14
  38. data/spec/isodoc/presentation_xml_spec.rb +345 -338
  39. data/spec/isodoc/section_spec.rb +910 -902
  40. data/spec/isodoc/table_spec.rb +566 -556
  41. data/spec/isodoc/terms_spec.rb +252 -256
  42. data/spec/isodoc/xref_spec.rb +2990 -2987
  43. data/spec/isodoc/xslfo_convert_spec.rb +39 -0
  44. data/spec/spec_helper.rb +30 -29
  45. metadata +71 -69
  46. data/.rubocop.ribose.yml +0 -65
  47. data/.rubocop.tb.yml +0 -650
@@ -0,0 +1,39 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe IsoDoc do
4
+ it "test empty pdf_options" do
5
+ convert = IsoDoc::XslfoPdfConvert.new(
6
+ {
7
+ datauriimage: false,
8
+ }
9
+ )
10
+
11
+ expect(convert.pdf_options(nil)).to eq("")
12
+ end
13
+
14
+ it "test empty pdf_options for nil font_manifest_file" do
15
+ convert = IsoDoc::XslfoPdfConvert.new(
16
+ {
17
+ datauriimage: false,
18
+ IsoDoc::XslfoPdfConvert::MN2PDF_OPTIONS => {
19
+ IsoDoc::XslfoPdfConvert::MN2PDF_FONT_MANIFEST => nil,
20
+ },
21
+ }
22
+ )
23
+
24
+ expect(convert.pdf_options(nil)).to eq("")
25
+ end
26
+
27
+ it "test --font-manifest pdf_options" do
28
+ convert = IsoDoc::XslfoPdfConvert.new(
29
+ {
30
+ datauriimage: false,
31
+ IsoDoc::XslfoPdfConvert::MN2PDF_OPTIONS => {
32
+ IsoDoc::XslfoPdfConvert::MN2PDF_FONT_MANIFEST => "/tmp/manifest.yml",
33
+ },
34
+ }
35
+ )
36
+
37
+ expect(convert.pdf_options(nil)).to eq("--font-manifest /tmp/manifest.yml")
38
+ end
39
+ end
data/spec/spec_helper.rb CHANGED
@@ -21,45 +21,46 @@ RSpec.configure do |config|
21
21
  end
22
22
  end
23
23
 
24
- def xmlpp(x)
24
+ def xmlpp(xml)
25
25
  s = ""
26
26
  f = REXML::Formatters::Pretty.new(2)
27
27
  f.compact = true
28
- f.write(REXML::Document.new(x),s)
28
+ f.write(REXML::Document.new(xml), s)
29
29
  s
30
30
  end
31
31
 
32
- def metadata(x)
33
- Hash[x.sort].delete_if{ |k, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
32
+ def metadata(hash)
33
+ Hash[hash.sort].delete_if do |_k, v|
34
+ v.nil? || v.respond_to?(:empty?) && v.empty?
35
+ end
34
36
  end
35
37
 
36
- # expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
37
-
38
- def strip_guid(x)
39
- x.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"').
40
- gsub(%r( href="#[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' href="#_"').
41
- gsub(%r( id="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="_"').
42
- gsub(%r( id="ftn[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="ftn_"').
43
- gsub(%r( id="fn:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="fn:_"').
44
- gsub(%r[ src="([^/]+)/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.], ' src="\\1/_.')
38
+ def strip_guid(xml)
39
+ xml.gsub(%r{ id="_[^"]+"}, ' id="_"')
40
+ .gsub(%r{ target="_[^"]+"}, ' target="_"')
41
+ .gsub(%r( href="#[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' href="#_"')
42
+ .gsub(%r( id="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="_"')
43
+ .gsub(%r( id="ftn[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="ftn_"')
44
+ .gsub(%r( id="fn:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="fn:_"')
45
+ .gsub(%r[ src="([^/]+)/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.], ' src="\\1/_.')
45
46
  end
46
47
 
47
- HTML_HDR = <<~END
48
- <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
49
- <head/>
50
- <body lang="en">
51
- <div class="title-section">
52
- <p>&#160;</p>
53
- </div>
54
- <br/>
55
- <div class="prefatory-section">
56
- <p>&#160;</p>
57
- </div>
58
- <br/>
59
- <div class="main-section">
60
- END
48
+ HTML_HDR = <<~HEADER.freeze
49
+ <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
50
+ <head/>
51
+ <body lang="en">
52
+ <div class="title-section">
53
+ <p>&#160;</p>
54
+ </div>
55
+ <br/>
56
+ <div class="prefatory-section">
57
+ <p>&#160;</p>
58
+ </div>
59
+ <br/>
60
+ <div class="main-section">
61
+ HEADER
61
62
 
62
- WORD_HDR = <<~END
63
+ WORD_HDR = <<~HEADER.freeze
63
64
  <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
64
65
  <head>
65
66
  <style>
@@ -77,4 +78,4 @@ WORD_HDR = <<~END
77
78
  </div>
78
79
  <p><br clear="all" class="section"/></p>
79
80
  <div class="WordSection3">
80
- END
81
+ HEADER
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.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-08 00:00:00.000000000 Z
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -25,91 +25,91 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: htmlentities
28
+ name: html2doc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.3.4
33
+ version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.3.4
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: nokogiri
42
+ name: htmlentities
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.10.4
47
+ version: 4.3.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.10.4
54
+ version: 4.3.4
55
55
  - !ruby/object:Gem::Dependency
56
- name: thread_safe
56
+ name: liquid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '4'
69
69
  - !ruby/object:Gem::Dependency
70
- name: uuidtools
70
+ name: metanorma
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 1.2.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 1.2.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: html2doc
84
+ name: nokogiri
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.0
89
+ version: 1.10.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.0
96
+ version: 1.10.4
97
97
  - !ruby/object:Gem::Dependency
98
- name: liquid
98
+ name: relaton-cli
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '4'
103
+ version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '4'
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: twitter_cldr
112
+ name: roman-numerals
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: roman-numerals
126
+ name: thread_safe
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,21 +137,21 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: metanorma
140
+ name: twitter_cldr
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 1.2.0
145
+ version: 6.6.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 1.2.0
152
+ version: 6.6.0
153
153
  - !ruby/object:Gem::Dependency
154
- name: relaton-cli
154
+ name: uuidtools
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,89 +165,89 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: rake
168
+ name: byebug
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '13.0'
173
+ version: '9.1'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '13.0'
180
+ version: '9.1'
181
181
  - !ruby/object:Gem::Dependency
182
- name: byebug
182
+ name: equivalent-xml
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '9.1'
187
+ version: '0.6'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '9.1'
194
+ version: '0.6'
195
195
  - !ruby/object:Gem::Dependency
196
- name: sassc
196
+ name: guard
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 2.4.0
201
+ version: '2.14'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 2.4.0
208
+ version: '2.14'
209
209
  - !ruby/object:Gem::Dependency
210
- name: equivalent-xml
210
+ name: guard-rspec
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '0.6'
215
+ version: '4.7'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '0.6'
222
+ version: '4.7'
223
223
  - !ruby/object:Gem::Dependency
224
- name: guard
224
+ name: rake
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '2.14'
229
+ version: '13.0'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '2.14'
236
+ version: '13.0'
237
237
  - !ruby/object:Gem::Dependency
238
- name: guard-rspec
238
+ name: rexml
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - "~>"
241
+ - - ">="
242
242
  - !ruby/object:Gem::Version
243
- version: '4.7'
243
+ version: '0'
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
- - - "~>"
248
+ - - ">="
249
249
  - !ruby/object:Gem::Version
250
- version: '4.7'
250
+ version: '0'
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rspec
253
253
  requirement: !ruby/object:Gem::Requirement
@@ -266,58 +266,58 @@ dependencies:
266
266
  name: rubocop
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
- - - '='
269
+ - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: 0.54.0
271
+ version: 1.5.2
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
- - - '='
276
+ - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: 0.54.0
278
+ version: 1.5.2
279
279
  - !ruby/object:Gem::Dependency
280
- name: simplecov
280
+ name: sassc
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
283
  - - "~>"
284
284
  - !ruby/object:Gem::Version
285
- version: '0.15'
285
+ version: 2.4.0
286
286
  type: :development
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
- version: '0.15'
292
+ version: 2.4.0
293
293
  - !ruby/object:Gem::Dependency
294
- name: timecop
294
+ name: simplecov
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - "~>"
298
298
  - !ruby/object:Gem::Version
299
- version: '0.9'
299
+ version: '0.15'
300
300
  type: :development
301
301
  prerelease: false
302
302
  version_requirements: !ruby/object:Gem::Requirement
303
303
  requirements:
304
304
  - - "~>"
305
305
  - !ruby/object:Gem::Version
306
- version: '0.9'
306
+ version: '0.15'
307
307
  - !ruby/object:Gem::Dependency
308
- name: rexml
308
+ name: timecop
309
309
  requirement: !ruby/object:Gem::Requirement
310
310
  requirements:
311
- - - ">="
311
+ - - "~>"
312
312
  - !ruby/object:Gem::Version
313
- version: '0'
313
+ version: '0.9'
314
314
  type: :development
315
315
  prerelease: false
316
316
  version_requirements: !ruby/object:Gem::Requirement
317
317
  requirements:
318
- - - ">="
318
+ - - "~>"
319
319
  - !ruby/object:Gem::Version
320
- version: '0'
320
+ version: '0.9'
321
321
  description: |
322
322
  isodoc converts documents in the IsoDoc document model into
323
323
  Microsoft Word and HTML.
@@ -332,8 +332,6 @@ files:
332
332
  - ".github/workflows/rake.yml"
333
333
  - ".hound.yml"
334
334
  - ".oss-guides.rubocop.yml"
335
- - ".rubocop.ribose.yml"
336
- - ".rubocop.tb.yml"
337
335
  - ".rubocop.yml"
338
336
  - CODE_OF_CONDUCT.md
339
337
  - Gemfile
@@ -361,6 +359,7 @@ files:
361
359
  - lib/isodoc/base_style/nav.scss
362
360
  - lib/isodoc/base_style/reset.css
363
361
  - lib/isodoc/base_style/reset.scss
362
+ - lib/isodoc/base_style/scripts.html
364
363
  - lib/isodoc/base_style/typography.css
365
364
  - lib/isodoc/base_style/typography.scss
366
365
  - lib/isodoc/class_utils.rb
@@ -420,6 +419,7 @@ files:
420
419
  - lib/isodoc/xslfo_convert.rb
421
420
  - spec/assets/header.html
422
421
  - spec/assets/html.scss
422
+ - spec/assets/html_override.css
423
423
  - spec/assets/htmlcover.html
424
424
  - spec/assets/htmlintro.html
425
425
  - spec/assets/i18n.yaml
@@ -432,6 +432,7 @@ files:
432
432
  - spec/assets/scripts.html
433
433
  - spec/assets/std.css
434
434
  - spec/assets/word.css
435
+ - spec/assets/word_override.css
435
436
  - spec/assets/wordcover.html
436
437
  - spec/assets/wordintro.html
437
438
  - spec/isodoc/blocks_spec.rb
@@ -448,6 +449,7 @@ files:
448
449
  - spec/isodoc/table_spec.rb
449
450
  - spec/isodoc/terms_spec.rb
450
451
  - spec/isodoc/xref_spec.rb
452
+ - spec/isodoc/xslfo_convert_spec.rb
451
453
  - spec/spec_helper.rb
452
454
  homepage: https://github.com/metanorma/isodoc
453
455
  licenses: