isodoc 2.1.3 → 2.2.0
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 +2 -2
- data/lib/isodoc/function/inline.rb +12 -7
- data/lib/isodoc/function/references.rb +16 -5
- data/lib/isodoc/function/section_titles.rb +3 -3
- data/lib/isodoc/function/to_word_html.rb +1 -1
- data/lib/isodoc/presentation_function/block.rb +2 -2
- data/lib/isodoc/presentation_function/section.rb +23 -7
- data/lib/isodoc/presentation_function/terms.rb +7 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +9 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
- data/lib/isodoc-yaml/i18n-de.yaml +2 -1
- data/lib/isodoc-yaml/i18n-en.yaml +2 -1
- data/lib/isodoc-yaml/i18n-es.yaml +2 -1
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +2 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- 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: c60f8eb9fcf49c289d99f64d901511387ae9d928a93c20ec81c011eb536f8a6a
|
4
|
+
data.tar.gz: f4c33c72526c543b3d7c4929a20dfaa2413e9d007b8d2315aed424e156ad4061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd64d2a35ac86b7b70d46b4ea3631070291b32ee014199d1bc395c5bf33c130d41527afcce573fddd49dc96a4f97d77a6e21a81ed45afec325ce2da61ad4c6ed
|
7
|
+
data.tar.gz: 758249109707c1a6132311e2706f9b791799960f063546cdc8d125f36919845e03bfc5546d2a68d47c30f782fd20b3de1143e66e88a53b5b5bb766e52407a2a7
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -15,8 +15,8 @@ module IsoDoc
|
|
15
15
|
def ns(xpath)
|
16
16
|
xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
|
17
17
|
.gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
|
18
|
-
.gsub(%r{\[([a-zA-z][a-z0-9A-Z
|
19
|
-
.gsub(%r{\[([a-zA-z][a-z0-9A-Z
|
18
|
+
.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)
|
@@ -17,7 +17,13 @@ module IsoDoc
|
|
17
17
|
def location_parse(node, out); end
|
18
18
|
|
19
19
|
def span_parse(node, out)
|
20
|
-
node
|
20
|
+
if node["style"]
|
21
|
+
out.span **{ style: node["style"] } do |s|
|
22
|
+
node.children.each { |n| parse(n, s) }
|
23
|
+
end
|
24
|
+
else
|
25
|
+
node.children.each { |n| parse(n, out) }
|
26
|
+
end
|
21
27
|
end
|
22
28
|
|
23
29
|
def callout_parse(node, out)
|
@@ -57,12 +63,11 @@ module IsoDoc
|
|
57
63
|
def eref_url(bibitemid)
|
58
64
|
return nil if @bibitems.nil? || @bibitems[bibitemid].nil?
|
59
65
|
|
60
|
-
|
61
|
-
url.text
|
62
|
-
|
63
|
-
@bibitems[bibitemid]
|
64
|
-
|
65
|
-
end
|
66
|
+
url = @bibitems[bibitemid].at(ns("./uri[@type = 'citation']")) and
|
67
|
+
return url.text
|
68
|
+
@bibitems[bibitemid]["hidden"] == "true" and
|
69
|
+
return @bibitems[bibitemid].at(ns("./uri"))&.text
|
70
|
+
"##{bibitemid}"
|
66
71
|
end
|
67
72
|
|
68
73
|
def eref_parse(node, out)
|
@@ -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)"
|
@@ -5,15 +5,15 @@ module IsoDoc
|
|
5
5
|
"."
|
6
6
|
end
|
7
7
|
|
8
|
-
def clausedelimspace(out)
|
8
|
+
def clausedelimspace(_node, out)
|
9
9
|
insert_tab(out, 1)
|
10
10
|
end
|
11
11
|
|
12
|
-
def inline_header_title(out,
|
12
|
+
def inline_header_title(out, node, title)
|
13
13
|
out.span **{ class: "zzMoveToFollowing" } do |s|
|
14
14
|
s.b do |b|
|
15
15
|
title&.children&.each { |c2| parse(c2, b) }
|
16
|
-
clausedelimspace(out) if /\S/.match?(title&.text)
|
16
|
+
clausedelimspace(node, out) if /\S/.match?(title&.text)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -218,7 +218,7 @@ module IsoDoc
|
|
218
218
|
when "feedback-statement" then feedback_parse(node, out)
|
219
219
|
when "passthrough" then passthrough_parse(node, out)
|
220
220
|
when "amend" then amend_parse(node, out)
|
221
|
-
when "tab" then clausedelimspace(out) # in Presentation XML only
|
221
|
+
when "tab" then clausedelimspace(node, out) # in Presentation XML only
|
222
222
|
when "svg" then svg_parse(node, out) # in Presentation XML only
|
223
223
|
when "add" then add_parse(node, out)
|
224
224
|
when "del" then del_parse(node, out)
|
@@ -20,8 +20,8 @@ module IsoDoc
|
|
20
20
|
node.children.first.previous = "<#{elem}></#{elem}>"
|
21
21
|
name = node.children.first
|
22
22
|
end
|
23
|
-
if name.children.empty? then name.add_child(cleanup_entities(number))
|
24
|
-
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}")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -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
|
@@ -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)
|
data/lib/isodoc/version.rb
CHANGED
@@ -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(@c.encode(s.next.text.sub(/^\s+/, ""), :hexadecimal))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
96
105
|
def word_colgroup(docxml)
|
97
106
|
cells2d = {}
|
98
107
|
docxml.xpath("//table[colgroup]").each do |t|
|
@@ -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,
|
@@ -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,
|
@@ -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: Раздел,
|
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.
|
4
|
+
version: 2.2.0
|
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-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|