isodoc 1.0.28 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d2aca20ce5f2e96df3da6fbb1a8e675e3b2393f51720bac2bdc760e6e9c09a5
4
- data.tar.gz: 6f83efeb115dbbb30f928d99e8f8c6da4172fc2a17d1792607d2cd38d6b5833c
3
+ metadata.gz: 56ed930565ee3a3bbb9649d61e3b552f6a13de3bb66cbf6f0e134d341c457386
4
+ data.tar.gz: ee72443f7f96082b52b60bd525cb54d14088f0776c60bd88456bd5796de9d7a9
5
5
  SHA512:
6
- metadata.gz: f3e63f2f2f04dea86c5b716be19385eec4273bdd57870ee1215f441e2b6494ea25c8c52c3edf40b8b657ed8d081667356b003e68ded049605f2985450e903649
7
- data.tar.gz: a1f408ba884174786963f38a5912ec128a94223b5f9f66fb28662398a6785bb2b54a42554fc3c2bb004230d443a6a38b8d771a1cdf64ec12447ea4e132b46a2c
6
+ metadata.gz: 8effb0abf7faf7a63a40a3cee55465290e5d156be8af54f16b36283e191f52ff3cba4443cce54f95c6b38a86c951656d78179cb02b4010c98a6bea8d80c97501
7
+ data.tar.gz: 15c19b41ec493b97cc0ed06fbfe161f1d39f99e069f6d760a20858330f676c2bd35a60fe04f83b88569e6c61238090d0e2c336129f9665f6b695882fc75801d3
@@ -1,5 +1,3 @@
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:
@@ -41,6 +39,10 @@ jobs:
41
39
  - name: Install Puppeteer
42
40
  run: |
43
41
  npm install -g puppeteer@3.0.1
42
+ - name: Install Inkscape
43
+ run: |
44
+ brew cask install inkscape
45
+ inkscape --version
44
46
  - name: Run specs
45
47
  run: |
46
48
  bundle exec rake
@@ -1,5 +1,3 @@
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:
@@ -43,6 +41,12 @@ jobs:
43
41
  sudo apt-get update
44
42
  sudo apt-get install libgbm1
45
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
46
50
  - name: Run specs
47
51
  run: |
48
52
  bundle exec rake
@@ -1,5 +1,3 @@
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:
@@ -43,6 +41,10 @@ jobs:
43
41
  - name: Install Puppeteer
44
42
  run: |
45
43
  npm install -g puppeteer@3.0.1
44
+ - name: Install Inkscape
45
+ run: |
46
+ choco install --no-progress -y inkscape
47
+ inkscape --version
46
48
  - name: Run specs
47
49
  run: |
48
50
  bundle exec rake
@@ -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 **{ id: node["id"], 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
 
@@ -224,7 +212,8 @@ module IsoDoc::Function
224
212
  end
225
213
 
226
214
  def passthrough_parse(node, out)
227
- return if node["format"] and !(node["format"].split(/,/).include? @format.to_s)
215
+ return if node["format"] and
216
+ !(node["format"].split(/,/).include? @format.to_s)
228
217
  out.passthrough node.text
229
218
  end
230
219
  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
@@ -87,6 +87,7 @@ module IsoDoc::Function
87
87
 
88
88
  # TODO: move to localization file
89
89
  def eref_localities1(target, type, from, to, delim, lang = "en")
90
+ return "" if type == "anchor"
90
91
  return l10n(eref_localities1_zh(target, type, from, to, delim)) if lang == "zh"
91
92
  ret = delim
92
93
  loc = @locality[type] || type.sub(/^locality:/, "").capitalize
@@ -90,21 +90,38 @@ module IsoDoc::Function
90
90
  end
91
91
 
92
92
  def eref_localities0(r, i, target, delim)
93
- if r["type"] == "whole" then l10n("#{delim} #{@whole_of_text}")
93
+ if r["type"] == "whole" then l10n("#{delim} #{@wholeoftext_lbl}")
94
94
  else
95
95
  eref_localities1(target, r["type"], r.at(ns("./referenceFrom")),
96
96
  r.at(ns("./referenceTo")), delim, @lang)
97
97
  end
98
98
  end
99
99
 
100
+ def suffix_url(url)
101
+ return url if %r{^http[s]?://}.match(url)
102
+ url.sub(/#{File.extname(url)}$/, ".html")
103
+ end
104
+
105
+ def eref_target(node)
106
+ href = "#" + node["bibitemid"]
107
+ url = node.at(ns("//bibitem[@id = '#{node['bibitemid']}']/"\
108
+ "uri[@type = 'citation']"))
109
+ return href unless url
110
+ href = suffix_url(url.text)
111
+ anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text
112
+ anchor and href += "##{anchor}"
113
+ href
114
+ end
115
+
100
116
  def eref_parse(node, out)
101
117
  linkend = get_linkend(node)
118
+ href = eref_target(node)
102
119
  if node["type"] == "footnote"
103
120
  out.sup do |s|
104
- s.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
121
+ s.a(**{ "href": href }) { |l| l << linkend }
105
122
  end
106
123
  else
107
- out.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
124
+ out.a(**{ "href": href }) { |l| l << linkend }
108
125
  end
109
126
  end
110
127
 
@@ -1,8 +1,11 @@
1
1
  module IsoDoc::Function
2
2
  module Lists
3
+ def ul_attrs(node)
4
+ { id: node["id"], style: keep_style(node) }
5
+ end
3
6
 
4
7
  def ul_parse(node, out)
5
- out.ul **attr_code(id: node["id"]) do |ul|
8
+ out.ul **attr_code(ul_attrs(node)) do |ul|
6
9
  node.children.each { |n| parse(n, ul) }
7
10
  end
8
11
  end
@@ -34,9 +37,12 @@ module IsoDoc::Function
34
37
  ol_style(type)
35
38
  end
36
39
 
40
+ def ol_attrs(node)
41
+ { type: ol_depth(node), id: node["id"], style: keep_style(node) }
42
+ end
43
+
37
44
  def ol_parse(node, out)
38
- style = ol_depth(node)
39
- out.ol **attr_code(type: style, id: node["id"] ) do |ol|
45
+ out.ol **attr_code(ol_attrs(node)) do |ol|
40
46
  node.children.each { |n| parse(n, ol) }
41
47
  end
42
48
  end
@@ -67,12 +73,12 @@ module IsoDoc::Function
67
73
  %w{dt dd}.include? n.name
68
74
  end
69
75
 
70
- def dl_attr(node)
71
- attr_code(id: node["id"])
76
+ def dl_attrs(node)
77
+ attr_code(id: node["id"], style: keep_style(node))
72
78
  end
73
79
 
74
80
  def dl_parse(node, out)
75
- out.dl **dl_attr(node) do |v|
81
+ out.dl **dl_attrs(node) do |v|
76
82
  node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
77
83
  v.dt **attr_code(id: dt["id"]) do |term|
78
84
  dt_parse(dt, term)
@@ -6,6 +6,7 @@ module IsoDoc::Function
6
6
  def docid_l10n(x)
7
7
  return x if x.nil?
8
8
  x.gsub(/All Parts/i, @all_parts_lbl.downcase) if @all_parts_lbl
9
+ x
9
10
  end
10
11
 
11
12
  # TODO generate formatted ref if not present
@@ -88,9 +89,8 @@ module IsoDoc::Function
88
89
  end
89
90
 
90
91
  def date_note_process(b, ref)
91
- date_note = b.at(ns("./note[text()][contains(.,'ISO DATE:')]"))
92
+ date_note = b.at(ns("./note[@type = 'ISO DATE']"))
92
93
  return if date_note.nil?
93
- date_note.content = date_note.content.gsub(/ISO DATE: /, "")
94
94
  date_note.children.first.replace("<p>#{date_note.content}</p>")
95
95
  footnote_parse(date_note, ref)
96
96
  end
@@ -60,8 +60,12 @@ module IsoDoc::Function
60
60
  %w(label title subject classification tag value inherit).include? n.name
61
61
  end
62
62
 
63
+ def reqt_attrs(node, klass)
64
+ attr_code(class: klass, id: node["id"], style: keep_style(node))
65
+ end
66
+
63
67
  def recommendation_parse(node, out)
64
- out.div **{ class: "recommend" } do |t|
68
+ out.div **reqt_attrs(node, "recommend") do |t|
65
69
  recommendation_name(node, t, @recommendation_lbl)
66
70
  recommendation_attributes(node, out)
67
71
  node.children.each do |n|
@@ -71,7 +75,7 @@ module IsoDoc::Function
71
75
  end
72
76
 
73
77
  def requirement_parse(node, out)
74
- out.div **{ class: "require" } do |t|
78
+ out.div **reqt_attrs(node, "require") do |t|
75
79
  recommendation_name(node, t, @requirement_lbl)
76
80
  recommendation_attributes(node, out)
77
81
  node.children.each do |n|
@@ -81,7 +85,7 @@ module IsoDoc::Function
81
85
  end
82
86
 
83
87
  def permission_parse(node, out)
84
- out.div **{ class: "permission" } do |t|
88
+ out.div **reqt_attrs(node, "permission") do |t|
85
89
  recommendation_name(node, t, @permission_lbl)
86
90
  recommendation_attributes(node, out)
87
91
  node.children.each do |n|
@@ -90,9 +94,14 @@ module IsoDoc::Function
90
94
  end
91
95
  end
92
96
 
97
+ def reqt_component_attrs(node)
98
+ attr_code(class: "requirement-" + node.name,
99
+ style: keep_style(node))
100
+ end
101
+
93
102
  def requirement_component_parse(node, out)
94
103
  return if node["exclude"] == "true"
95
- out.div **{ class: "requirement-" + node.name } do |div|
104
+ out.div **reqt_component_attrs(node) do |div|
96
105
  node.children.each do |n|
97
106
  parse(n, div)
98
107
  end