metanorma-jis 0.3.7 → 0.4.1

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.
@@ -54,7 +54,7 @@ module IsoDoc
54
54
  isoxml.xpath(ns("//bibdata/date")).each do |d|
55
55
  val = Common::date_range(d)
56
56
  @lang == "ja" and val = @i18n.japanese_date(val)
57
- set("#{d['type'].gsub(/-/, '_')}date".to_sym, val)
57
+ set("#{d['type'].tr('-', '_')}date".to_sym, val)
58
58
  end
59
59
  end
60
60
 
@@ -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)
@@ -65,7 +66,7 @@ module IsoDoc
65
66
  dest = doc.at(ns("//sections")) ||
66
67
  doc.at(ns("//preface")).after("<sections> </sections>").next_element
67
68
  dest.children.empty? and dest.children = " "
68
- dest.children.first.next = source
69
+ dest.add_first_child source
69
70
  end
70
71
 
71
72
  def move_participants(doc)
@@ -73,7 +74,7 @@ module IsoDoc
73
74
  t = participant_table(p) or return
74
75
  p.remove
75
76
  ins = make_preface(doc) or return nil
76
- ins.children.first.previous = t
77
+ ins.add_first_child t
77
78
  end
78
79
 
79
80
  def participant_table(clause)
@@ -45,12 +45,8 @@ module IsoDoc
45
45
  elem.children.first.previous = @i18n.l10n("#{@i18n.admitted}: ")
46
46
  end
47
47
 
48
- def block(docxml)
49
- super
50
- dl docxml
51
- end
52
-
53
48
  def dl(docxml)
49
+ super
54
50
  docxml.xpath(ns("//table//dl | //figure//dl")).each do |l|
55
51
  l.at(ns("./dl")) || l.at("./ancestor::xmlns:dl") and next
56
52
  dl_to_para(l)
@@ -64,7 +60,8 @@ module IsoDoc
64
60
  def dl_to_para(node)
65
61
  ret = dl_to_para_name(node)
66
62
  ret += dl_to_para_terms(node)
67
- 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|
68
65
  ret += x.to_xml
69
66
  end
70
67
  dl_id_insert(node, ret)
@@ -78,7 +75,7 @@ module IsoDoc
78
75
  end
79
76
 
80
77
  def dl_to_para_name(node)
81
- e = node.at(ns("./name")) or return ""
78
+ e = node.at(ns("./fmt-name")) or return ""
82
79
  "<p class='ListTitle'>#{e.children.to_xml}</p>"
83
80
  end
84
81
 
@@ -100,8 +97,9 @@ module IsoDoc
100
97
  def table1(node)
101
98
  super
102
99
  cols = table_cols_count(node)
103
- name = node.at(ns("./name"))
104
- 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)
105
103
  table_unit_note(node, thead, cols)
106
104
  end
107
105
 
@@ -135,6 +133,10 @@ module IsoDoc
135
133
  elem.children = l10n("#{@i18n.source}: #{to_xml(elem.children).strip}")
136
134
  end
137
135
 
136
+ def table_fn1(_table, fnote, _idx)
137
+ fnote["reference"] += ")"
138
+ end
139
+
138
140
  def bibdata_i18n(bibdata)
139
141
  super
140
142
  @lang == "ja" and date_translate(bibdata)
@@ -182,6 +184,18 @@ module IsoDoc
182
184
  a << ret
183
185
  end
184
186
 
187
+ def figure_fn(elem)
188
+ (elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn")))
189
+ .each do |f|
190
+ table_fn1(elem, f, nil)
191
+ end
192
+ end
193
+
194
+ def omit_docid_prefix(prefix)
195
+ prefix.nil? || prefix.empty? and return true
196
+ super || %w(JIS).include?(prefix)
197
+ end
198
+
185
199
  include Init
186
200
  end
187
201
  end
@@ -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
@@ -29,7 +29,7 @@ module IsoDoc
29
29
  def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
30
30
  top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
31
31
  bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
32
- ret = <<~STYLE.gsub(/\n/, "")
32
+ ret = <<~STYLE.delete("\n")
33
33
  border-top:#{top}mso-border-top-alt:#{top}
34
34
  border-left:#{bottom}mso-border-top-alt:#{bottom}
35
35
  border-right:#{bottom}mso-border-top-alt:#{bottom}
@@ -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
@@ -1783,9 +1783,21 @@ that the `number` given for the series applies to the second iteration of number
1783
1783
  May be used to differentiate rendering of notes in bibliographies</a:documentation>
1784
1784
  </attribute>
1785
1785
  </optional>
1786
- <ref name="LocalizedMarkedUpString">
1786
+ <ref name="LocalizedStringAttributes">
1787
1787
  <a:documentation>The content of the note</a:documentation>
1788
1788
  </ref>
1789
+ <choice>
1790
+ <oneOrMore>
1791
+ <ref name="BasicBlockNoId">
1792
+ <a:documentation>Multiple blocks of content</a:documentation>
1793
+ </ref>
1794
+ </oneOrMore>
1795
+ <oneOrMore>
1796
+ <ref name="TextElement">
1797
+ <a:documentation>Single block of content</a:documentation>
1798
+ </ref>
1799
+ </oneOrMore>
1800
+ </choice>
1789
1801
  </element>
1790
1802
  </define>
1791
1803
  <define name="bibabstract">
@@ -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.3.4 -->
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">
@@ -326,7 +326,7 @@ normative or informative references, some split references into sections organiz
326
326
  <a:documentation>Content of note</a:documentation>
327
327
  <oneOrMore>
328
328
  <choice>
329
- <ref name="paragraph"/>
329
+ <ref name="paragraph-with-footnote"/>
330
330
  <ref name="ul"/>
331
331
  <ref name="ol"/>
332
332
  <ref name="dl"/>
@@ -412,7 +412,7 @@ normative or informative references, some split references into sections organiz
412
412
  <element name="note">
413
413
  <ref name="OptionalId"/>
414
414
  <oneOrMore>
415
- <ref name="paragraph"/>
415
+ <ref name="paragraph-with-footnote"/>
416
416
  </oneOrMore>
417
417
  </element>
418
418
  </define>
@@ -1977,7 +1977,7 @@ used in document amendments</a:documentation>
1977
1977
  <oneOrMore>
1978
1978
  <choice>
1979
1979
  <a:documentation>Content of the verbal representation of the term</a:documentation>
1980
- <ref name="paragraph"/>
1980
+ <ref name="paragraph-with-footnote"/>
1981
1981
  <ref name="dl"/>
1982
1982
  <ref name="ol"/>
1983
1983
  <ref name="ul"/>
@@ -2015,7 +2015,7 @@ used in document amendments</a:documentation>
2015
2015
  <oneOrMore>
2016
2016
  <choice>
2017
2017
  <a:documentation>Content of the term note</a:documentation>
2018
- <ref name="paragraph"/>
2018
+ <ref name="paragraph-with-footnote"/>
2019
2019
  <ref name="ul"/>
2020
2020
  <ref name="ol"/>
2021
2021
  <ref name="dl"/>
@@ -2037,7 +2037,7 @@ used in document amendments</a:documentation>
2037
2037
  <ref name="dl"/>
2038
2038
  <ref name="quote"/>
2039
2039
  <ref name="sourcecode"/>
2040
- <ref name="paragraph"/>
2040
+ <ref name="paragraph-with-footnote"/>
2041
2041
  <ref name="figure"/>
2042
2042
  </choice>
2043
2043
  </oneOrMore>
@@ -27,7 +27,6 @@ module Metanorma
27
27
  "Noto Serif JP" => nil,
28
28
  "Noto Serif JP ExtraLight" => nil,
29
29
  "Noto Serif JP Medium" => nil,
30
- "Noto Serif JP Bold" => nil,
31
30
  "Noto Serif JP Black" => nil,
32
31
  "Noto Sans JP Thin" => nil,
33
32
  "Noto Sans JP Medium" => nil,
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Jis
3
- VERSION = "0.3.7".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.8.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.3.7
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-10-28 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.8.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.8.0
40
+ version: 2.9.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pubid
43
43
  requirement: !ruby/object:Gem::Requirement