metanorma-jis 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ module IsoDoc
10
10
  if t = elem.at(ns("./title"))
11
11
  t.children = "<strong>#{to_xml(t.children)}</strong>"
12
12
  end
13
- prefix_name(elem, "<br/>", lbl, "title")
13
+ prefix_name(elem, { caption: "<br/>" }, lbl, "title")
14
14
  end
15
15
 
16
16
  def annex(docxml)
@@ -31,6 +31,7 @@ module IsoDoc
31
31
  t = elem.elements.first
32
32
  commentary_title_hdr(t)
33
33
  middle_title_main(t, "CommentaryStandardName")
34
+ prefix_name(elem, {}, nil, "title")
34
35
  end
35
36
 
36
37
  def commentary_title_hdr(elem)
@@ -60,7 +60,8 @@ module IsoDoc
60
60
  def dl_to_para(node)
61
61
  ret = dl_to_para_name(node)
62
62
  ret += dl_to_para_terms(node)
63
- node.elements.reject { |n| %w(dt dd name).include?(n.name) }.each do |x|
63
+ node.elements.reject { |n| %w(dt dd name fmt-name).include?(n.name) }
64
+ .each do |x|
64
65
  ret += x.to_xml
65
66
  end
66
67
  dl_id_insert(node, ret)
@@ -74,7 +75,7 @@ module IsoDoc
74
75
  end
75
76
 
76
77
  def dl_to_para_name(node)
77
- e = node.at(ns("./name")) or return ""
78
+ e = node.at(ns("./fmt-name")) or return ""
78
79
  "<p class='ListTitle'>#{e.children.to_xml}</p>"
79
80
  end
80
81
 
@@ -96,8 +97,9 @@ module IsoDoc
96
97
  def table1(node)
97
98
  super
98
99
  cols = table_cols_count(node)
99
- name = node.at(ns("./name"))
100
- thead = table_thead_pt(node, name)
100
+ ins = node.at(ns("./fmt-xref-label")) ||
101
+ node.at(ns("./fmt-name"))
102
+ thead = table_thead_pt(node, ins)
101
103
  table_unit_note(node, thead, cols)
102
104
  end
103
105
 
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  out.span do |s|
7
7
  s << @i18n.table_footnote
8
8
  out.span **attrs do |a|
9
- a << "#{fnref})"
9
+ a << fnref.sub(/(?!<\))$/, ")") # TODO TO Presentation XML
10
10
  end
11
11
  insert_tab(s, 1)
12
12
  end
@@ -66,9 +66,9 @@ module IsoDoc
66
66
  def norm_ref(node, out)
67
67
  node["hidden"] != "true" or return
68
68
  out.div class: "normref_div" do |div|
69
- clause_name(node, node.at(ns("./title")), div, nil)
69
+ clause_name(node, node.at(ns("./fmt-title")), div, nil)
70
70
  if node.name == "clause"
71
- node.elements.each { |e| parse(e, div) unless e.name == "title" }
71
+ node.elements.each { |e| parse(e, div) unless e.name == "fmt-title" }
72
72
  else biblio_list(node, div, false)
73
73
  end
74
74
  end
@@ -79,7 +79,7 @@ module IsoDoc
79
79
  page_break(out)
80
80
  out.div class: "bibliography" do |div|
81
81
  div.h1 class: "Section3" do |h1|
82
- node.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
82
+ node.at(ns("./fmt-title"))&.children&.each { |c2| parse(c2, h1) }
83
83
  end
84
84
  biblio_list(node, div, true)
85
85
  end
@@ -101,10 +101,10 @@ module IsoDoc
101
101
 
102
102
  def introduction(clause, out)
103
103
  out.div class: "Section3", id: clause["id"] do |div|
104
- clause_name(clause, clause.at(ns("./title")), div,
104
+ clause_name(clause, clause.at(ns("./fmt-title")), div,
105
105
  { class: "IntroTitle" })
106
106
  clause.elements.each do |e|
107
- parse(e, div) unless e.name == "title"
107
+ parse(e, div) unless e.name == "fmt-title"
108
108
  end
109
109
  end
110
110
  end
@@ -150,7 +150,7 @@ module IsoDoc
150
150
  def render_annex(out, clause)
151
151
  out.div **attr_code(annex_attrs(clause)) do |s|
152
152
  clause.elements.each do |c1|
153
- if c1.name == "title" then annex_name(clause, c1, s)
153
+ if c1.name == "fmt-title" then annex_name(clause, c1, s)
154
154
  else parse(c1, s)
155
155
  end
156
156
  end
@@ -24,19 +24,19 @@ module IsoDoc
24
24
  class Xref < IsoDoc::Iso::Xref
25
25
  attr_accessor :autonumbering_style
26
26
 
27
- def clause_sep
27
+ def clausesep
28
28
  @autonumbering_style == :japanese ? "\u30fb" : "."
29
29
  end
30
30
 
31
- def clause_counter(num, opts)
31
+ def clause_counter(num, opts = { })
32
32
  opts[:numerals] ||= @autonumbering_style
33
- opts[:separator] ||= clause_sep
33
+ opts[:separator] ||= clausesep
34
34
  super
35
35
  end
36
36
 
37
- def list_counter(num, opts)
37
+ def list_counter(num, opts = { })
38
38
  opts[:numerals] ||= @autonumbering_style
39
- opts[:separator] ||= clause_sep
39
+ opts[:separator] ||= clausesep
40
40
  IsoDoc::Jis::Counter.new(num, opts)
41
41
  end
42
42
 
@@ -44,13 +44,43 @@ module IsoDoc
44
44
  @lang == "ja" ? "の" : super
45
45
  end
46
46
 
47
- def subfigure_label(subfignum)
47
+ def hierreqtsep
48
+ @lang == "ja" ? "の" : super
49
+ end
50
+
51
+ # KILL
52
+ def subfigure_labelx(subfignum)
48
53
  subfignum.zero? and return ""
49
54
  sep = @lang == "ja" ? "の" : " "
50
55
  "#{sep}#{(subfignum + 96).chr})"
51
56
  end
52
57
 
53
- def annex_name_lbl(clause, num)
58
+ def subfigure_label(subfignum)
59
+ subfignum.zero? and return
60
+ (subfignum + 96).chr
61
+ end
62
+
63
+ def subfigure_delim
64
+ ")"
65
+ end
66
+
67
+ # taken from isodoc to override ISO
68
+ def subfigure_anchor(elem, sublabel, label, klass, container: false)
69
+ figlabel = fig_subfig_label(label, sublabel)
70
+ @anchors[elem["id"]] = anchor_struct(
71
+ figlabel, elem, @labels[klass] || klass.capitalize, klass,
72
+ { unnumb: elem["unnumbered"], container: }
73
+ )
74
+ if elem["unnumbered"] != "true"
75
+ x = semx(elem, sublabel)
76
+ @anchors[elem["id"]][:label] = x
77
+ @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] +
78
+ subfigure_separator(markup: true) + x + delim_wrap(subfigure_delim)
79
+ end
80
+ end
81
+
82
+ # KILL
83
+ def annex_name_lblx(clause, num)
54
84
  obl = "(#{@labels['inform_annex']})"
55
85
  clause["obligation"] == "normative" and
56
86
  obl = "(#{@labels['norm_annex']})"
@@ -59,19 +89,16 @@ module IsoDoc
59
89
  "#{title} #{num}<br/>#{obl}"
60
90
  end
61
91
 
62
- def annex_name_anchors1(clause, num, level)
63
- @anchors[clause["id"]] =
64
- { xref: num, label: num, level: level,
65
- subtype: "annex" }
92
+ def annex_name_lbl(clause, num)
93
+ super.gsub(%r{</?strong>}, "")
66
94
  end
67
95
 
68
- def annex_names1(clause, num, level)
69
- annex_name_anchors1(clause, num, level)
70
- i = clause_counter(0, prefix: num)
71
- clause.xpath(ns(SUBCLAUSES)).each do |c|
72
- annex_names1(c, i.increment(c).print, level + 1)
73
- end
74
- end
96
+ def annex_name_anchors1(clause, num, level)
97
+ super
98
+ # undo ISO "Clause A.2" in favour of "A.2"
99
+ level == 2 and
100
+ @anchors[clause["id"]][:xref] = semx(clause, num)
101
+ end
75
102
 
76
103
  def clause_order_main(docxml)
77
104
  [
@@ -128,31 +155,34 @@ module IsoDoc
128
155
  end
129
156
 
130
157
  def commentary_names(clause)
158
+ #require "debug" ; binding.b
131
159
  preface_name_anchors(clause, 1, clause_title(clause))
132
160
  clause.xpath(ns(SUBCLAUSES))
133
161
  .each_with_object(clause_counter(0, {})) do |c, i|
134
- commentary_names1(c, clause["id"], i.increment(c).print, 2)
162
+ commentary_names1(c, clause["id"], nil, i.increment(c).print, 2)
135
163
  end
136
164
  end
137
165
 
138
- def commentary_names1(clause, root, num, level)
139
- commentary_name_anchors(clause, num, root, level)
166
+ def commentary_names1(clause, root, parentnum, num, level)
167
+ lbl = clause_number_semx(parentnum, clause, num)
168
+ commentary_name_anchors(clause, lbl, root, level)
140
169
  clause.xpath(ns(SUBCLAUSES))
141
- .each_with_object(clause_counter(0, prefix: num)) do |c, i|
142
- commentary_names1(c, root, i.increment(c).print,
170
+ .each_with_object(clause_counter(0)) do |c, i|
171
+ commentary_names1(c, root, lbl, i.increment(c).print,
143
172
  level + 1)
144
173
  end
145
174
  end
146
175
 
147
176
  def commentary_name_anchors(clause, num, root, level)
148
177
  @anchors[clause["id"]] =
149
- { label: num, xref: l10n("#{@labels['clause']} #{num}"),
178
+ { label: num, xref: labelled_autonum(@labels["clause"], num),
150
179
  container: root,
151
180
  title: clause_title(clause), level: level, type: "clause",
152
181
  elem: @labels["clause"] }
153
182
  end
154
183
 
155
- def list_item_anchor_names(list, list_anchor, depth, prev_label,
184
+ # KILL ?
185
+ def list_item_anchor_namesx(list, list_anchor, depth, prev_label,
156
186
  refer_list)
157
187
  c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {})
158
188
  list.xpath(ns("./li")).each do |li|
@@ -161,10 +191,11 @@ refer_list)
161
191
  { list_anchor: list_anchor,
162
192
  prev_label: prev_label,
163
193
  refer_list: depth == 1 ? refer_list : nil })
164
- li["id"] and @anchors[li["id"]] =
194
+ li["id"] ||= "_#{UUIDTools::UUID.random_create}"
195
+ @anchors[li["id"]] =
165
196
  { label: bare_label,
166
197
  bare_xref: "#{bare_label})",
167
- xref: "#{label})", type: "listitem",
198
+ xref: "#{label}#{list_item_delim}", type: "listitem",
168
199
  refer_list: refer_list,
169
200
  container: list_anchor[:container] }
170
201
  (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
@@ -174,16 +205,23 @@ refer_list)
174
205
  end
175
206
  end
176
207
 
208
+ # KILL
209
+ def list_anchor_names(s)
210
+ super
211
+ #require "debug"; binding.b
212
+ end
213
+
177
214
  def list_item_value(entry, counter, depth, opts)
178
- label1 = counter.increment(entry).listlabel(entry.parent, depth)
179
215
  if depth > 2
180
- base = @c.decode(opts[:prev_label]).split(/\)\s*/) # List a) 1.1.1
181
- label1 = "#{base[-1].sub(/^の/,'')}#{clause_sep}#{label1}"
182
- [label1, list_item_anchor_label(label1, opts[:list_anchor],
183
- base[0].sub(/[\p{Zs})]+$/, ""), opts[:refer_list])]
216
+ # require 'debug'; binding.b
217
+ label = counter.increment(entry).listlabel(entry.parent, depth)
218
+ s = semx(entry, label)
219
+ base = @c.decode(opts[:prev_label].gsub(%r{<[^>]+>}, "")).split(/\)\s*/) # List a) 1.1.1
220
+ label = "#{base[-1].sub(/^の/,'')}#{clausesep}#{label}"
221
+ #[label, J=list_item_anchor_label(opts[:prev_label] + delim_wrap(clause_sep) + s, opts[:list_anchor], base[0].sub(/[\p{Zs})]+$/, ""), opts[:refer_list])]
222
+ [label, opts[:prev_label] + delim_wrap(clausesep) + s]
184
223
  else
185
- [label1, list_item_anchor_label(label1, opts[:list_anchor], opts[:prev_label],
186
- opts[:refer_list])]
224
+ super
187
225
  end
188
226
  end
189
227
  end
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.4.0 -->
20
+ <!-- VERSION v1.4.1 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Jis
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.4.1".freeze
4
4
  end
5
5
  end
6
6
 
@@ -20,7 +20,7 @@ module Relaton
20
20
  r = doc.relation.select { |x| x.type == "hasRepresentation" }
21
21
  .map { |x| @i18n.also_pub_as + render_single_bibitem(x.bibitem) }
22
22
  out = [render_single_bibitem(doc)] + r
23
- @i18n.l10n(out.join(". ").gsub(".. ", ". ").sub(/\.\s*$/, ""))
23
+ @i18n.l10n(out.join(". ").gsub(/[.。]\. /, ". ").sub(/[.。]\s*$/, ""))
24
24
  end
25
25
 
26
26
  def render_all(bib, type: "author-date")
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
32
32
 
33
33
  spec.add_dependency "japanese_calendar", "~> 0"
34
- spec.add_dependency "metanorma-iso", "~> 2.9.0"
34
+ spec.add_dependency "metanorma-iso", "~> 2.9.1"
35
35
  spec.add_dependency "pubid"
36
36
 
37
37
  spec.add_development_dependency "debug"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-jis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-11 00:00:00.000000000 Z
11
+ date: 2024-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: japanese_calendar
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.9.0
33
+ version: 2.9.1
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: 2.9.0
40
+ version: 2.9.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pubid
43
43
  requirement: !ruby/object:Gem::Requirement