isodoc 3.2.0 → 3.2.2
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 +4 -4
- data/README.adoc +1 -1
- data/isodoc.gemspec +1 -5
- data/lib/isodoc/function/cleanup.rb +3 -3
- data/lib/isodoc/function/setup.rb +1 -0
- data/lib/isodoc/function/table.rb +20 -7
- data/lib/isodoc/function/utils.rb +0 -1
- data/lib/isodoc/html_function/html.rb +4 -1
- data/lib/isodoc/metadata.rb +15 -7
- data/lib/isodoc/metadata_contributor.rb +7 -2
- data/lib/isodoc/presentation_function/autonum.rb +1 -1
- data/lib/isodoc/presentation_function/bibdata.rb +5 -5
- data/lib/isodoc/presentation_function/ids.rb +3 -9
- data/lib/isodoc/presentation_function/list.rb +8 -1
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/table.rb +5 -4
- data/lib/isodoc/xref/xref_gen_seq.rb +5 -6
- metadata +3 -4
- data/lib/nokogiri/xml/node.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1838af1ef3cfa443fb12a42021110e6fbd62939a9de84b341063bde18dd6f095
|
4
|
+
data.tar.gz: aa8889a0f7b2519aee981d9f7e9e244b52dd9c6d8afb9c3232259e74899a64e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 485a2e94c34ee1f1d00a8ea50e04dbb2dd8d1aafee5091478e3dec43b61f0a9585905af7cf1f9ae28db44c9c0427e674a4b2e358bbac89e74a2fc117d6e98f72
|
7
|
+
data.tar.gz: be94db4afe2a26d5afee70e2b9afe48cf091372e3606643914f1705bfece932536d6699e0792a9d9a3df70d1753726d67261e628e8b066436e6371da9bda6c1f
|
data/README.adoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/isodoc.svg["Gem Version", link="https://rubygems.org/gems/isodoc"]
|
4
4
|
image:https://github.com/metanorma/isodoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Arake"]
|
5
|
-
image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
|
5
|
+
// image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
|
6
6
|
image:https://img.shields.io/github/issues-pr-raw/metanorma/isodoc.svg["Pull Requests", link="https://github.com/metanorma/isodoc/pulls"]
|
7
7
|
image:https://img.shields.io/github/commits-since/metanorma/isodoc/latest.svg["Commits since latest",link="https://github.com/metanorma/isodoc/releases"]
|
8
8
|
|
data/isodoc.gemspec
CHANGED
@@ -56,10 +56,6 @@ Gem::Specification.new do |spec|
|
|
56
56
|
spec.add_development_dependency "sassc-embedded", "~> 1"
|
57
57
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
58
58
|
spec.add_development_dependency "timecop", "~> 0.9"
|
59
|
-
spec.add_development_dependency "
|
60
|
-
# html2doc locks lutaml-model to ~ 0.7.0, but until testing of lutaml-model
|
61
|
-
# releases against dowmstream gems (notably Plurimath) is in place, locking at
|
62
|
-
# patch level
|
63
|
-
#spec.add_dependency "lutaml-model", "0.7.1"
|
59
|
+
spec.add_development_dependency "canon"
|
64
60
|
# spec.metadata["rubygems_mfa_required"] = "true"
|
65
61
|
end
|
@@ -105,9 +105,9 @@ module IsoDoc
|
|
105
105
|
table.at(".//tr").xpath("./td | ./th").each do |td|
|
106
106
|
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
107
107
|
end
|
108
|
-
|
109
|
-
|
110
|
-
tfoot.add_child("<tr><td colspan='#{cols}'
|
108
|
+
table["class"].nil? or # = plain table
|
109
|
+
s = "style='border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;'"
|
110
|
+
tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>")
|
111
111
|
tfoot.xpath(".//td").last
|
112
112
|
end
|
113
113
|
|
@@ -40,16 +40,28 @@ module IsoDoc
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def bordered_table_style(node, klass)
|
44
|
+
bordered = "border-width:1px;border-spacing:0;"
|
45
|
+
(node["plain"] != "true" && (%w(modspec).include?(klass) || !klass)) or
|
46
|
+
bordered = ""
|
47
|
+
bordered
|
48
|
+
end
|
49
|
+
|
43
50
|
def table_attrs(node)
|
44
|
-
width = node["width"] ? "width:#{node['width']};" : nil
|
45
51
|
c = node["class"]
|
46
|
-
|
47
|
-
(%w(modspec).include?(c) || !c) or bordered = ""
|
48
|
-
style = node["style"] ? "" : "#{bordered}#{width}"
|
52
|
+
style = table_attrs_style(node, c)
|
49
53
|
attr_code(id: node["id"],
|
50
|
-
class: c || "MsoISOTable",
|
51
|
-
style:
|
52
|
-
|
54
|
+
class: node["plain"] == "true" ? nil : (c || "MsoISOTable"),
|
55
|
+
style: style, title: node["alt"])
|
56
|
+
end
|
57
|
+
|
58
|
+
def table_attrs_style(node, klass)
|
59
|
+
width = node["width"] ? "width:#{node['width']};" : nil
|
60
|
+
bordered = bordered_table_style(node, klass)
|
61
|
+
style = node["style"] ? "" : "#{bordered}#{width}"
|
62
|
+
style += keep_style(node) || ""
|
63
|
+
style.empty? and style = nil
|
64
|
+
style
|
53
65
|
end
|
54
66
|
|
55
67
|
def tcaption(node, table)
|
@@ -125,6 +137,7 @@ module IsoDoc
|
|
125
137
|
end
|
126
138
|
|
127
139
|
def table_bordered?(node)
|
140
|
+
node.parent.parent["plain"] == "true" and return false
|
128
141
|
c = node.parent.parent["class"]
|
129
142
|
%w(modspec).include?(c) || !c
|
130
143
|
end
|
@@ -96,7 +96,10 @@ module IsoDoc
|
|
96
96
|
|
97
97
|
def table_attrs(node)
|
98
98
|
ret = super
|
99
|
-
node.at(ns("./colgroup"))
|
99
|
+
if node.at(ns("./colgroup"))
|
100
|
+
ret[:style] ||= ""
|
101
|
+
ret[:style] += "table-layout:fixed;"
|
102
|
+
end
|
100
103
|
ret
|
101
104
|
end
|
102
105
|
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative "metadata_contributor"
|
|
3
3
|
|
4
4
|
module IsoDoc
|
5
5
|
class Metadata
|
6
|
-
attr_accessor :fonts_options, :labels
|
6
|
+
attr_accessor :fonts_options, :labels, :localdir
|
7
7
|
|
8
8
|
def ns(xpath)
|
9
9
|
Common::ns(xpath)
|
@@ -58,9 +58,8 @@ module IsoDoc
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def docstatus(xml, _out)
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
published_default(xml)
|
62
|
+
s = xml.at(ns("//bibdata/status/stage#{NOLANG}")) or return
|
64
63
|
s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
|
65
64
|
set(:stage, status_print(s.text))
|
66
65
|
s1 and set(:stage_display, status_print(s1.text))
|
@@ -70,10 +69,18 @@ module IsoDoc
|
|
70
69
|
set(:substage_display, i1)
|
71
70
|
(i2 = xml.at(ns("//bibdata/status/iteration"))&.text) and
|
72
71
|
set(:iteration, i2)
|
73
|
-
set(:unpublished, unpublished(s.text))
|
74
72
|
unpublished(s.text) && set(:stageabbr, stage_abbr(s.text))
|
75
73
|
end
|
76
74
|
|
75
|
+
def published_default(xml)
|
76
|
+
override = xml.at(ns("//semantic-metadata/stage-published"))&.text
|
77
|
+
default = override || "true"
|
78
|
+
ret = default == "false"
|
79
|
+
s = xml.at(ns("//bibdata/status/stage#{NOLANG}"))
|
80
|
+
override || !s or ret = unpublished(s.text)
|
81
|
+
set(:unpublished, ret)
|
82
|
+
end
|
83
|
+
|
77
84
|
def stage_abbr(docstatus)
|
78
85
|
status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join
|
79
86
|
end
|
@@ -131,8 +138,7 @@ module IsoDoc
|
|
131
138
|
|
132
139
|
def title(isoxml, _out)
|
133
140
|
main = isoxml.at(ns("//bibdata/title[@language='#{@lang}']"))
|
134
|
-
&.children
|
135
|
-
set(:doctitle, main)
|
141
|
+
&.children and set(:doctitle, to_xml(main))
|
136
142
|
end
|
137
143
|
|
138
144
|
def subtitle(_isoxml, _out)
|
@@ -193,5 +199,7 @@ module IsoDoc
|
|
193
199
|
set(lbl, m << v.text)
|
194
200
|
end
|
195
201
|
end
|
202
|
+
|
203
|
+
include ::IsoDoc::ClassUtils
|
196
204
|
end
|
197
205
|
end
|
@@ -97,11 +97,16 @@ module IsoDoc
|
|
97
97
|
ret
|
98
98
|
end
|
99
99
|
|
100
|
+
def to_datauri(src)
|
101
|
+
/^data:/.match?(src) and return src
|
102
|
+
Vectory::Utils::datauri(src, @localdir)
|
103
|
+
end
|
104
|
+
|
100
105
|
def agency(xml)
|
101
106
|
agency, publisher, logos = agency1(xml)
|
102
107
|
set(:agency, agency)
|
103
108
|
set(:publisher, connectives_strip(@i18n.boolean_conj(publisher, "and")))
|
104
|
-
set(:copublisher_logos, logos)
|
109
|
+
set(:copublisher_logos, logos.map { |l| to_datauri(l) })
|
105
110
|
set(:copublisher_logo_attrs, copublisher_logo_attrs(xml))
|
106
111
|
agency_addr(xml)
|
107
112
|
end
|
@@ -135,7 +140,7 @@ module IsoDoc
|
|
135
140
|
set(k, v)
|
136
141
|
end
|
137
142
|
n = a.at(ns("./address/formattedAddress")) and
|
138
|
-
set(:pub_address, n.children
|
143
|
+
set(:pub_address, to_xml(n.children))
|
139
144
|
end
|
140
145
|
end
|
141
146
|
end
|
@@ -50,12 +50,12 @@ module IsoDoc
|
|
50
50
|
# translate dest_xpath in bibdata using lookup in hash
|
51
51
|
# source text is dest_xpath by default, can be alt_source_xpath if given
|
52
52
|
def hash_translate(bibdata, hash, dest_xpath, alt_source_xpath, lang)
|
53
|
-
x = bibdata.at(ns(dest_xpath)) or return
|
54
|
-
alt_source_xpath and doctype = bibdata.at(ns(alt_source_xpath))
|
55
|
-
doctype ||= x
|
56
53
|
hash.is_a? Hash or return
|
57
|
-
|
58
|
-
|
54
|
+
x = bibdata.xpath(ns(dest_xpath))
|
55
|
+
alt_source_xpath and alt_x = bibdata.at(ns(alt_source_xpath))&.text
|
56
|
+
x.each do |d|
|
57
|
+
v = hash[alt_x || d.text] and tag_translate(d, lang, v)
|
58
|
+
end
|
59
59
|
end
|
60
60
|
|
61
61
|
# does not allow %Spellout and %Ordinal in the ordinal expression
|
@@ -77,7 +77,6 @@ module IsoDoc
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def provide_ids(docxml)
|
80
|
-
@new_ids = {} # guids assigned within Presentation XML
|
81
80
|
anchor_sanitise(docxml)
|
82
81
|
populate_id(docxml)
|
83
82
|
add_missing_id(docxml)
|
@@ -120,10 +119,12 @@ module IsoDoc
|
|
120
119
|
end
|
121
120
|
|
122
121
|
def add_new_contenthash_id(docxml, ids)
|
122
|
+
suffix = "" # for disambiguation in Metanorma Collections
|
123
|
+
docxml["document_suffix"] and suffix = "_#{docxml['document_suffix']}"
|
123
124
|
%w(original-id id).each do |k|
|
124
125
|
docxml.xpath("//*[@#{k}]").each do |x|
|
125
126
|
ids.has_key?(x[k]) or next
|
126
|
-
new_id = contenthash(x)
|
127
|
+
new_id = Metanorma::Utils::contenthash(x) + suffix
|
127
128
|
ids[x[k]] = new_id
|
128
129
|
x[k] = new_id
|
129
130
|
end
|
@@ -134,17 +135,10 @@ module IsoDoc
|
|
134
135
|
Metanorma::Utils::anchor_attributes(presxml: true).each do |e|
|
135
136
|
docxml.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
|
136
137
|
ids.has_key?(x[e[1]]) or next
|
137
|
-
#require "debug"; binding.b unless ids[x[e[1]]]
|
138
138
|
ids[x[e[1]]] or next
|
139
139
|
x[e[1]] = ids[x[e[1]]]
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
144
|
-
# TODO duplicate of standoc
|
145
|
-
def contenthash(elem)
|
146
|
-
Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
|
147
|
-
.sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
|
148
|
-
end
|
149
143
|
end
|
150
144
|
end
|
@@ -62,6 +62,12 @@ module IsoDoc
|
|
62
62
|
%w(—)
|
63
63
|
end
|
64
64
|
|
65
|
+
def ul_label_list_from_metadata(docxml)
|
66
|
+
list = docxml.xpath(ns("//presentation-metadata/ul-label-list"))
|
67
|
+
list.empty? and return nil
|
68
|
+
list.map(&:text)
|
69
|
+
end
|
70
|
+
|
65
71
|
def ul_label(elem)
|
66
72
|
val = ul_label_value(elem)
|
67
73
|
semx = "<semx element='autonum' source='#{elem['id']}'>#{val}</semx>"
|
@@ -71,7 +77,8 @@ module IsoDoc
|
|
71
77
|
|
72
78
|
def ul_label_value(elem)
|
73
79
|
depth = elem.ancestors("ul, ol").size
|
74
|
-
val =
|
80
|
+
val = ul_label_list_from_metadata(elem.document.root) ||
|
81
|
+
ul_label_list(elem)
|
75
82
|
val[(depth - 1) % val.size]
|
76
83
|
end
|
77
84
|
end
|
data/lib/isodoc/version.rb
CHANGED
@@ -15,9 +15,10 @@ module IsoDoc
|
|
15
15
|
table.at(".//tr").xpath("./td | ./th").each do |td|
|
16
16
|
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
17
17
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
table["plain"] == "true" or
|
19
|
+
s = "style='border-top:0pt;mso-border-top-alt:0pt;" \
|
20
|
+
"border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;'"
|
21
|
+
tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>")
|
21
22
|
tfoot.xpath(".//td").last
|
22
23
|
end
|
23
24
|
|
@@ -72,7 +73,7 @@ module IsoDoc
|
|
72
73
|
|
73
74
|
def table_attrs(node)
|
74
75
|
c = node["class"]
|
75
|
-
style = node["style"] ?
|
76
|
+
style = node["style"] || node["plain"] == "true" ? "" : "border-spacing:0;border-width:1px;"
|
76
77
|
(%w(modspec).include?(c) || !c) or style = nil
|
77
78
|
ret =
|
78
79
|
{ summary: node["summary"], width: node["width"],
|
@@ -30,10 +30,9 @@ module IsoDoc
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def sequential_figure_class_names(clause, container: false)
|
33
|
-
c = {}
|
34
33
|
j = 0
|
35
34
|
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
36
|
-
.
|
35
|
+
.each_with_object({}) do |t, c|
|
37
36
|
c[t["class"]] ||= Counter.new
|
38
37
|
# labelled_ancestor(t, %w(figure)) and next
|
39
38
|
j = subfigure_increment(j, c[t["class"]], t)
|
@@ -50,7 +49,7 @@ module IsoDoc
|
|
50
49
|
|
51
50
|
def figure_anchor(elem, sublabel, label, klass, container: false)
|
52
51
|
if sublabel
|
53
|
-
|
52
|
+
label&.include?("<semx") or label = semx(elem.parent, label)
|
54
53
|
subfigure_anchor(elem, sublabel, label, klass, container: false)
|
55
54
|
else
|
56
55
|
@anchors[elem["id"]] = anchor_struct(
|
@@ -185,9 +184,8 @@ container: false)
|
|
185
184
|
end
|
186
185
|
|
187
186
|
def hierarchical_figure_class_names(clauses, num)
|
188
|
-
c = {}
|
189
187
|
j = 0
|
190
|
-
nodeSet(clauses).
|
188
|
+
nodeSet(clauses).each_with_object({}) do |clause, c|
|
191
189
|
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
192
190
|
.noblank.each do |t|
|
193
191
|
# labelled_ancestor(t, %w(figure)) and next
|
@@ -207,7 +205,8 @@ container: false)
|
|
207
205
|
# labelled_ancestor(t) and next
|
208
206
|
@anchors[t["id"]] =
|
209
207
|
anchor_struct(hiersemx(clause, num, c.increment(t), t),
|
210
|
-
t, @labels["table"], "table",
|
208
|
+
t, @labels["table"], "table",
|
209
|
+
{ unnumb: t["unnumbered"], container: false })
|
211
210
|
end
|
212
211
|
end
|
213
212
|
end
|
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: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -333,7 +333,7 @@ dependencies:
|
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: '0.9'
|
335
335
|
- !ruby/object:Gem::Dependency
|
336
|
-
name:
|
336
|
+
name: canon
|
337
337
|
requirement: !ruby/object:Gem::Requirement
|
338
338
|
requirements:
|
339
339
|
- - ">="
|
@@ -488,7 +488,6 @@ files:
|
|
488
488
|
- lib/metanorma/output/base.rb
|
489
489
|
- lib/metanorma/output/utils.rb
|
490
490
|
- lib/metanorma/output/xslfo.rb
|
491
|
-
- lib/nokogiri/xml/node.rb
|
492
491
|
- lib/relaton/render-isodoc/config.yml
|
493
492
|
- lib/relaton/render-isodoc/general.rb
|
494
493
|
homepage: https://github.com/metanorma/isodoc
|