isodoc 3.2.3 → 3.2.5
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/lib/isodoc/function/footnotes.rb +1 -2
- data/lib/isodoc/function/setup.rb +1 -1
- data/lib/isodoc/metadata.rb +5 -5
- data/lib/isodoc/metadata_contributor.rb +5 -5
- data/lib/isodoc/presentation_function/docid.rb +8 -2
- data/lib/isodoc/presentation_function/footnotes.rb +11 -5
- data/lib/isodoc/presentation_function/refs.rb +2 -2
- data/lib/isodoc/presentation_xml_convert.rb +2 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +18 -0
- data/lib/isodoc/word_function/postprocess_toc.rb +4 -6
- data/lib/isodoc/xslfo_convert.rb +9 -2
- 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: c9fdc30bd68584b0e694c4ebc052d9d5c9377ff0b97d470bf9a71b422cc4c01d
|
4
|
+
data.tar.gz: 6eb37637765b514734b06b12beaee5769884636b9163844d6bfd8396e4beff49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8368550186c0826ce9f4cf4634b2c00970622eae12ed79582e8ef4002d88349e019a2a641877acf51747513f57d97a3d5bcf98695c5f58f638bec986b73331d
|
7
|
+
data.tar.gz: c57d4d8f9a1c32fdef6f3828ee5b11d798de609e80cb72f0eec89a980235d28e5dbabd64431a9c683bbd430f406ddee169547c1af4dfe4bf15c2cfdbfa490d52
|
@@ -38,8 +38,7 @@ module IsoDoc
|
|
38
38
|
fnbody.xpath(ns(".//fmt-fn-label")).each do |s|
|
39
39
|
s["class"] = "TableFootnoteRef"
|
40
40
|
s.name = "span"
|
41
|
-
d = s.at(ns("./span[@class = 'fmt-caption-delim']")) and
|
42
|
-
s.next = d
|
41
|
+
d = s.at(ns("./span[@class = 'fmt-caption-delim']")) and s.next = d
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
@@ -14,7 +14,7 @@ module IsoDoc
|
|
14
14
|
dir = init_dir(filename, debug)
|
15
15
|
@filename = filename
|
16
16
|
@output_dir = File.dirname(filename)
|
17
|
-
@localdir =
|
17
|
+
@localdir = "#{@baseassetpath || filepath.parent.to_s}/"
|
18
18
|
@sourcedir = @localdir
|
19
19
|
@sourcefilename and
|
20
20
|
@sourcedir = "#{Pathname.new(@sourcefilename).parent}/"
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -58,7 +58,7 @@ module IsoDoc
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def docstatus(xml, _out)
|
61
|
-
published_default(xml)
|
61
|
+
published = published_default(xml)
|
62
62
|
s = xml.at(ns("//bibdata/status/stage#{NOLANG}")) or return
|
63
63
|
s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
|
64
64
|
set(:stage, status_print(s.text))
|
@@ -69,23 +69,23 @@ module IsoDoc
|
|
69
69
|
set(:substage_display, i1)
|
70
70
|
(i2 = xml.at(ns("//bibdata/status/iteration"))&.text) and
|
71
71
|
set(:iteration, i2)
|
72
|
-
|
72
|
+
!published && set(:stageabbr, stage_abbr(s.text))
|
73
73
|
end
|
74
74
|
|
75
75
|
def published_default(xml)
|
76
76
|
override = xml.at(ns("//semantic-metadata/stage-published"))&.text
|
77
77
|
default = override || "true"
|
78
78
|
ret = default == "false"
|
79
|
-
s = xml.at(ns("//bibdata/status/stage#{NOLANG}"))
|
80
|
-
override || !s or ret = unpublished(s.text)
|
81
79
|
set(:unpublished, ret)
|
80
|
+
default == "true"
|
82
81
|
end
|
83
82
|
|
84
83
|
def stage_abbr(docstatus)
|
85
84
|
status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join
|
86
85
|
end
|
87
86
|
|
88
|
-
|
87
|
+
# KILL
|
88
|
+
def unpublishedx(status)
|
89
89
|
!status.casecmp("published").zero?
|
90
90
|
end
|
91
91
|
|
@@ -107,14 +107,14 @@ module IsoDoc
|
|
107
107
|
set(:agency, agency)
|
108
108
|
set(:publisher, connectives_strip(@i18n.boolean_conj(publisher, "and")))
|
109
109
|
set(:copublisher_logos, logos.map { |l| to_datauri(l) })
|
110
|
-
set(:copublisher_logo_attrs,
|
110
|
+
set(:copublisher_logo_attrs, contrib_logo_attrs(xml, "publisher"))
|
111
111
|
agency_addr(xml)
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
114
|
+
def contrib_logo_attrs(xml, role)
|
115
115
|
xml.xpath(ns("//metanorma-extension/presentation-metadata/*"))
|
116
116
|
.each_with_object([]) do |x, m|
|
117
|
-
|
117
|
+
contrib_logo_attr?(x, role) or next
|
118
118
|
p = x.name.split(/[_-]/)
|
119
119
|
idx = (p[4] || "1").to_i - 1
|
120
120
|
m[idx] ||= {}
|
@@ -123,8 +123,8 @@ module IsoDoc
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
def
|
127
|
-
elem.name.start_with?("logo-
|
126
|
+
def contrib_logo_attr?(elem, role)
|
127
|
+
elem.name.start_with?("logo-#{role}-") or return false
|
128
128
|
p = elem.name.split(/[_-]/)
|
129
129
|
%w(doc html).include?(p[2]) &&
|
130
130
|
%w(height width).include?(p[3]) &&
|
@@ -49,16 +49,22 @@ module IsoDoc
|
|
49
49
|
id
|
50
50
|
end
|
51
51
|
|
52
|
+
def xml_to_string_skip_fn(node)
|
53
|
+
node1 = node.dup
|
54
|
+
node1.xpath(ns(".//fn")).each(&:remove)
|
55
|
+
to_xml(node1.children)
|
56
|
+
end
|
57
|
+
|
52
58
|
def bracket_if_num(num)
|
53
59
|
num.nil? and return nil
|
54
|
-
num =
|
60
|
+
num = xml_to_string_skip_fn(num).sub(/^\[/, "").sub(/\]$/, "")
|
55
61
|
/^\d+$/.match?(num) and return "[#{num}]"
|
56
62
|
num
|
57
63
|
end
|
58
64
|
|
59
65
|
def unbracket1(ident)
|
60
66
|
ident.nil? and return nil
|
61
|
-
ident.is_a?(String) or ident =
|
67
|
+
ident.is_a?(String) or ident = xml_to_string_skip_fn(ident)
|
62
68
|
ident.sub(/^\[/, "").sub(/\]$/, "")
|
63
69
|
end
|
64
70
|
|
@@ -55,7 +55,8 @@ module IsoDoc
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def table_fn(elem)
|
58
|
-
fnotes = elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn"))
|
58
|
+
fnotes = elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn")) -
|
59
|
+
elem.xpath(ns("./fmt-name//fn"))
|
59
60
|
ret = footnote_collect(fnotes)
|
60
61
|
f = footnote_container(fnotes, ret) and elem << f
|
61
62
|
end
|
@@ -80,9 +81,11 @@ module IsoDoc
|
|
80
81
|
|
81
82
|
def non_document_footnotes(docxml)
|
82
83
|
table_fns = docxml.xpath(ns("//table//fn")) -
|
83
|
-
docxml.xpath(ns("//table/name//fn"))
|
84
|
+
docxml.xpath(ns("//table/name//fn")) -
|
85
|
+
docxml.xpath(ns("//table/fmt-name//fn"))
|
84
86
|
fig_fns = docxml.xpath(ns("//figure//fn")) -
|
85
|
-
docxml.xpath(ns("//figure/name//fn"))
|
87
|
+
docxml.xpath(ns("//figure/name//fn")) -
|
88
|
+
docxml.xpath(ns("//figure/fmt-name//fn"))
|
86
89
|
table_fns + fig_fns
|
87
90
|
end
|
88
91
|
|
@@ -117,7 +120,8 @@ module IsoDoc
|
|
117
120
|
|
118
121
|
# move footnotes into key
|
119
122
|
def figure_fn(elem)
|
120
|
-
fn = elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn"))
|
123
|
+
fn = elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn")) -
|
124
|
+
elem.xpath(ns("./fmt-name//fn"))
|
121
125
|
fn.empty? and return
|
122
126
|
dl = figure_key_insert_pt(elem)
|
123
127
|
footnote_collect(fn).each do |f|
|
@@ -169,8 +173,10 @@ module IsoDoc
|
|
169
173
|
end
|
170
174
|
|
171
175
|
# Do not insert a comment bookmark inside another comment bookmark
|
176
|
+
# Also avoid list labels, which are typically not rendered downstream
|
177
|
+
# as selectable text
|
172
178
|
AVOID_COMMENT_BOOKMARKS = <<~XPATH.freeze
|
173
|
-
[not(ancestor::xmlns:fmt-annotation-start)][not(ancestor::xmlns:fmt-annotation-end)]
|
179
|
+
[not(ancestor::xmlns:fmt-annotation-start)][not(ancestor::xmlns:fmt-annotation-end)][not(ancestor::xmlns:fmt-name[parent::xmlns:li])]
|
174
180
|
XPATH
|
175
181
|
|
176
182
|
def comment_bookmarks_locate(elem)
|
@@ -4,9 +4,9 @@ module IsoDoc
|
|
4
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
5
5
|
def references(docxml)
|
6
6
|
bibliography_bibitem_number(docxml)
|
7
|
-
|
7
|
+
@ref_renderings = references_render(docxml)
|
8
8
|
docxml.xpath(ns("//references/bibitem")).each do |x|
|
9
|
-
bibitem(x,
|
9
|
+
bibitem(x, @ref_renderings)
|
10
10
|
reference_name(x)
|
11
11
|
end
|
12
12
|
hidden_items(docxml)
|
@@ -86,8 +86,6 @@ module IsoDoc
|
|
86
86
|
index docxml # fed by strip_duplicate_ids
|
87
87
|
toc docxml
|
88
88
|
display_order docxml # feeds document_footnotes
|
89
|
-
document_footnotes docxml
|
90
|
-
comments docxml
|
91
89
|
end
|
92
90
|
|
93
91
|
def block(docxml)
|
@@ -111,6 +109,8 @@ module IsoDoc
|
|
111
109
|
end
|
112
110
|
|
113
111
|
def inline(docxml)
|
112
|
+
document_footnotes docxml
|
113
|
+
comments docxml
|
114
114
|
bibitem_lookup(docxml) # feeds citeas
|
115
115
|
fmt_ref docxml # feeds citeas, xref, eref, origin, concept
|
116
116
|
citeas docxml # feeds xref, eref, origin, concept
|
data/lib/isodoc/version.rb
CHANGED
@@ -63,6 +63,7 @@ module IsoDoc
|
|
63
63
|
word_floating_titles(docxml)
|
64
64
|
word_section_breaks(docxml)
|
65
65
|
word_tab_clean(docxml)
|
66
|
+
word_fn_cleanup(docxml)
|
66
67
|
authority_cleanup(docxml)
|
67
68
|
word_remove_empty_toc(docxml)
|
68
69
|
word_remove_empty_sections(docxml)
|
@@ -197,6 +198,23 @@ module IsoDoc
|
|
197
198
|
end
|
198
199
|
end
|
199
200
|
end
|
201
|
+
|
202
|
+
TABLE_FN_ADJ = <<~XPATH.freeze
|
203
|
+
//a[@class='TableFootnoteRef'][following-sibling::*[1][self::a[@class='TableFootnoteRef']]]
|
204
|
+
XPATH
|
205
|
+
|
206
|
+
FN_ADJ = <<~XPATH.freeze
|
207
|
+
//span[@class='MsoFootnoteReference'][following-sibling::*[1][self::span[@class='MsoFootnoteReference']]]
|
208
|
+
XPATH
|
209
|
+
|
210
|
+
def word_fn_cleanup(docxml)
|
211
|
+
docxml.xpath(TABLE_FN_ADJ).each do |a|
|
212
|
+
a.next = '<span class="TableFootnoteRef">, </span>'
|
213
|
+
end
|
214
|
+
docxml.xpath(FN_ADJ).each do |a|
|
215
|
+
a.next = '<span class="MsoFootnoteReference">, </span>'
|
216
|
+
end
|
217
|
+
end
|
200
218
|
end
|
201
219
|
end
|
202
220
|
end
|
@@ -92,15 +92,13 @@ module IsoDoc
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def toc_word_class_list(classes)
|
95
|
-
classes.map
|
96
|
-
/ /.match?(x) ? %("#{x}") : x
|
97
|
-
end.join(",")
|
95
|
+
classes.map { |x| "#{x},1" }.join(",")
|
98
96
|
end
|
99
97
|
|
100
98
|
def word_toc_reqt_preface1
|
101
99
|
<<~TOC
|
102
100
|
<span lang="EN-GB"><span style='mso-element:field-begin'></span><span
|
103
|
-
style='mso-spacerun:yes'> </span>TOC \\h \\z \\t #{toc_word_class_list reqt_toc_class}
|
101
|
+
style='mso-spacerun:yes'> </span>TOC \\h \\z \\t "#{toc_word_class_list reqt_toc_class}"
|
104
102
|
<span style='mso-element:field-separator'></span></span>
|
105
103
|
TOC
|
106
104
|
end
|
@@ -108,14 +106,14 @@ module IsoDoc
|
|
108
106
|
def word_toc_table_preface1
|
109
107
|
<<~TOC
|
110
108
|
<span lang="EN-GB"><span style='mso-element:field-begin'></span><span style='mso-spacerun:yes'> </span>TOC
|
111
|
-
\\h \\z \\t #{toc_word_class_list table_toc_class} <span style='mso-element:field-separator'></span></span>
|
109
|
+
\\h \\z \\t "#{toc_word_class_list table_toc_class}" <span style='mso-element:field-separator'></span></span>
|
112
110
|
TOC
|
113
111
|
end
|
114
112
|
|
115
113
|
def word_toc_figure_preface1
|
116
114
|
<<~TOC
|
117
115
|
<span lang="EN-GB"><span style='mso-element:field-begin'></span><span style='mso-spacerun:yes'> </span>TOC
|
118
|
-
\\h \\z \\t #{toc_word_class_list figure_toc_class} <span style='mso-element:field-separator'></span></span>
|
116
|
+
\\h \\z \\t "#{toc_word_class_list figure_toc_class}" <span style='mso-element:field-separator'></span></span>
|
119
117
|
TOC
|
120
118
|
end
|
121
119
|
|
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -58,8 +58,15 @@ module IsoDoc
|
|
58
58
|
ret["--param baseassetpath="] = @baseassetpath
|
59
59
|
ret = ret.merge(@pdf_cmd_options)
|
60
60
|
%w(--xsl-file --xsl-file-override).each do |x|
|
61
|
-
|
62
|
-
|
61
|
+
if ret[x]
|
62
|
+
ret[x] = if File.absolute_path?(ret[x])
|
63
|
+
Pathname.new(ret[x]).to_s
|
64
|
+
else
|
65
|
+
Pathname.new(
|
66
|
+
File.expand_path(File.join(@baseassetpath, ret[x])),
|
67
|
+
).to_s
|
68
|
+
end
|
69
|
+
end
|
63
70
|
end
|
64
71
|
if ret["--xsl-file"]
|
65
72
|
@xsl = ret["--xsl-file"]
|
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.5
|
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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|