isodoc 1.0.24 → 1.0.29

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +14 -4
  3. data/.github/workflows/ubuntu.yml +19 -5
  4. data/.github/workflows/windows.yml +14 -4
  5. data/isodoc.gemspec +1 -1
  6. data/lib/isodoc-yaml/i18n-en.yaml +3 -1
  7. data/lib/isodoc-yaml/i18n-fr.yaml +3 -1
  8. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +3 -1
  9. data/lib/isodoc/convert.rb +1 -0
  10. data/lib/isodoc/function/blocks.rb +43 -49
  11. data/lib/isodoc/function/{blocks_example.rb → blocks_example_note.rb} +57 -2
  12. data/lib/isodoc/function/cleanup.rb +16 -2
  13. data/lib/isodoc/function/i18n.rb +1 -0
  14. data/lib/isodoc/function/inline.rb +79 -77
  15. data/lib/isodoc/function/inline_simple.rb +72 -0
  16. data/lib/isodoc/function/lists.rb +12 -6
  17. data/lib/isodoc/function/references.rb +51 -39
  18. data/lib/isodoc/function/reqt.rb +13 -4
  19. data/lib/isodoc/function/section.rb +19 -8
  20. data/lib/isodoc/function/table.rb +3 -4
  21. data/lib/isodoc/function/terms.rb +1 -1
  22. data/lib/isodoc/function/to_word_html.rb +23 -13
  23. data/lib/isodoc/function/utils.rb +13 -6
  24. data/lib/isodoc/function/xref_counter.rb +43 -9
  25. data/lib/isodoc/function/xref_gen.rb +2 -1
  26. data/lib/isodoc/function/xref_gen_seq.rb +11 -10
  27. data/lib/isodoc/function/xref_sect_gen.rb +24 -24
  28. data/lib/isodoc/headlesshtml_convert.rb +5 -0
  29. data/lib/isodoc/html_convert.rb +5 -0
  30. data/lib/isodoc/html_function/footnotes.rb +3 -3
  31. data/lib/isodoc/html_function/html.rb +16 -1
  32. data/lib/isodoc/html_function/postprocess.rb +6 -5
  33. data/lib/isodoc/metadata.rb +10 -3
  34. data/lib/isodoc/metadata_date.rb +19 -7
  35. data/lib/isodoc/pdf_convert.rb +5 -0
  36. data/lib/isodoc/version.rb +1 -1
  37. data/lib/isodoc/word_convert.rb +5 -0
  38. data/lib/isodoc/word_function/body.rb +13 -51
  39. data/lib/isodoc/word_function/footnotes.rb +3 -3
  40. data/lib/isodoc/word_function/inline.rb +75 -0
  41. data/lib/isodoc/word_function/postprocess.rb +13 -2
  42. data/lib/isodoc/word_function/table.rb +3 -3
  43. data/lib/isodoc/xslfo_convert.rb +5 -0
  44. data/spec/assets/i18n.yaml +4 -1
  45. data/spec/assets/odf.emf +0 -0
  46. data/spec/assets/odf.svg +4 -0
  47. data/spec/assets/odf1.svg +4 -0
  48. data/spec/isodoc/blocks_spec.rb +274 -51
  49. data/spec/isodoc/cleanup_spec.rb +317 -25
  50. data/spec/isodoc/footnotes_spec.rb +20 -5
  51. data/spec/isodoc/i18n_spec.rb +12 -12
  52. data/spec/isodoc/inline_spec.rb +299 -4
  53. data/spec/isodoc/lists_spec.rb +8 -8
  54. data/spec/isodoc/metadata_spec.rb +112 -3
  55. data/spec/isodoc/postproc_spec.rb +39 -21
  56. data/spec/isodoc/ref_spec.rb +121 -52
  57. data/spec/isodoc/section_spec.rb +236 -207
  58. data/spec/isodoc/table_spec.rb +28 -28
  59. data/spec/isodoc/terms_spec.rb +57 -13
  60. data/spec/isodoc/xref_spec.rb +218 -71
  61. metadata +10 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50ac1215a8065519d1dbab07c61a8c4e84dbc90923300bef4f6e44e4b9a8a843
4
- data.tar.gz: b89e80351f424c11fb7cb2b92c838a8b8b05f2791a1f91a1d531b14611632229
3
+ metadata.gz: 56ed930565ee3a3bbb9649d61e3b552f6a13de3bb66cbf6f0e134d341c457386
4
+ data.tar.gz: ee72443f7f96082b52b60bd525cb54d14088f0776c60bd88456bd5796de9d7a9
5
5
  SHA512:
6
- metadata.gz: d5ca6cf434f62383545145ccb02adccc060cc9fc5b79478655a5eaa21ca03332f1032baa87abc670935a586fa2cd957f3b8c9358e40802f33dcbc978e8da4b0a
7
- data.tar.gz: 01f839c290c1e557a162e2ae43aba2c8ecb291b86664759d72eeacd80b1f338734ce470827cd35485446b589f77b637a5cece6f3118b0855d2494f7537adc1e1
6
+ metadata.gz: 8effb0abf7faf7a63a40a3cee55465290e5d156be8af54f16b36283e191f52ff3cba4443cce54f95c6b38a86c951656d78179cb02b4010c98a6bea8d80c97501
7
+ data.tar.gz: 15c19b41ec493b97cc0ed06fbfe161f1d39f99e069f6d760a20858330f676c2bd35a60fe04f83b88569e6c61238090d0e2c336129f9665f6b695882fc75801d3
@@ -1,20 +1,26 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: macos
4
2
 
5
3
  on:
6
4
  push:
7
5
  branches: [ master ]
8
6
  pull_request:
7
+ paths-ignore:
8
+ - .github/workflows/ubuntu.yml
9
+ - .github/workflows/windows.yml
9
10
 
10
11
  jobs:
11
12
  test-macos:
12
13
  name: Test on Ruby ${{ matrix.ruby }} macOS
13
14
  runs-on: macos-latest
15
+ continue-on-error: ${{ matrix.experimental }}
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby: [ '2.6', '2.5', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
18
24
  steps:
19
25
  - uses: actions/checkout@master
20
26
  - name: Use Ruby
@@ -29,10 +35,14 @@ jobs:
29
35
  - name: Use Node
30
36
  uses: actions/setup-node@v1
31
37
  with:
32
- node-version: '8'
38
+ node-version: '12'
33
39
  - name: Install Puppeteer
34
40
  run: |
35
- npm install -g puppeteer
41
+ npm install -g puppeteer@3.0.1
42
+ - name: Install Inkscape
43
+ run: |
44
+ brew cask install inkscape
45
+ inkscape --version
36
46
  - name: Run specs
37
47
  run: |
38
48
  bundle exec rake
@@ -1,20 +1,26 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: ubuntu
4
2
 
5
3
  on:
6
4
  push:
7
5
  branches: [ master ]
8
6
  pull_request:
7
+ paths-ignore:
8
+ - .github/workflows/macos.yml
9
+ - .github/workflows/windows.yml
9
10
 
10
11
  jobs:
11
12
  test-linux:
12
13
  name: Test on Ruby ${{ matrix.ruby }} Ubuntu
13
14
  runs-on: ubuntu-latest
15
+ continue-on-error: ${{ matrix.experimental }}
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby: [ '2.6', '2.5', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
18
24
  steps:
19
25
  - uses: actions/checkout@master
20
26
  - name: Use Ruby
@@ -29,15 +35,23 @@ jobs:
29
35
  - name: Use Node
30
36
  uses: actions/setup-node@v1
31
37
  with:
32
- node-version: '8'
38
+ node-version: '12'
33
39
  - name: Install Puppeteer
34
40
  run: |
35
- npm install -g puppeteer
41
+ sudo apt-get update
42
+ sudo apt-get install libgbm1
43
+ npm install -g puppeteer@3.0.1
44
+ - name: Install Inkscape
45
+ run: |
46
+ sudo add-apt-repository ppa:inkscape.dev/stable
47
+ sudo apt update
48
+ sudo apt install inkscape
49
+ inkscape --version
36
50
  - name: Run specs
37
51
  run: |
38
52
  bundle exec rake
39
53
  - name: Trigger dependent repositories
40
- if: github.ref == 'refs/heads/master'
54
+ if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
41
55
  env:
42
56
  GH_USERNAME: ${{ secrets.PAT_USERNAME }}
43
57
  GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
@@ -1,20 +1,26 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: windows
4
2
 
5
3
  on:
6
4
  push:
7
5
  branches: [ master ]
8
6
  pull_request:
7
+ paths-ignore:
8
+ - .github/workflows/macos.yml
9
+ - .github/workflows/ubuntu.yml
9
10
 
10
11
  jobs:
11
12
  test-windows:
12
13
  name: Test on Ruby ${{ matrix.ruby }} Windows
13
14
  runs-on: windows-latest
15
+ continue-on-error: ${{ matrix.experimental }}
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby: [ '2.6', '2.5', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
18
24
  steps:
19
25
  - uses: actions/checkout@master
20
26
  - name: Use Ruby
@@ -31,10 +37,14 @@ jobs:
31
37
  - name: Use Node
32
38
  uses: actions/setup-node@v1
33
39
  with:
34
- node-version: '8'
40
+ node-version: '12'
35
41
  - name: Install Puppeteer
36
42
  run: |
37
- npm install -g puppeteer
43
+ npm install -g puppeteer@3.0.1
44
+ - name: Install Inkscape
45
+ run: |
46
+ choco install --no-progress -y inkscape
47
+ inkscape --version
38
48
  - name: Run specs
39
49
  run: |
40
50
  bundle exec rake
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "html2doc", "~> 1.0.0"
37
37
  spec.add_dependency "liquid"
38
38
  spec.add_dependency "roman-numerals"
39
- spec.add_dependency "sassc", "~> 2.2.1"
39
+ spec.add_dependency "sassc", "~> 2.4.0"
40
40
  spec.add_dependency "metanorma", "~> 1.0.0"
41
41
  spec.add_dependency "rake", "~> 12.0"
42
42
 
@@ -6,7 +6,9 @@ introduction: Introduction
6
6
  foreword: Foreword
7
7
  abstract: Abstract
8
8
  termsdef: Terms and definitions
9
- termsdefsymbols: Terms, definitions, symbols and abbreviated terms
9
+ termsdefsymbolsabbrev: Terms, definitions, symbols and abbreviated terms
10
+ termsdefsymbols: Terms, definitions and symbols
11
+ termsdefabbrev: Terms, definitions and abbreviated terms
10
12
  normref: Normative references
11
13
  bibliography: Bibliography
12
14
  clause: Clause
@@ -6,7 +6,9 @@ introduction: Introduction
6
6
  foreword: Avant-propos
7
7
  abstract: Résumé
8
8
  termsdef: Terms et définitions
9
- termsdefsymbols: Terms, définitions, symboles et termes abrégés
9
+ termsdefsymbolsabbrev: Terms, définitions, symboles et termes abrégés
10
+ termsdefsymbols: Terms, définitions et symboles
11
+ termsdefabbrev: Terms, définitions et termes abrégés
10
12
  normref: Références normatives
11
13
  bibliography: Bibliographie
12
14
  clause: Article
@@ -6,7 +6,9 @@ introduction: 引言
6
6
  foreword: 前言
7
7
  abstract: 摘要
8
8
  termsdef: 术语和定义
9
- termsdefsymbols: 术语、定义、符号、代号和缩略语
9
+ termsdefsymbolsabbrev: 术语、定义、符号、代号和缩略语
10
+ termsdefsymbols: 术语、定义、符号和代号
11
+ termsdefabbrev: 术语、定义、符号和缩略语
10
12
  normref: 规范性引用文件
11
13
  bibliography: 参考文献
12
14
  clause: 条
@@ -48,6 +48,7 @@ module IsoDoc
48
48
  @olstyle = options[:olstyle]
49
49
  @datauriimage = options[:datauriimage]
50
50
  @suppressheadingnumbers = options[:suppressheadingnumbers]
51
+ @break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
51
52
  @termdomain = ""
52
53
  @termexample = false
53
54
  @note = false
@@ -1,45 +1,9 @@
1
- require_relative "blocks_example"
1
+ require_relative "blocks_example_note"
2
2
 
3
3
  module IsoDoc::Function
4
4
  module Blocks
5
5
  @annotation = false
6
6
 
7
- def note_label(node)
8
- n = get_anchors[node["id"]]
9
- return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
10
- l10n("#{@note_lbl} #{n[:label]}")
11
- end
12
-
13
- def note_p_parse(node, div)
14
- div.p do |p|
15
- p.span **{ class: "note_label" } do |s|
16
- s << note_label(node)
17
- end
18
- insert_tab(p, 1)
19
- node.first_element_child.children.each { |n| parse(n, p) }
20
- end
21
- node.element_children[1..-1].each { |n| parse(n, div) }
22
- end
23
-
24
- def note_parse1(node, div)
25
- div.p do |p|
26
- p.span **{ class: "note_label" } do |s|
27
- s << note_label(node)
28
- end
29
- insert_tab(p, 1)
30
- end
31
- node.children.each { |n| parse(n, div) }
32
- end
33
-
34
- def note_parse(node, out)
35
- @note = true
36
- out.div **{ id: node["id"], class: "Note" } do |div|
37
- node.first_element_child.name == "p" ?
38
- note_p_parse(node, div) : note_parse1(node, div)
39
- end
40
- @note = false
41
- end
42
-
43
7
  def figure_name_parse(node, div, name)
44
8
  return if name.nil? && node.at(ns("./figure"))
45
9
  lbl = anchor(node['id'], :label, false)
@@ -58,11 +22,15 @@ module IsoDoc::Function
58
22
  end
59
23
  end
60
24
 
25
+ def figure_attrs(node)
26
+ attr_code(id: node["id"], class: "figure", style: keep_style(node))
27
+ end
28
+
61
29
  def figure_parse(node, out)
62
30
  return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
63
31
  node["type"] == "pseudocode"
64
32
  @in_figure = true
65
- out.div **attr_code(id: node["id"], class: "figure") do |div|
33
+ out.div **figure_attrs(node) do |div|
66
34
  node.children.each do |n|
67
35
  figure_key(out) if n.name == "dl"
68
36
  parse(n, div) unless n.name == "name"
@@ -72,10 +40,14 @@ module IsoDoc::Function
72
40
  @in_figure = false
73
41
  end
74
42
 
43
+ def pseudocode_attrs(node)
44
+ attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
45
+ end
46
+
75
47
  def pseudocode_parse(node, out)
76
48
  @in_figure = true
77
49
  name = node.at(ns("./name"))
78
- out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
50
+ out.div **pseudocode_attrs(node) do |div|
79
51
  node.children.each { |n| parse(n, div) unless n.name == "name" }
80
52
  sourcecode_name_parse(node, div, name)
81
53
  end
@@ -101,9 +73,13 @@ module IsoDoc::Function
101
73
  end
102
74
  end
103
75
 
76
+ def sourcecode_attrs(node)
77
+ attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
78
+ end
79
+
104
80
  def sourcecode_parse(node, out)
105
81
  name = node.at(ns("./name"))
106
- out.p **attr_code(id: node["id"], class: "Sourcecode") do |div|
82
+ out.p **sourcecode_attrs(node) do |div|
107
83
  @sourcecode = true
108
84
  node.children.each { |n| parse(n, div) unless n.name == "name" }
109
85
  @sourcecode = false
@@ -138,10 +114,15 @@ module IsoDoc::Function
138
114
  name
139
115
  end
140
116
 
117
+ def admonition_attrs(node)
118
+ attr_code(id: node["id"], class: admonition_class(node),
119
+ style: keep_style(node))
120
+ end
121
+
141
122
  def admonition_parse(node, out)
142
123
  type = node["type"]
143
124
  name = admonition_name(node, type)
144
- out.div **{ class: admonition_class(node) } do |t|
125
+ out.div **admonition_attrs(node) do |t|
145
126
  admonition_name_parse(node, t, name) if name
146
127
  node.children.each { |n| parse(n, t) unless n.name == "name" }
147
128
  end
@@ -157,7 +138,7 @@ module IsoDoc::Function
157
138
  end
158
139
 
159
140
  def formula_parse1(node, out)
160
- out.div **attr_code(id: node["id"], class: "formula") do |div|
141
+ out.div **attr_code(class: "formula") do |div|
161
142
  div.p do |p|
162
143
  parse(node.at(ns("./stem")), div)
163
144
  lbl = anchor(node['id'], :label, false)
@@ -169,12 +150,18 @@ module IsoDoc::Function
169
150
  end
170
151
  end
171
152
 
153
+ def formula_attrs(node)
154
+ attr_code(id: node["id"], style: keep_style(node))
155
+ end
156
+
172
157
  def formula_parse(node, out)
173
- formula_parse1(node, out)
174
- formula_where(node.at(ns("./dl")), out)
175
- node.children.each do |n|
176
- next if %w(stem dl).include? n.name
177
- parse(n, out)
158
+ out.div **formula_attrs(node) do |div|
159
+ formula_parse1(node, div)
160
+ formula_where(node.at(ns("./dl")), div)
161
+ node.children.each do |n|
162
+ next if %w(stem dl).include? n.name
163
+ parse(n, div)
164
+ end
178
165
  end
179
166
  end
180
167
 
@@ -187,8 +174,9 @@ module IsoDoc::Function
187
174
 
188
175
  def para_attrs(node)
189
176
  attrs = { class: para_class(node), id: node["id"] }
190
- node["align"].nil? or
191
- attrs[:style] = "text-align:#{node['align']};"
177
+ s = node["align"].nil? ? "" : "text-align:#{node['align']};"
178
+ s = "#{s}#{keep_style(node)}"
179
+ attrs[:style] = s unless s.empty?
192
180
  attrs
193
181
  end
194
182
 
@@ -222,5 +210,11 @@ module IsoDoc::Function
222
210
  quote_attribution(node, out)
223
211
  end
224
212
  end
213
+
214
+ def passthrough_parse(node, out)
215
+ return if node["format"] and
216
+ !(node["format"].split(/,/).include? @format.to_s)
217
+ out.passthrough node.text
218
+ end
225
219
  end
226
220
  end
@@ -15,9 +15,13 @@ module IsoDoc::Function
15
15
  { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
16
16
  margin-left:0pt;vertical-align:top;" }.freeze
17
17
 
18
+ def example_div_attr(node)
19
+ attr_code(id: node["id"], class: "example", style: keep_style(node))
20
+ end
21
+
18
22
  # used if we are boxing examples
19
23
  def example_div_parse(node, out)
20
- out.div **attr_code(id: node["id"], class: "example") do |div|
24
+ out.div **example_div_attr(node) do |div|
21
25
  example_label(node, div, node.at(ns("./name")))
22
26
  node.children.each do |n|
23
27
  parse(n, div) unless n.name == "name"
@@ -27,7 +31,8 @@ module IsoDoc::Function
27
31
 
28
32
  def example_table_attr(node)
29
33
  attr_code(id: node["id"], class: "example",
30
- style: "border-collapse:collapse;border-spacing:0;" )
34
+ style: "border-collapse:collapse;border-spacing:0;"\
35
+ "#{keep_style(node)}" )
31
36
  end
32
37
 
33
38
  EXAMPLE_TD_ATTR =
@@ -49,5 +54,55 @@ module IsoDoc::Function
49
54
  def example_parse(node, out)
50
55
  example_div_parse(node, out)
51
56
  end
57
+
58
+ def note_label(node)
59
+ n = get_anchors[node["id"]]
60
+ return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
61
+ l10n("#{@note_lbl} #{n[:label]}")
62
+ end
63
+
64
+ def note_p_parse(node, div)
65
+ div.p do |p|
66
+ p.span **{ class: "note_label" } do |s|
67
+ s << note_label(node)
68
+ end
69
+ insert_tab(p, 1)
70
+ node.first_element_child.children.each { |n| parse(n, p) }
71
+ end
72
+ node.element_children[1..-1].each { |n| parse(n, div) }
73
+ end
74
+
75
+ def note_parse1(node, div)
76
+ div.p do |p|
77
+ p.span **{ class: "note_label" } do |s|
78
+ s << note_label(node)
79
+ end
80
+ insert_tab(p, 1)
81
+ end
82
+ node.children.each { |n| parse(n, div) }
83
+ end
84
+
85
+ def keep_style(node)
86
+ ret = ""
87
+ node["keep-with-next"] == "true" and
88
+ ret += "page-break-after: avoid;"
89
+ node["keep-lines-together"] == "true" and
90
+ ret += "page-break-inside: avoid;"
91
+ return nil if ret.empty?
92
+ ret
93
+ end
94
+
95
+ def note_attrs(node)
96
+ attr_code(id: node["id"], class: "Note", style: keep_style(node))
97
+ end
98
+
99
+ def note_parse(node, out)
100
+ @note = true
101
+ out.div **note_attrs(node) do |div|
102
+ node.first_element_child.name == "p" ?
103
+ note_p_parse(node, div) : note_parse1(node, div)
104
+ end
105
+ @note = false
106
+ end
52
107
  end
53
108
  end