isodoc 2.5.5 → 2.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6ca47f20afd4ccef8c44ce28bfca11c4803f9aa8988e950cf1842dc251dc855
4
- data.tar.gz: 9f2ca8a82bb0528e05f8a6cc631cfad987c0fe8d819937af79580a119955a921
3
+ metadata.gz: 89b2a927f8f452dd13667b90a02e9871472784e620c85978a83d6fd52015902b
4
+ data.tar.gz: f76d973900f03358f4411a8b479db06544e3d7ecc52971cd0c5afe60334046bd
5
5
  SHA512:
6
- metadata.gz: 10170334bf2d0bbf492237695054a1a164c8c7f056a8cec5d782cd468f4a367524fc9dc841fccf4c3f7c90038af32d83e962d5cf224d66e5f7d05323b1b65083
7
- data.tar.gz: 9fc62b5c28d0baff4b369f15f8811a6be8b0bd85e1b63db6a9b36017e9a84a276c9df3034c679c0bd11ecbca0d5f7056bd2aa1627873a561be29b67f5619db9a
6
+ metadata.gz: aecc80230f4d1cde0232702931d07290c340f98c3a5e93a81603fed8c7775a1fca6dbf29cf09aa8141aece7fa3befb6d583c70690cf2cda02fcf50ce5bf75848
7
+ data.tar.gz: fc2d6d6fa85a1dc0edf1735068b940084b21fe20442158bc18307e9ae77581875dbf2b66be5cc4847bd2eb1096063b959c9df9695d356963e879c9c83e6a9e3b
@@ -30,33 +30,38 @@ module IsoDoc
30
30
 
31
31
  docxml.xpath("//td | //th").each do |d|
32
32
  d.traverse do |n|
33
- next unless n.text?
34
-
35
- n.replace(HTMLEntities.new.encode(
36
- break_up_long_strings(n.text),
37
- ))
33
+ n.text? or next
34
+ ret = break_up_long_str(n.text)
35
+ n.content = ret
38
36
  end
39
37
  end
40
38
  end
41
39
 
42
- def break_up_long_strings(text)
43
- return text if /^\s*$/.match?(text)
40
+ LONGSTR_THRESHOLD = 10
41
+ LONGSTR_NOPUNCT = 2
44
42
 
43
+ def break_up_long_str(text)
44
+ /^\s*$/.match?(text) and return text
45
45
  text.split(/(?=\s)/).map do |w|
46
- if /^\s*$/.match(text) || (w.size < 30) then w
46
+ if /^\s*$/.match(text) || (w.size < LONGSTR_THRESHOLD) then w
47
47
  else
48
- w.scan(/.{,30}/).map do |w1|
49
- w1.size < 30 ? w1 : break_up_long_strings1(w1)
48
+ w.scan(/.{,#{LONGSTR_THRESHOLD}}/o).map.with_index do |w1, i|
49
+ w1.size < LONGSTR_THRESHOLD ? w1 : break_up_long_str1(w1, i + 1)
50
50
  end.join
51
51
  end
52
52
  end.join
53
53
  end
54
54
 
55
- def break_up_long_strings1(text)
56
- s = text.split(%r{(?<=[,.?+;/=])})
57
- if s.size == 1 then "#{text} "
55
+ # break on punct every LONGSTRING_THRESHOLD chars
56
+ # break regardless every LONGSTRING_THRESHOLD * LONGSTR_NOPUNCT
57
+ def break_up_long_str1(text, iteration)
58
+ s = text.split(%r{(?<=[,.?+;/=(\[])})
59
+ if s.size == 1
60
+ (iteration % LONGSTR_NOPUNCT).zero? and
61
+ text += "\u200b"
62
+ text
58
63
  else
59
- s[-1] = " #{s[-1]}"
64
+ s[-1] = "\u200b#{s[-1]}"
60
65
  s.join
61
66
  end
62
67
  end
@@ -102,8 +102,6 @@ module IsoDoc
102
102
  end
103
103
  end
104
104
 
105
- def table_long_strings_cleanup(docxml); end
106
-
107
105
  def table_attrs(node)
108
106
  ret = super
109
107
  node.at(ns("./colgroup")) and ret[:style] += "table-layout:fixed;"
@@ -140,6 +140,7 @@ module IsoDoc
140
140
  def ol(docxml)
141
141
  docxml.xpath(ns("//ol")).each { |f| ol1(f) }
142
142
  @xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
143
+ docxml.xpath(ns("//ol/li")).each { |f| ol_label(f) }
143
144
  end
144
145
 
145
146
  # We don't really want users to specify type of ordered list;
@@ -157,6 +158,13 @@ module IsoDoc
157
158
 
158
159
  def ol1(elem)
159
160
  elem["type"] ||= ol_depth(elem).to_s
161
+ elem.xpath(ns("./li")).each do |li|
162
+ li["id"] ||= "_#{UUIDTools::UUID.random_create}"
163
+ end
164
+ end
165
+
166
+ def ol_label(elem)
167
+ elem["label"] = @xrefs.anchor(elem["id"], :label, false)
160
168
  end
161
169
 
162
170
  def requirement_render_preprocessing(docxml); end
@@ -89,6 +89,17 @@ module IsoDoc
89
89
  end
90
90
  end
91
91
 
92
+ def date(docxml)
93
+ (docxml.xpath(ns("//date")) -
94
+ docxml.xpath(ns("//bibdata/date | //bibitem//date"))).each do |d|
95
+ date1(d)
96
+ end
97
+ end
98
+
99
+ def date1(elem)
100
+ elem.replace(@i18n.date(elem["value"], elem["format"].strip))
101
+ end
102
+
92
103
  private
93
104
 
94
105
  def found_matching_variant_sibling(node)
@@ -6,8 +6,8 @@ module IsoDoc
6
6
  end
7
7
 
8
8
  def anchor_value(id)
9
- @xrefs.anchor(id, :value) || @xrefs.anchor(id, :label) ||
10
- @xrefs.anchor(id, :xref)
9
+ @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :value) ||
10
+ @xrefs.anchor(id, :label) || @xrefs.anchor(id, :xref)
11
11
  end
12
12
 
13
13
  def anchor_linkend(node, linkend)
@@ -85,6 +85,7 @@ module IsoDoc
85
85
  mathml docxml
86
86
  variant docxml
87
87
  identifier docxml
88
+ date docxml
88
89
  end
89
90
 
90
91
  def terms(docxml)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.5.5".freeze
2
+ VERSION = "2.5.7".freeze
3
3
  end
@@ -107,6 +107,13 @@ module IsoDoc
107
107
  end
108
108
 
109
109
  def increment_letter
110
+ clock_letter
111
+ @letter = (@letter.ord + 1).chr.to_s
112
+ @skip_i && %w(i I).include?(@letter) and
113
+ @letter = (@letter.ord + 1).chr.to_s
114
+ end
115
+
116
+ def clock_letter
110
117
  case @letter
111
118
  when "Z"
112
119
  @letter = "@"
@@ -115,9 +122,6 @@ module IsoDoc
115
122
  @letter = "`"
116
123
  @base = string_inc(@base, "a")
117
124
  end
118
- @letter = (@letter.ord + 1).chr.to_s
119
- @skip_i && %w(i I).include?(@letter) and
120
- @letter = (@letter.ord + 1).chr.to_s
121
125
  end
122
126
 
123
127
  def blank?(str)
@@ -171,18 +171,27 @@ module IsoDoc
171
171
  refer_list)
172
172
  c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
173
173
  list.xpath(ns("./li")).each do |li|
174
- label = c.increment(li).listlabel(list, depth)
175
- label = list_item_anchor_label(label, list_anchor, prev_label,
176
- refer_list)
174
+ bare_label, label =
175
+ list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label,
176
+ refer_list: refer_list })
177
177
  li["id"] and @anchors[li["id"]] =
178
- { xref: "#{label})", type: "listitem", refer_list:
179
- refer_list, container: list_anchor[:container] }
178
+ { label: bare_label, bare_xref: "#{label})",
179
+ xref: "#{label})",
180
+ type: "listitem", refer_list: refer_list,
181
+ container: list_anchor[:container] }
180
182
  (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
181
183
  list_item_anchor_names(ol, list_anchor, depth + 1, label, false)
182
184
  end
183
185
  end
184
186
  end
185
187
 
188
+ def list_item_value(entry, counter, depth, opts)
189
+ label = counter.increment(entry).listlabel(entry.parent, depth)
190
+ [label,
191
+ list_item_anchor_label(label, opts[:list_anchor], opts[:prev_label],
192
+ opts[:refer_list])]
193
+ end
194
+
186
195
  def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
187
196
  prev_label.empty? or
188
197
  label = @i18n.list_nested_xref.sub(/%1/, "#{prev_label})")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.5
4
+ version: 2.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-22 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc