isodoc 3.1.2 → 3.1.3

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: aa02186be0f73d998dca870f3559df00184697cc3582ef302eb934e4901d1ab1
4
- data.tar.gz: 54cf027ca0fcab8ec1c97b35d7ada8ec7137a32a2adeecfa2c0cb9b653b3b0f2
3
+ metadata.gz: 0cc231c707c79c5af17d4a07818b64395a13328377f6ab4521e2cdfe1ad8c884
4
+ data.tar.gz: 1b6a810aae9f30c35eeea2f59daddc10d62d63cfd3efd3a0c0813c1c6a7b8bf0
5
5
  SHA512:
6
- metadata.gz: 251471002a6b16dd050364344f6a63e99b0e3b266a0dcc65cb4f83382b5ebfece49cc75ea65229282ef61a7206fb1ac4d7aba441b86b19704c6d9d00398ce3f2
7
- data.tar.gz: 5fde838af0af79d78ccc4fecd730bc64cc60e6afaf68691f5e046d18ada04df54a922b61d98b22632a9395e21caa4c0cbbafceea70c729da839f9b732beb54c9
6
+ metadata.gz: 4403a6d48af622fc31f0829683d4c11d2c76226a15f877deb449eaf8fcdf37e9b7fe55b25225ac1889fc2d3a15eda554d568efb9a988def3fe7bdc3e4d1632fc
7
+ data.tar.gz: 3365c6b7317a602ea24bf62d3ccc73cadd8ac3b872735945388172f029c0b02460e8f2337f95a192b786057ea69045acc4917a7454c4145bb670777da770ce9e
@@ -52,8 +52,8 @@ module IsoDoc
52
52
  end
53
53
 
54
54
  def clause_title_depth(node, title)
55
- depth = node.ancestors(sections_names.join(", ")).size + 1
56
55
  depth = title["depth"] if title && title["depth"]
56
+ depth = node.ancestors(sections_names.join(", ")).size + 1 unless depth
57
57
  depth
58
58
  end
59
59
 
@@ -70,14 +70,15 @@ module IsoDoc
70
70
 
71
71
  # do not change to Presentation XML rendering
72
72
  def sem_xml_descendant?(node)
73
- !node.ancestors("preferred, admitted, deprecated, related, " \
74
- "definition, termsource").empty? and return true
75
- !node.ancestors("xref, eref, origin, link").empty? and return true
76
- !node.ancestors("name, title").empty? and return true
77
- node.ancestors("bibitem") &&
78
- !node.ancestors("formattedref, biblio-tag") and return true
79
- !node.ancestors("requirement, recommendation, permission").empty? &&
80
- node.ancestors("fmt-provision").empty? and return true
73
+ ancestor_names = node.ancestors.map(&:name)
74
+
75
+ return true if %w[preferred admitted deprecated related definition termsource].any? { |name| ancestor_names.include?(name) }
76
+ return true if %w[xref eref origin link name title].any? { |name| ancestor_names.include?(name) }
77
+ return true if ancestor_names.include?("bibitem") &&
78
+ !%w[formattedref biblio-tag].any? { |name| ancestor_names.include?(name) }
79
+ return true if (ancestor_names & %w[requirement recommendation permission]).any? &&
80
+ !ancestor_names.include?("fmt-provision")
81
+
81
82
  false
82
83
  end
83
84
 
@@ -15,11 +15,25 @@ module IsoDoc
15
15
  end
16
16
 
17
17
  def unnumbered_clause?(elem)
18
- !elem.ancestors("boilerplate, metanorma-extension").empty? ||
18
+ numbered_clause_invalid_context?(elem) ||
19
19
  @suppressheadingnumbers || elem["unnumbered"] ||
20
20
  elem.at("./ancestor::*[@unnumbered = 'true']")
21
21
  end
22
22
 
23
+ # context in which clause numbering is invalid:
24
+ # metanorma-extension, boilerplate
25
+ def numbered_clause_invalid_context?(elem)
26
+ @ncic_cache ||= {}
27
+ elem or return false
28
+ @ncic_cache.key?(elem) and return @ncic_cache[elem]
29
+ if ["metanorma-extension", "boilerplate"].include?(elem.name)
30
+ @ncic_cache[elem] = true
31
+ else
32
+ elem.respond_to?(:parent) or return false
33
+ @ncic_cache[elem] = numbered_clause_invalid_context?(elem.parent)
34
+ end
35
+ end
36
+
23
37
  def clausedelim
24
38
  ret = super
25
39
  ret && !ret.empty? or return ret
@@ -29,8 +43,9 @@ module IsoDoc
29
43
  def clause1(elem)
30
44
  level = @xrefs.anchor(elem["id"], :level, false) ||
31
45
  (elem.ancestors("clause, annex").size + 1)
32
- lbl = @xrefs.anchor(elem["id"], :label, !unnumbered_clause?(elem))
33
- if unnumbered_clause?(elem) || !lbl
46
+ is_unnumbered = unnumbered_clause?(elem)
47
+ lbl = @xrefs.anchor(elem["id"], :label, !is_unnumbered)
48
+ if is_unnumbered || !lbl
34
49
  prefix_name(elem, {}, nil, "title")
35
50
  else
36
51
  prefix_name(elem, { caption: "<tab/>" }, "#{lbl}#{clausedelim}",
@@ -132,10 +147,10 @@ module IsoDoc
132
147
  clauses.empty? and return
133
148
  preface = clauses.first.parent
134
149
  clauses.each do |clause|
135
- float = preceding_floats(clause)
136
- xpath = after.map { |n| "./self::xmlns:#{n}" }.join(" | ")
137
- xpath.empty? and xpath = "./self::*[not(following-sibling::*)]"
138
- preface_move1(clause, preface, float, nil, xpath)
150
+ float = preceding_floats(clause)
151
+ xpath = after.map { |n| "./self::xmlns:#{n}" }.join(" | ")
152
+ xpath.empty? and xpath = "./self::*[not(following-sibling::*)]"
153
+ preface_move1(clause, preface, float, nil, xpath)
139
154
  end
140
155
  end
141
156
 
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.1.2".freeze
2
+ VERSION = "3.1.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.