isodoc 2.1.2.1 → 2.1.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/class_utils.rb +17 -1
- data/lib/isodoc/function/references.rb +16 -5
- data/lib/isodoc/function/utils.rb +4 -0
- data/lib/isodoc/presentation_function/block.rb +9 -5
- data/lib/isodoc/presentation_function/image.rb +1 -1
- data/lib/isodoc/presentation_function/inline.rb +0 -8
- data/lib/isodoc/presentation_function/section.rb +24 -8
- data/lib/isodoc/presentation_function/terms.rb +7 -2
- data/lib/isodoc/presentation_function/xrefs.rb +1 -3
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +1 -1
- data/lib/isodoc/word_function/inline.rb +7 -2
- data/lib/isodoc/word_function/postprocess.rb +9 -0
- data/lib/isodoc/xref.rb +1 -1
- data/lib/isodoc-yaml/i18n-ar.yaml +2 -0
- data/lib/isodoc-yaml/i18n-de.yaml +3 -1
- data/lib/isodoc-yaml/i18n-en.yaml +3 -1
- data/lib/isodoc-yaml/i18n-es.yaml +3 -1
- data/lib/isodoc-yaml/i18n-fr.yaml +2 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +3 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0dec55aba65a594c5a4ef3916219976edb11e162aee6f806f05bc587466941a
|
4
|
+
data.tar.gz: 47ef329be8d9b6aff1777820aa4901a74400888196227ea5dc08a218793e6f87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd9d0f72fdef518808f6605953fa11d6033c5693a8851807b617bacc0d43315657ed80b8de93f0f46bcfb9d0529f327d647e00947234c5ebefa8666250b57ea9
|
7
|
+
data.tar.gz: 3ef2cc2b5f97c2358e5e888865c8406ce66808e3fb7e62804646b71838ad748e372880ce359648dadd581bc36205e6d347aedbe220f2c9d6a1a7f5ee130d8055
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -16,7 +16,7 @@ module IsoDoc
|
|
16
16
|
xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
|
17
17
|
.gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
|
18
18
|
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1")
|
19
|
-
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*[/\]])}, "[xmlns:\\1")
|
19
|
+
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*[/\[\]])}, "[xmlns:\\1")
|
20
20
|
end
|
21
21
|
|
22
22
|
def liquid(doc)
|
@@ -62,5 +62,21 @@ module IsoDoc
|
|
62
62
|
end
|
63
63
|
xml.root.children.to_xml
|
64
64
|
end
|
65
|
+
|
66
|
+
def nearest_block_parent(node)
|
67
|
+
until %w(p title td th name formula li dt dd sourcecode pre quote
|
68
|
+
note example)
|
69
|
+
.include?(node.name)
|
70
|
+
node = node.parent
|
71
|
+
end
|
72
|
+
node
|
73
|
+
end
|
74
|
+
|
75
|
+
# node is at the start of sentence in a Metanorma XML context
|
76
|
+
def start_of_sentence(node)
|
77
|
+
prec = nearest_block_parent(node).xpath("./descendant-or-self::text()") &
|
78
|
+
node.xpath("./preceding::text()")
|
79
|
+
prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map(&:text).join)
|
80
|
+
end
|
65
81
|
end
|
66
82
|
end
|
@@ -19,7 +19,8 @@ module IsoDoc
|
|
19
19
|
ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
|
20
20
|
ref << ", #{idents[sdo]}" if idents[:ordinal] && idents[:sdo]
|
21
21
|
end
|
22
|
-
ref << ",
|
22
|
+
ref << "," if idents[:sdo]
|
23
|
+
ref << " "
|
23
24
|
reference_format(bib, ref)
|
24
25
|
end
|
25
26
|
end
|
@@ -34,7 +35,8 @@ module IsoDoc
|
|
34
35
|
idents[:metanorma]) && idents[:sdo]
|
35
36
|
end
|
36
37
|
date_note_process(bib, ref)
|
37
|
-
ref << ",
|
38
|
+
ref << "," if idents[:sdo]
|
39
|
+
ref << " "
|
38
40
|
reference_format(bib, ref)
|
39
41
|
end
|
40
42
|
end
|
@@ -48,13 +50,21 @@ module IsoDoc
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def pref_ref_code(bib)
|
51
|
-
|
53
|
+
return nil if bib["suppress_identifier"] == "true"
|
54
|
+
|
55
|
+
ret = bib.xpath(ns("./docidentifier[@primary = 'true'][@language = '#{@lang}']"))
|
56
|
+
ret.empty? and
|
57
|
+
ret = bib.xpath(ns("./docidentifier[@primary = 'true']"))
|
52
58
|
ret.empty? and
|
53
59
|
ret = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
|
54
60
|
"@type = 'metanorma' "\
|
55
61
|
"or @type = 'metanorma-ordinal' or "\
|
56
|
-
"@type = 'ISSN' or @type = 'ISBN'
|
57
|
-
"@
|
62
|
+
"@type = 'ISSN' or @type = 'ISBN')]"\
|
63
|
+
"[@language = '#{@lang}']")) ||
|
64
|
+
bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
|
65
|
+
"@type = 'metanorma' "\
|
66
|
+
"or @type = 'metanorma-ordinal' or "\
|
67
|
+
"@type = 'ISSN' or @type = 'ISBN')]"))
|
58
68
|
ret
|
59
69
|
end
|
60
70
|
|
@@ -66,6 +76,7 @@ module IsoDoc
|
|
66
76
|
"@type = 'ISBN']"))
|
67
77
|
id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
|
68
78
|
return [id, id1, id2, id3] if id || id1 || id2 || id3
|
79
|
+
return [nil, nil, nil, nil] if bib["suppress_identifier"] == "true"
|
69
80
|
|
70
81
|
id = Nokogiri::XML::Node.new("docidentifier", bib.document)
|
71
82
|
id << "(NO ID)"
|
@@ -11,6 +11,10 @@ module IsoDoc
|
|
11
11
|
self.class.ns(xpath)
|
12
12
|
end
|
13
13
|
|
14
|
+
def start_of_sentence(node)
|
15
|
+
self.class.start_of_sentence(node)
|
16
|
+
end
|
17
|
+
|
14
18
|
def insert_tab(out, count)
|
15
19
|
tab = %w(Hans Hant).include?(@script) ? " " : "  "
|
16
20
|
[1..count].each { out << tab }
|
@@ -8,6 +8,10 @@ module IsoDoc
|
|
8
8
|
text.capitalize
|
9
9
|
end
|
10
10
|
|
11
|
+
def block_delim
|
12
|
+
" — "
|
13
|
+
end
|
14
|
+
|
11
15
|
def prefix_name(node, delim, number, elem)
|
12
16
|
return if number.nil? || number.empty?
|
13
17
|
|
@@ -16,8 +20,8 @@ module IsoDoc
|
|
16
20
|
node.children.first.previous = "<#{elem}></#{elem}>"
|
17
21
|
name = node.children.first
|
18
22
|
end
|
19
|
-
if name.children.empty? then name.add_child(cleanup_entities(number))
|
20
|
-
else (name.children.first.previous = "#{number}#{delim}")
|
23
|
+
if name.children.empty? then name.add_child(cleanup_entities(number.strip))
|
24
|
+
else (name.children.first.previous = "#{number.strip}#{delim}")
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
@@ -31,7 +35,7 @@ module IsoDoc
|
|
31
35
|
return if labelled_ancestor(elem)
|
32
36
|
|
33
37
|
lbl = @xrefs.anchor(elem["id"], :label, false) or return
|
34
|
-
prefix_name(elem,
|
38
|
+
prefix_name(elem, block_delim,
|
35
39
|
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
36
40
|
end
|
37
41
|
|
@@ -60,7 +64,7 @@ module IsoDoc
|
|
60
64
|
else
|
61
65
|
l10n("#{@i18n.example} #{n[:label]}")
|
62
66
|
end
|
63
|
-
prefix_name(elem,
|
67
|
+
prefix_name(elem, block_delim, lbl, "name")
|
64
68
|
end
|
65
69
|
|
66
70
|
def note(docxml)
|
@@ -130,7 +134,7 @@ module IsoDoc
|
|
130
134
|
return if elem["unnumbered"] && !elem.at(ns("./name"))
|
131
135
|
|
132
136
|
n = @xrefs.anchor(elem["id"], :label, false)
|
133
|
-
prefix_name(elem,
|
137
|
+
prefix_name(elem, block_delim, l10n("#{lower2cap @i18n.table} #{n}"),
|
134
138
|
"name")
|
135
139
|
end
|
136
140
|
|
@@ -32,7 +32,7 @@ module IsoDoc
|
|
32
32
|
return if elem.at(ns("./figure")) && !elem.at(ns("./name"))
|
33
33
|
|
34
34
|
lbl = @xrefs.anchor(elem["id"], :label, false) or return
|
35
|
-
prefix_name(elem,
|
35
|
+
prefix_name(elem, block_delim,
|
36
36
|
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
37
37
|
end
|
38
38
|
|
@@ -3,14 +3,6 @@ require_relative "xrefs"
|
|
3
3
|
|
4
4
|
module IsoDoc
|
5
5
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
6
|
-
def nearest_block_parent(node)
|
7
|
-
until %w(p title td th name formula li dt dd sourcecode pre)
|
8
|
-
.include?(node.name)
|
9
|
-
node = node.parent
|
10
|
-
end
|
11
|
-
node
|
12
|
-
end
|
13
|
-
|
14
6
|
def non_locality_elems(node)
|
15
7
|
node.children.reject do |c|
|
16
8
|
%w{locality localityStack location}.include? c.name
|
@@ -11,7 +11,8 @@ module IsoDoc
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def clause1(elem)
|
14
|
-
level = @xrefs.anchor(elem["id"], :level, false) ||
|
14
|
+
level = @xrefs.anchor(elem["id"], :level, false) ||
|
15
|
+
(elem.ancestors("clause, annex").size + 1)
|
15
16
|
t = elem.at(ns("./title")) and t["depth"] = level
|
16
17
|
return if !elem.ancestors("boilerplate").empty? ||
|
17
18
|
@suppressheadingnumbers || elem["unnumbered"]
|
@@ -80,6 +81,10 @@ module IsoDoc
|
|
80
81
|
docxml.xpath(ns("//references/bibitem")).each do |x|
|
81
82
|
bibitem(x)
|
82
83
|
end
|
84
|
+
docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x|
|
85
|
+
x.at(ns("./bibitem[not(@hidden = 'true')]")) and next
|
86
|
+
x["hidden"] = "true"
|
87
|
+
end
|
83
88
|
@xrefs.parse_inclusions(refs: true).parse(docxml)
|
84
89
|
end
|
85
90
|
|
@@ -91,15 +96,26 @@ module IsoDoc
|
|
91
96
|
|
92
97
|
def bibrender(xml)
|
93
98
|
if f = xml.at(ns("./formattedref"))
|
94
|
-
|
95
|
-
|
96
|
-
else
|
97
|
-
xml.children =
|
98
|
-
"#{bibrenderer.render(xml.to_xml)}"\
|
99
|
-
"#{xml.xpath(ns('./docidentifier | ./uri | ./note')).to_xml}"
|
99
|
+
bibrender_formattedref(f, xml)
|
100
|
+
else bibrender_relaton(xml)
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
104
|
+
def bibrender_formattedref(formattedref, xml)
|
105
|
+
code = render_identifier(bibitem_ref_code(xml))
|
106
|
+
(code[:sdo] && xml["suppress_identifier"] != "true") and
|
107
|
+
formattedref << " [#{code[:sdo]}] "
|
108
|
+
end
|
109
|
+
|
110
|
+
def bibrender_relaton(xml)
|
111
|
+
bib = xml.dup
|
112
|
+
bib["suppress_identifier"] == true and
|
113
|
+
bib.xpath(ns("./docidentifier")).each(&:remove)
|
114
|
+
xml.children =
|
115
|
+
"#{bibrenderer.render(bib.to_xml)}"\
|
116
|
+
"#{xml.xpath(ns('./docidentifier | ./uri | ./note')).to_xml}"
|
117
|
+
end
|
118
|
+
|
103
119
|
def bibrenderer
|
104
120
|
::Relaton::Render::IsoDoc::General.new(language: @lang)
|
105
121
|
end
|
@@ -177,7 +193,7 @@ module IsoDoc
|
|
177
193
|
|
178
194
|
def toc(docxml)
|
179
195
|
docxml.xpath(ns("//toc//xref[text()]")).each do |x|
|
180
|
-
lbl = @xrefs.
|
196
|
+
lbl = @xrefs.anchor(x["target"], :label) or next
|
181
197
|
x.children.first.previous = "#{lbl}<tab/>"
|
182
198
|
end
|
183
199
|
end
|
@@ -82,8 +82,13 @@ module IsoDoc
|
|
82
82
|
p = node.at(ns("./preferred"))
|
83
83
|
ref = node.at(ns("./xref | ./eref | ./termref"))
|
84
84
|
label = @i18n.relatedterms[node["type"]].upcase
|
85
|
-
|
86
|
-
|
85
|
+
if p && ref
|
86
|
+
node.replace(l10n("<p><strong>#{label}:</strong> "\
|
87
|
+
"<em>#{p.to_xml}</em> (#{ref.to_xml})</p>"))
|
88
|
+
else
|
89
|
+
node.replace(l10n("<p><strong>#{label}:</strong> "\
|
90
|
+
"<strong>**RELATED TERM NOT FOUND**</strong></p>"))
|
91
|
+
end
|
87
92
|
end
|
88
93
|
|
89
94
|
def designation(docxml)
|
@@ -105,9 +105,7 @@ module IsoDoc
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def capitalise_xref1(node, linkend)
|
108
|
-
|
109
|
-
node.xpath("./preceding::text()")
|
110
|
-
if prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map(&:text).join)
|
108
|
+
if start_of_sentence(node)
|
111
109
|
Common::case_with_markup(linkend, "capital", @script)
|
112
110
|
else linkend
|
113
111
|
end
|
data/lib/isodoc/version.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module WordFunction
|
3
3
|
module Body
|
4
|
-
def section_break(body)
|
4
|
+
def section_break(body, continuous: false)
|
5
5
|
body.p do |p|
|
6
|
-
|
6
|
+
if continuous
|
7
|
+
p.br **{ clear: "all", style: "page-break-before:auto;"\
|
8
|
+
"mso-break-type:section-break" }
|
9
|
+
else
|
10
|
+
p.br **{ clear: "all", class: "section" }
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
9
14
|
|
@@ -88,11 +88,20 @@ module IsoDoc
|
|
88
88
|
word_pseudocode_cleanup(docxml)
|
89
89
|
word_image_caption(docxml)
|
90
90
|
word_section_breaks(docxml)
|
91
|
+
word_tab_clean(docxml)
|
91
92
|
authority_cleanup(docxml)
|
92
93
|
word_footnote_format(docxml)
|
93
94
|
docxml
|
94
95
|
end
|
95
96
|
|
97
|
+
def word_tab_clean(docxml)
|
98
|
+
docxml.xpath("//p[@class='Biblio']//span[@style='mso-tab-count:1']")
|
99
|
+
.each do |s|
|
100
|
+
s.next.text? or next
|
101
|
+
s.next.replace(s.next.text.sub(/^\s+/, ""))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
96
105
|
def word_colgroup(docxml)
|
97
106
|
cells2d = {}
|
98
107
|
docxml.xpath("//table[colgroup]").each do |t|
|
data/lib/isodoc/xref.rb
CHANGED
@@ -52,7 +52,7 @@ module IsoDoc
|
|
52
52
|
|
53
53
|
# extract names for all anchors, xref and label
|
54
54
|
def parse(docxml)
|
55
|
-
amend_preprocess(docxml) if
|
55
|
+
amend_preprocess(docxml) if @parse_settings.empty?
|
56
56
|
initial_anchor_names(docxml)
|
57
57
|
back_anchor_names(docxml)
|
58
58
|
# preempt clause notes with all other types of note (ISO default)
|
@@ -94,6 +94,7 @@ admonition:
|
|
94
94
|
caution: حذر
|
95
95
|
important: مهم
|
96
96
|
safety precautions: احتياطات السلامة
|
97
|
+
editorial: ملاحظة تحريرية
|
97
98
|
locality:
|
98
99
|
section: قسم
|
99
100
|
clause: فقرة
|
@@ -132,6 +133,7 @@ relatedterms:
|
|
132
133
|
contrast: مضاد
|
133
134
|
# تباين
|
134
135
|
see: انظر
|
136
|
+
seealso: انظر أيضا
|
135
137
|
inflection:
|
136
138
|
فقرة:
|
137
139
|
sg: فقرة
|
@@ -99,7 +99,8 @@ admonition: {
|
|
99
99
|
warning: Warnung,
|
100
100
|
caution: Vorsicht,
|
101
101
|
important: Wichtig,
|
102
|
-
safety precautions: Sicherheitsvorkehrungen
|
102
|
+
safety precautions: Sicherheitsvorkehrungen,
|
103
|
+
editorial: Redaktioneller Hinweis
|
103
104
|
}
|
104
105
|
locality: {
|
105
106
|
section: Abschnitt,
|
@@ -138,6 +139,7 @@ relatedterms:
|
|
138
139
|
compare: vergleiche
|
139
140
|
contrast: dagegen
|
140
141
|
see: siehe
|
142
|
+
seealso: siehe auch
|
141
143
|
inflection:
|
142
144
|
Klausel:
|
143
145
|
sg: Klausel
|
@@ -99,7 +99,8 @@ admonition: {
|
|
99
99
|
warning: Warning,
|
100
100
|
caution: Caution,
|
101
101
|
important: Important,
|
102
|
-
safety precautions: Safety Precautions
|
102
|
+
safety precautions: Safety Precautions,
|
103
|
+
editorial: Editorial Note
|
103
104
|
}
|
104
105
|
locality: {
|
105
106
|
section: Section,
|
@@ -138,6 +139,7 @@ relatedterms:
|
|
138
139
|
compare: compare
|
139
140
|
contrast: contrast
|
140
141
|
see: see
|
142
|
+
seealso: see also
|
141
143
|
inflection:
|
142
144
|
Clause:
|
143
145
|
sg: Clause
|
@@ -99,7 +99,8 @@ admonition: {
|
|
99
99
|
warning: Advertencia,
|
100
100
|
caution: Precaución,
|
101
101
|
important: Importante,
|
102
|
-
safety precautions: Precauciones de seguridad
|
102
|
+
safety precautions: Precauciones de seguridad,
|
103
|
+
editorial: Note editorial
|
103
104
|
}
|
104
105
|
locality: {
|
105
106
|
section: Sección,
|
@@ -138,6 +139,7 @@ relatedterms:
|
|
138
139
|
compare: relacionado
|
139
140
|
contrast: difiere
|
140
141
|
see: véase
|
142
|
+
seealso: véase tambien
|
141
143
|
inflection:
|
142
144
|
Cláusula:
|
143
145
|
sg: Cláusula
|
@@ -98,6 +98,7 @@ admonition: {
|
|
98
98
|
caution: Attention,
|
99
99
|
important: Important,
|
100
100
|
safety precautions: Précautions de Sécurité,
|
101
|
+
editorial: Note éditoriale
|
101
102
|
}
|
102
103
|
locality: {
|
103
104
|
section: Section,
|
@@ -136,6 +137,7 @@ relatedterms:
|
|
136
137
|
compare: comparez
|
137
138
|
contrast: contrastez
|
138
139
|
see: voir
|
140
|
+
seealso: voir aussi
|
139
141
|
inflection:
|
140
142
|
Clause:
|
141
143
|
sg: Article
|
@@ -104,7 +104,8 @@ admonition: {
|
|
104
104
|
warning: Предупреждение,
|
105
105
|
caution: Предостережение,
|
106
106
|
important: Важно,
|
107
|
-
safety precautions: Меры
|
107
|
+
safety precautions: Меры безопасности,
|
108
|
+
editorial: Редакционная Заметка
|
108
109
|
}
|
109
110
|
locality: {
|
110
111
|
section: Раздел,
|
@@ -143,6 +144,7 @@ relatedterms:
|
|
143
144
|
compare: наравне
|
144
145
|
contrast: противоположный
|
145
146
|
see: см.
|
147
|
+
seealso: см. также
|
146
148
|
inflection:
|
147
149
|
Пункт:
|
148
150
|
sg: Пункт
|
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.1.
|
4
|
+
version: 2.1.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: 2022-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -504,7 +504,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
504
504
|
- !ruby/object:Gem::Version
|
505
505
|
version: '0'
|
506
506
|
requirements: []
|
507
|
-
rubygems_version: 3.3.
|
507
|
+
rubygems_version: 3.3.16
|
508
508
|
signing_key:
|
509
509
|
specification_version: 4
|
510
510
|
summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.
|