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 +4 -4
- data/lib/isodoc/function/cleanup.rb +19 -14
- data/lib/isodoc/html_function/html.rb +0 -2
- data/lib/isodoc/presentation_function/block.rb +8 -0
- data/lib/isodoc/presentation_function/inline.rb +11 -0
- data/lib/isodoc/presentation_function/xrefs.rb +2 -2
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_counter.rb +7 -3
- data/lib/isodoc/xref/xref_gen.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89b2a927f8f452dd13667b90a02e9871472784e620c85978a83d6fd52015902b
|
4
|
+
data.tar.gz: f76d973900f03358f4411a8b479db06544e3d7ecc52971cd0c5afe60334046bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
34
|
-
|
35
|
-
n.
|
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
|
-
|
43
|
-
|
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 <
|
46
|
+
if /^\s*$/.match(text) || (w.size < LONGSTR_THRESHOLD) then w
|
47
47
|
else
|
48
|
-
w.scan(/.{
|
49
|
-
w1.size <
|
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
|
-
|
56
|
-
|
57
|
-
|
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] = "
|
64
|
+
s[-1] = "\u200b#{s[-1]}"
|
60
65
|
s.join
|
61
66
|
end
|
62
67
|
end
|
@@ -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, :
|
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)
|
data/lib/isodoc/version.rb
CHANGED
@@ -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)
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -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 =
|
175
|
-
|
176
|
-
|
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
|
-
{
|
179
|
-
|
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.
|
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-
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html2doc
|