isodoc 2.12.0 → 2.12.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/isodoc.gemspec +2 -2
- data/lib/isodoc/convert.rb +0 -21
- data/lib/isodoc/function/blocks.rb +19 -48
- data/lib/isodoc/function/blocks_example_note.rb +75 -29
- data/lib/isodoc/function/cleanup.rb +3 -40
- data/lib/isodoc/function/inline.rb +39 -9
- data/lib/isodoc/function/lists.rb +5 -5
- data/lib/isodoc/function/references.rb +9 -133
- data/lib/isodoc/function/reqt.rb +2 -2
- data/lib/isodoc/function/section.rb +25 -28
- data/lib/isodoc/function/section_titles.rb +16 -13
- data/lib/isodoc/function/table.rb +3 -3
- data/lib/isodoc/function/terms.rb +21 -20
- data/lib/isodoc/function/to_word_html.rb +8 -5
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/html_function/footnotes.rb +2 -1
- data/lib/isodoc/html_function/html.rb +1 -5
- data/lib/isodoc/init.rb +31 -0
- data/lib/isodoc/metadata.rb +9 -0
- data/lib/isodoc/metadata_contributor.rb +1 -1
- data/lib/isodoc/metadata_date.rb +1 -1
- data/lib/isodoc/presentation_function/autonum.rb +139 -0
- data/lib/isodoc/presentation_function/block.rb +95 -36
- data/lib/isodoc/presentation_function/docid.rb +78 -0
- data/lib/isodoc/presentation_function/erefs.rb +6 -4
- data/lib/isodoc/presentation_function/image.rb +52 -13
- data/lib/isodoc/presentation_function/inline.rb +6 -6
- data/lib/isodoc/presentation_function/math.rb +0 -14
- data/lib/isodoc/presentation_function/metadata.rb +0 -62
- data/lib/isodoc/presentation_function/refs.rb +44 -14
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +46 -121
- data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
- data/lib/isodoc/presentation_function/terms.rb +27 -2
- data/lib/isodoc/presentation_function/title.rb +107 -0
- data/lib/isodoc/presentation_function/xrefs.rb +17 -10
- data/lib/isodoc/presentation_xml_convert.rb +6 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +8 -36
- data/lib/isodoc/word_function/footnotes.rb +1 -1
- data/lib/isodoc/word_function/lists.rb +12 -10
- data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
- data/lib/isodoc/word_function/postprocess_table.rb +1 -1
- data/lib/isodoc/word_function/table.rb +2 -2
- data/lib/isodoc/xref/clause_order.rb +2 -2
- data/lib/isodoc/xref/xref_anchor.rb +31 -16
- data/lib/isodoc/xref/xref_counter_types.rb +3 -2
- data/lib/isodoc/xref/xref_gen.rb +57 -33
- data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
- data/lib/isodoc/xref/xref_sect_gen.rb +64 -47
- data/lib/isodoc/xref/xref_util.rb +49 -1
- data/lib/isodoc/xref.rb +3 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
- data/lib/isodoc-yaml/i18n-de.yaml +9 -9
- data/lib/isodoc-yaml/i18n-en.yaml +9 -9
- data/lib/isodoc-yaml/i18n-es.yaml +9 -9
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
- data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
- data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
- data/lib/nokogiri/xml/node.rb +1 -0
- metadata +9 -6
@@ -1,16 +1,7 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module Function
|
3
3
|
module References
|
4
|
-
|
5
|
-
# references anyway; keeping here instead of in IsoDoc::Iso for now
|
6
|
-
def docid_l10n(text)
|
7
|
-
text.nil? and return text
|
8
|
-
@i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
|
9
|
-
text.size < 20 and text.gsub!(/ /, " ")
|
10
|
-
text
|
11
|
-
end
|
12
|
-
|
13
|
-
def nonstd_bibitem(list, bib, _ordinal, biblio)
|
4
|
+
def bibitem_entry(list, bib, _ordinal, biblio)
|
14
5
|
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
15
6
|
tag = bib.at(ns("./biblio-tag"))
|
16
7
|
tag&.children&.each { |n| parse(n, ref) }
|
@@ -18,139 +9,24 @@ module IsoDoc
|
|
18
9
|
end
|
19
10
|
end
|
20
11
|
|
21
|
-
def std_bibitem_entry(list, bib, _ordinal, biblio)
|
22
|
-
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
23
|
-
tag = bib.at(ns("./biblio-tag"))
|
24
|
-
tag&.children&.each { |n| parse(n, ref) }
|
25
|
-
reference_format(bib, ref)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
SKIP_DOCID = <<~XPATH.strip.freeze
|
30
|
-
@type = 'DOI' or @type = 'doi' or @type = 'ISSN' or @type = 'issn' or @type = 'ISBN' or @type = 'isbn' or starts-with(@type, 'ISSN.') or starts-with(@type, 'ISBN.') or starts-with(@type, 'issn.') or starts-with(@type, 'isbn.')
|
31
|
-
XPATH
|
32
|
-
|
33
|
-
def pref_ref_code(bib)
|
34
|
-
bib["suppress_identifier"] == "true" and return nil
|
35
|
-
ret = bib.xpath(ns("./docidentifier[@scope = 'biblio-tag']"))
|
36
|
-
ret.empty? or return ret.map(&:text)
|
37
|
-
ret = pref_ref_code_parse(bib) or return nil
|
38
|
-
ins = bib.at(ns("./docidentifier[last()]"))
|
39
|
-
ret.reverse.each do |r|
|
40
|
-
ins.next = "<docidentifier scope='biblio-tag'>#{docid_l10n(r)}</docidentifier>"
|
41
|
-
end
|
42
|
-
ret
|
43
|
-
end
|
44
|
-
|
45
|
-
def pref_ref_code_parse(bib)
|
46
|
-
data, = @bibrender.parse(bib)
|
47
|
-
ret = data[:authoritative_identifier] or return nil
|
48
|
-
ret.empty? and return nil
|
49
|
-
ret
|
50
|
-
end
|
51
|
-
|
52
|
-
# returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
|
53
|
-
def bibitem_ref_code(bib)
|
54
|
-
id, id1, id2, id3 = bibitem_ref_code_prep(bib)
|
55
|
-
id || id1 || id2 || id3 and return [id, id1, id2, id3]
|
56
|
-
bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil]
|
57
|
-
[nil, no_identifier(bib), nil, nil]
|
58
|
-
end
|
59
|
-
|
60
|
-
def bibitem_ref_code_prep(bib)
|
61
|
-
id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
|
62
|
-
id1 = pref_ref_code(bib)
|
63
|
-
id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
|
64
|
-
id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
|
65
|
-
[id, id1, id2, id3]
|
66
|
-
end
|
67
|
-
|
68
|
-
def no_identifier(bib)
|
69
|
-
@i18n.no_identifier or return nil
|
70
|
-
id = Nokogiri::XML::Node.new("docidentifier", bib.document)
|
71
|
-
id << @i18n.no_identifier
|
72
|
-
id
|
73
|
-
end
|
74
|
-
|
75
|
-
def bracket_if_num(num)
|
76
|
-
num.nil? and return nil
|
77
|
-
num = num.text.sub(/^\[/, "").sub(/\]$/, "")
|
78
|
-
/^\d+$/.match?(num) and return "[#{num}]"
|
79
|
-
num
|
80
|
-
end
|
81
|
-
|
82
|
-
def unbracket1(ident)
|
83
|
-
ident.nil? and return nil
|
84
|
-
ident.is_a?(String) or ident = ident.text
|
85
|
-
ident.sub(/^\[/, "").sub(/\]$/, "")
|
86
|
-
end
|
87
|
-
|
88
|
-
def unbracket(ident)
|
89
|
-
if ident.respond_to?(:size)
|
90
|
-
ident.map { |x| unbracket1(x) }.join(" / ")
|
91
|
-
else
|
92
|
-
unbracket1(ident)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def render_identifier(ident)
|
97
|
-
{ metanorma: bracket_if_num(ident[0]),
|
98
|
-
sdo: unbracket(ident[1]),
|
99
|
-
doi: unbracket(ident[2]),
|
100
|
-
ordinal: bracket_if_num(ident[3]) }
|
101
|
-
end
|
102
|
-
|
103
|
-
def docid_prefix(prefix, docid)
|
104
|
-
docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
|
105
|
-
!/^#{prefix}\b/.match(docid)
|
106
|
-
docid_l10n(docid)
|
107
|
-
end
|
108
|
-
|
109
|
-
def omit_docid_prefix(prefix)
|
110
|
-
return true if prefix.nil? || prefix.empty?
|
111
|
-
|
112
|
-
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
|
113
|
-
.include? prefix
|
114
|
-
end
|
115
|
-
|
116
12
|
def iso_bibitem_entry_attrs(bib, biblio)
|
117
13
|
{ id: bib["id"], class: biblio ? "Biblio" : "NormRef" }
|
118
14
|
end
|
119
15
|
|
120
|
-
# reference not to be rendered because it is deemed implicit
|
121
|
-
# in the standards environment
|
122
|
-
def implicit_reference(bib)
|
123
|
-
bib["hidden"] == "true"
|
124
|
-
end
|
125
|
-
|
126
16
|
def reference_format(bib, out)
|
127
17
|
ftitle = bib.at(ns("./formattedref"))
|
128
18
|
ftitle&.children&.each { |n| parse(n, out) }
|
129
19
|
end
|
130
20
|
|
131
|
-
def standard?(bib)
|
132
|
-
ret = false
|
133
|
-
bib.xpath(ns("./docidentifier")).each do |id|
|
134
|
-
next if id["type"].nil? ||
|
135
|
-
id.at(".//self::*[#{SKIP_DOCID} or @type = 'metanorma']")
|
136
|
-
|
137
|
-
ret = true
|
138
|
-
end
|
139
|
-
ret
|
140
|
-
end
|
141
|
-
|
142
21
|
def biblio_list(refs, div, biblio)
|
143
22
|
i = 0
|
144
23
|
refs.children.each do |b|
|
145
24
|
if b.name == "bibitem"
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
if standard?(b) then std_bibitem_entry(div, b, i, biblio)
|
150
|
-
else nonstd_bibitem(div, b, i, biblio)
|
151
|
-
end
|
25
|
+
b["hidden"] == "true" and next
|
26
|
+
i += 1
|
27
|
+
bibitem_entry(div, b, i, biblio)
|
152
28
|
else
|
153
|
-
parse(b, div) unless %w(title).include? b.name
|
29
|
+
parse(b, div) unless %w(fmt-title).include? b.name
|
154
30
|
end
|
155
31
|
end
|
156
32
|
end
|
@@ -165,9 +41,9 @@ module IsoDoc
|
|
165
41
|
def norm_ref(node, out)
|
166
42
|
node["hidden"] != "true" or return
|
167
43
|
out.div do |div|
|
168
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
44
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
169
45
|
if node.name == "clause"
|
170
|
-
node.elements.each { |e| parse(e, div) unless e.name == "title" }
|
46
|
+
node.elements.each { |e| parse(e, div) unless e.name == "fmt-title" }
|
171
47
|
else biblio_list(node, div, false)
|
172
48
|
end
|
173
49
|
end
|
@@ -184,7 +60,7 @@ module IsoDoc
|
|
184
60
|
page_break(out)
|
185
61
|
out.div do |div|
|
186
62
|
div.h1 class: "Section3" do |h1|
|
187
|
-
node.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
|
63
|
+
node.at(ns("./fmt-title"))&.children&.each { |c2| parse(c2, h1) }
|
188
64
|
end
|
189
65
|
biblio_list(node, div, true)
|
190
66
|
end
|
@@ -193,7 +69,7 @@ module IsoDoc
|
|
193
69
|
def bibliography_parse(node, out)
|
194
70
|
node["hidden"] != true or return
|
195
71
|
out.div do |div|
|
196
|
-
clause_parse_title(node, div, node.at(ns("./title")), out,
|
72
|
+
clause_parse_title(node, div, node.at(ns("./fmt-title")), out,
|
197
73
|
{ class: "Section3" })
|
198
74
|
biblio_list(node, div, true)
|
199
75
|
end
|
data/lib/isodoc/function/reqt.rb
CHANGED
@@ -20,9 +20,9 @@ module IsoDoc
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def recommendation_parse1(node, out)
|
23
|
-
recommendation_name(node.at(ns("./name")), out)
|
23
|
+
recommendation_name(node.at(ns("./fmt-name")), out)
|
24
24
|
node.children.each do |n|
|
25
|
-
parse(n, out) unless n.name == "name"
|
25
|
+
parse(n, out) unless n.name == "fmt-name"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -10,8 +10,8 @@ module IsoDoc
|
|
10
10
|
# used for subclauses
|
11
11
|
def clause_parse(node, out)
|
12
12
|
out.div **attr_code(clause_attrs(node)) do |div|
|
13
|
-
clause_parse_title(node, div, node.at(ns("./title")), out)
|
14
|
-
node.children.reject { |c1| c1.name == "title" }.each do |c1|
|
13
|
+
clause_parse_title(node, div, node.at(ns("./fmt-title")), out)
|
14
|
+
node.children.reject { |c1| c1.name == "fmt-title" }.each do |c1|
|
15
15
|
parse(c1, div)
|
16
16
|
end
|
17
17
|
end
|
@@ -19,8 +19,8 @@ module IsoDoc
|
|
19
19
|
|
20
20
|
def clause(node, out)
|
21
21
|
out.div **attr_code(clause_attrs(node)) do |s|
|
22
|
-
clause_name(node, node.at(ns("./title")), s, nil)
|
23
|
-
node.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
22
|
+
clause_name(node, node.at(ns("./fmt-title")), s, nil)
|
23
|
+
node.elements.reject { |c1| c1.name == "fmt-title" }.each do |c1|
|
24
24
|
parse(c1, s)
|
25
25
|
end
|
26
26
|
end
|
@@ -34,7 +34,7 @@ module IsoDoc
|
|
34
34
|
page_break(out)
|
35
35
|
out.div **attr_code(annex_attrs(node)) do |s|
|
36
36
|
node.elements.each do |c1|
|
37
|
-
if c1.name == "title" then annex_name(node, c1, s)
|
37
|
+
if c1.name == "fmt-title" then annex_name(node, c1, s)
|
38
38
|
else parse(c1, s)
|
39
39
|
end
|
40
40
|
end
|
@@ -47,9 +47,9 @@ module IsoDoc
|
|
47
47
|
|
48
48
|
def scope(node, out)
|
49
49
|
out.div **attr_code(id: node["id"]) do |div|
|
50
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
50
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
51
51
|
node.elements.each do |e|
|
52
|
-
parse(e, div) unless e.name == "title"
|
52
|
+
parse(e, div) unless e.name == "fmt-title"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -59,9 +59,9 @@ module IsoDoc
|
|
59
59
|
|
60
60
|
def terms_defs(node, out)
|
61
61
|
out.div **attr_code(id: node["id"]) do |div|
|
62
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
62
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
63
63
|
node.elements.each do |e|
|
64
|
-
parse(e, div) unless %w{title source}.include? e.name
|
64
|
+
parse(e, div) unless %w{fmt-title source}.include? e.name
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -73,28 +73,25 @@ module IsoDoc
|
|
73
73
|
|
74
74
|
def symbols_abbrevs(node, out)
|
75
75
|
out.div **attr_code(id: node["id"], class: "Symbols") do |div|
|
76
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
76
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
77
77
|
node.elements.each do |e|
|
78
|
-
parse(e, div) unless e.name == "title"
|
78
|
+
parse(e, div) unless e.name == "fmt-title"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
# subclause
|
84
84
|
def symbols_parse(isoxml, out)
|
85
|
-
isoxml.at(ns("./title")) or
|
86
|
-
#isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
|
87
|
-
isoxml.add_first_child "<title>#{@i18n.symbols}</title>"
|
88
85
|
clause_parse(isoxml, out)
|
89
86
|
end
|
90
87
|
|
91
88
|
def introduction(clause, out)
|
92
89
|
page_break(out)
|
93
90
|
out.div class: "Section3", id: clause["id"] do |div|
|
94
|
-
clause_name(clause, clause.at(ns("./title")), div,
|
91
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div,
|
95
92
|
{ class: "IntroTitle" })
|
96
93
|
clause.elements.each do |e|
|
97
|
-
parse(e, div) unless e.name == "title"
|
94
|
+
parse(e, div) unless e.name == "fmt-title"
|
98
95
|
end
|
99
96
|
end
|
100
97
|
end
|
@@ -102,9 +99,9 @@ module IsoDoc
|
|
102
99
|
def foreword(clause, out)
|
103
100
|
page_break(out)
|
104
101
|
out.div **attr_code(id: clause["id"]) do |s|
|
105
|
-
clause_name(clause, clause.at(ns("./title"))
|
102
|
+
clause_name(clause, clause.at(ns("./fmt-title")), s,
|
106
103
|
{ class: "ForewordTitle" })
|
107
|
-
clause.elements.each { |e| parse(e, s) unless e.name == "title" }
|
104
|
+
clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
|
108
105
|
end
|
109
106
|
end
|
110
107
|
|
@@ -112,9 +109,9 @@ module IsoDoc
|
|
112
109
|
title_attr = { class: "IntroTitle" }
|
113
110
|
page_break(out)
|
114
111
|
out.div class: "Section3", id: clause["id"] do |div|
|
115
|
-
clause_name(clause, clause.at(ns("./title")), div, title_attr)
|
112
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div, title_attr)
|
116
113
|
clause.elements.each do |e|
|
117
|
-
parse(e, div) unless e.name == "title"
|
114
|
+
parse(e, div) unless e.name == "fmt-title"
|
118
115
|
end
|
119
116
|
end
|
120
117
|
end
|
@@ -122,9 +119,9 @@ module IsoDoc
|
|
122
119
|
def abstract(clause, out)
|
123
120
|
page_break(out)
|
124
121
|
out.div **attr_code(id: clause["id"]) do |s|
|
125
|
-
clause_name(clause, clause.at(ns("./title")), s,
|
122
|
+
clause_name(clause, clause.at(ns("./fmt-title")), s,
|
126
123
|
{ class: "AbstractTitle" })
|
127
|
-
clause.elements.each { |e| parse(e, s) unless e.name == "title" }
|
124
|
+
clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
|
128
125
|
end
|
129
126
|
end
|
130
127
|
|
@@ -144,10 +141,10 @@ module IsoDoc
|
|
144
141
|
def preface_normal(clause, out)
|
145
142
|
page_break(out)
|
146
143
|
out.div **attr_code(preface_attrs(clause)) do |div|
|
147
|
-
clause_name(clause, clause.at(ns("./title")), div,
|
144
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div,
|
148
145
|
{ class: "IntroTitle" })
|
149
146
|
clause.elements.each do |e|
|
150
|
-
parse(e, div) unless e.name == "title"
|
147
|
+
parse(e, div) unless e.name == "fmt-title"
|
151
148
|
end
|
152
149
|
end
|
153
150
|
end
|
@@ -156,10 +153,10 @@ module IsoDoc
|
|
156
153
|
@bare and return
|
157
154
|
page_break(out)
|
158
155
|
out.div **attr_code(preface_attrs(clause)) do |div|
|
159
|
-
clause_name(clause, clause.at(ns("./title")), div,
|
156
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div,
|
160
157
|
{ class: "IntroTitle" })
|
161
158
|
clause.elements.each do |e|
|
162
|
-
parse(e, div) unless e.name == "title"
|
159
|
+
parse(e, div) unless e.name == "fmt-title"
|
163
160
|
end
|
164
161
|
end
|
165
162
|
end
|
@@ -168,10 +165,10 @@ module IsoDoc
|
|
168
165
|
@seen_colophon or page_break(out)
|
169
166
|
@seen_colophon = true
|
170
167
|
out.div class: "Section3", id: node["id"] do |div|
|
171
|
-
clause_name(node, node.at(ns("./title")), div,
|
168
|
+
clause_name(node, node.at(ns("./fmt-title")), div,
|
172
169
|
{ class: "IntroTitle" })
|
173
170
|
node.elements.each do |e|
|
174
|
-
parse(e, div) unless e.name == "title"
|
171
|
+
parse(e, div) unless e.name == "fmt-title"
|
175
172
|
end
|
176
173
|
end
|
177
174
|
end
|
@@ -18,18 +18,24 @@ module IsoDoc
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def sections_names
|
22
|
+
%w[clause annex terms references definitions
|
23
|
+
acknowledgements introduction abstract foreword appendix]
|
24
|
+
end
|
25
|
+
|
21
26
|
def freestanding_title(node, out)
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
# node.parent.at(ns("./fmt-title[@source = '#{node['id']}']")) and
|
28
|
+
# return # this title is already being rendered as fmt-title
|
29
|
+
# For testing convenience, let's just go by parent
|
30
|
+
sections_names.include?(node.parent.name) and return
|
31
|
+
parents = node.ancestors(sections_names.join(", "))
|
25
32
|
clause_parse_title(parents.empty? ? node : parents.first,
|
26
33
|
out, node, out)
|
27
34
|
end
|
28
35
|
|
29
36
|
# used for subclauses
|
30
37
|
def clause_parse_title(node, div, title, out, header_class = {})
|
31
|
-
|
32
|
-
|
38
|
+
title.nil? and return
|
33
39
|
if node["inline-header"] == "true"
|
34
40
|
inline_header_title(out, node, title)
|
35
41
|
else
|
@@ -46,9 +52,7 @@ module IsoDoc
|
|
46
52
|
end
|
47
53
|
|
48
54
|
def clause_title_depth(node, title)
|
49
|
-
depth = node.ancestors("
|
50
|
-
"definitions, acknowledgements, introduction, " \
|
51
|
-
"foreword").size + 1
|
55
|
+
depth = node.ancestors(sections_names.join(", ")).size + 1
|
52
56
|
depth = title["depth"] if title && title["depth"]
|
53
57
|
depth
|
54
58
|
end
|
@@ -63,12 +67,12 @@ module IsoDoc
|
|
63
67
|
end
|
64
68
|
|
65
69
|
# top level clause names
|
66
|
-
def clause_name(
|
70
|
+
def clause_name(_node, title, div, header_class)
|
67
71
|
header_class = {} if header_class.nil?
|
68
72
|
div.h1 **attr_code(header_class) do |h1|
|
69
73
|
if title.is_a?(String) then h1 << title
|
70
|
-
|
71
|
-
title
|
74
|
+
elsif title
|
75
|
+
children_parse(title, h1)
|
72
76
|
clause_parse_subtitle(title, h1)
|
73
77
|
end
|
74
78
|
end
|
@@ -76,8 +80,7 @@ module IsoDoc
|
|
76
80
|
end
|
77
81
|
|
78
82
|
def annex_name(_annex, name, div)
|
79
|
-
|
80
|
-
|
83
|
+
name.nil? and return
|
81
84
|
div.h1 class: "Annex" do |t|
|
82
85
|
name.children.each { |c2| parse(c2, t) }
|
83
86
|
clause_parse_subtitle(name, t)
|
@@ -2,7 +2,7 @@ module IsoDoc
|
|
2
2
|
module Function
|
3
3
|
module Table
|
4
4
|
def table_title_parse(node, out)
|
5
|
-
name = node.at(ns("./name")) or return
|
5
|
+
name = node.at(ns("./fmt-name")) or return
|
6
6
|
out.p class: "TableTitle", style: "text-align:center;" do |p|
|
7
7
|
name&.children&.each { |n| parse(n, p) }
|
8
8
|
end
|
@@ -112,12 +112,12 @@ module IsoDoc
|
|
112
112
|
!header && cell.name == "th" and
|
113
113
|
scope = (cell["rowspan"] ? "rowgroup" : "row")
|
114
114
|
{ rowspan: cell["rowspan"], colspan: cell["colspan"],
|
115
|
-
style: style.
|
115
|
+
style: style.delete("\n"), scope: scope, class: cell["class"] }
|
116
116
|
end
|
117
117
|
|
118
118
|
def make_tr_attr_style(row, rowmax, totalrows, _header, bordered)
|
119
119
|
bordered or return ""
|
120
|
-
<<~STYLE.
|
120
|
+
<<~STYLE.delete("\n")
|
121
121
|
border-top:#{row.zero? ? "#{SW} 1.5pt;" : 'none;'}
|
122
122
|
border-bottom:#{SW} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;
|
123
123
|
STYLE
|
@@ -28,30 +28,27 @@ module IsoDoc
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
33
|
-
first.children.each { |n| parse(n, para) }
|
34
|
-
node.elements.drop(1).each { |n| parse(n, div) }
|
35
|
-
else
|
36
|
-
node.elements.each { |n| parse(n, div) }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def termnote_delim
|
41
|
-
l10n(": ")
|
31
|
+
def termnote_p_class
|
32
|
+
nil
|
42
33
|
end
|
43
34
|
|
44
35
|
def termnote_parse(node, out)
|
45
|
-
|
36
|
+
para = block_body_first_elem(node)
|
46
37
|
out.div **note_attrs(node) do |div|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
termnote_parse1(node, para, div)
|
39
|
+
para&.xpath("./following-sibling::*")&.each { |n| parse(n, div) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def termnote_parse1(node, para, div)
|
44
|
+
div.p **attr_code(class: termnote_p_class) do |p|
|
45
|
+
name = node.at(ns("./fmt-name")) and
|
46
|
+
p.span class: "termnote_label" do |s|
|
47
|
+
children_parse(name, s)
|
51
48
|
end
|
52
|
-
|
53
|
-
end
|
49
|
+
para&.name == "p" and children_parse(para, p)
|
54
50
|
end
|
51
|
+
para&.name != "p" and parse(para, div)
|
55
52
|
end
|
56
53
|
|
57
54
|
def termref_parse(node, out)
|
@@ -60,12 +57,16 @@ module IsoDoc
|
|
60
57
|
end
|
61
58
|
end
|
62
59
|
|
60
|
+
def termdomain_parse(node, out)
|
61
|
+
node["hidden"] == "true" and return
|
62
|
+
node.children.each { |n| parse(n, out) }
|
63
|
+
end
|
64
|
+
|
63
65
|
def termdef_parse(node, out)
|
64
|
-
name = node
|
66
|
+
name = node.at(ns("./fmt-name"))&.remove
|
65
67
|
out.p class: "TermNum", id: node["id"] do |p|
|
66
68
|
name&.children&.each { |n| parse(n, p) }
|
67
69
|
end
|
68
|
-
set_termdomain("")
|
69
70
|
node.children.each { |n| parse(n, out) }
|
70
71
|
end
|
71
72
|
|
@@ -4,10 +4,6 @@ require "pathname"
|
|
4
4
|
module IsoDoc
|
5
5
|
module Function
|
6
6
|
module ToWordHtml
|
7
|
-
def set_termdomain(termdomain)
|
8
|
-
@termdomain = termdomain
|
9
|
-
end
|
10
|
-
|
11
7
|
def note?
|
12
8
|
@note
|
13
9
|
end
|
@@ -222,7 +218,7 @@ module IsoDoc
|
|
222
218
|
when "preferred" then term_parse(node, out)
|
223
219
|
when "admitted" then admitted_term_parse(node, out)
|
224
220
|
when "deprecates" then deprecated_term_parse(node, out)
|
225
|
-
when "domain" then
|
221
|
+
when "domain" then termdomain_parse(node, out)
|
226
222
|
when "definition" then definition_parse(node, out)
|
227
223
|
when "termsource" then termref_parse(node, out)
|
228
224
|
when "modification" then modification_parse(node, out)
|
@@ -261,9 +257,16 @@ module IsoDoc
|
|
261
257
|
when "location" then location_parse(node, out)
|
262
258
|
when "cross-align" then cross_align_parse(node, out)
|
263
259
|
when "columnbreak" then columnbreak_parse(node, out)
|
260
|
+
when "attribution" then attribution_parse(node, out)
|
261
|
+
when "author" then author_parse(node, out)
|
264
262
|
when "ruby" then ruby_parse(node, out)
|
265
263
|
when "rt" then rt_parse(node, out)
|
266
264
|
when "rb" then rb_parse(node, out)
|
265
|
+
when "semx" then semx_parse(node, out)
|
266
|
+
when "name" then name_parse(node, out)
|
267
|
+
when "fmt-xref-label" then xref_label_parse(node, out)
|
268
|
+
when "fmt-name" then fmt_name_parse(node, out)
|
269
|
+
when "floating-title" then floating_title_parse(node, out)
|
267
270
|
else error_parse(node, out)
|
268
271
|
end
|
269
272
|
end
|
@@ -24,6 +24,7 @@ module IsoDoc
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# Move to Presentation XML, as <fmt-footnote>: it's a footnote body
|
27
28
|
def make_table_footnote_text(node, fnid, fnref)
|
28
29
|
attrs = { id: "fn:#{fnid}" }
|
29
30
|
noko do |xml|
|
@@ -68,7 +69,7 @@ module IsoDoc
|
|
68
69
|
|
69
70
|
def footnote_parse(node, out)
|
70
71
|
return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
|
71
|
-
!node.ancestors.map(&:name).include?("name")
|
72
|
+
!node.ancestors.map(&:name).include?("fmt-name")
|
72
73
|
|
73
74
|
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
74
75
|
attrs = { class: "FootnoteRef", href: "#fn:#{fn}" }
|
@@ -15,10 +15,6 @@ module IsoDoc
|
|
15
15
|
end.join("\n")
|
16
16
|
end
|
17
17
|
|
18
|
-
def preprocess_xslt(docxml)
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
18
|
def make_body1(body, _docxml)
|
23
19
|
return if @bare
|
24
20
|
|
@@ -78,7 +74,7 @@ module IsoDoc
|
|
78
74
|
end
|
79
75
|
|
80
76
|
def sourcecode_parse(node, out)
|
81
|
-
name = node.at(ns("./name"))
|
77
|
+
name = node.at(ns("./fmt-name"))
|
82
78
|
tag = node.at(ns(".//sourcecode | .//table")) ? "div" : "pre"
|
83
79
|
attr = sourcecode_attrs(node).merge(class: "sourcecode")
|
84
80
|
out.send tag, **attr do |div|
|
data/lib/isodoc/init.rb
CHANGED
@@ -140,5 +140,36 @@ module IsoDoc
|
|
140
140
|
def agency?(text)
|
141
141
|
self.class::AGENCIES.include?(text)
|
142
142
|
end
|
143
|
+
|
144
|
+
def docid_l10n(text)
|
145
|
+
text.nil? and return text
|
146
|
+
@i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
|
147
|
+
x = Nokogiri::XML::DocumentFragment.parse(text)
|
148
|
+
(x.xpath(".//text()") - x.xpath(".//fn//text()")).each do |n|
|
149
|
+
n.replace(n.text.gsub(/ /, " "))
|
150
|
+
end
|
151
|
+
to_xml(x)
|
152
|
+
end
|
153
|
+
|
154
|
+
def docid_prefix(prefix, docid)
|
155
|
+
docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
|
156
|
+
!/^#{prefix}\b/.match(docid)
|
157
|
+
docid_l10n(docid)
|
158
|
+
end
|
159
|
+
|
160
|
+
def omit_docid_prefix(prefix)
|
161
|
+
prefix.nil? || prefix.empty? and return true
|
162
|
+
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
|
163
|
+
.include? prefix
|
164
|
+
end
|
165
|
+
|
166
|
+
def connectives_spans(text)
|
167
|
+
text.gsub("<conn>", "<span class='fmt-conn'>")
|
168
|
+
.gsub("</conn>", "</span>")
|
169
|
+
.gsub("<enum-comma>", "<span class='fmt-enum-comma'>")
|
170
|
+
.gsub("</enum-comma>", "</span>")
|
171
|
+
.gsub("<comma>", "<span class='fmt-comma'>")
|
172
|
+
.gsub("</comma>", "</span>")
|
173
|
+
end
|
143
174
|
end
|
144
175
|
end
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -13,6 +13,15 @@ module IsoDoc
|
|
13
13
|
@i18n.l10n(expr, lang, script, locale)
|
14
14
|
end
|
15
15
|
|
16
|
+
def connectives_strip(text)
|
17
|
+
text.gsub("<conn>", "")
|
18
|
+
.gsub("</conn>", "")
|
19
|
+
.gsub("<enum-comma>", "")
|
20
|
+
.gsub("</enum-comma>", "")
|
21
|
+
.gsub("<comma>", "")
|
22
|
+
.gsub("</comma>", "")
|
23
|
+
end
|
24
|
+
|
16
25
|
def initialize(lang, script, locale, i18n, fonts_options = {})
|
17
26
|
@metadata = { lang:, script: }
|
18
27
|
DATETYPES.each { |w| @metadata["#{w.tr('-', '_')}date".to_sym] = "XXX" }
|
@@ -79,7 +79,7 @@ module IsoDoc
|
|
79
79
|
def agency(xml)
|
80
80
|
agency, publisher = agency1(xml)
|
81
81
|
set(:agency, agency.sub(%r{/$}, ""))
|
82
|
-
set(:publisher, @i18n.boolean_conj(publisher, "and"))
|
82
|
+
set(:publisher, connectives_strip(@i18n.boolean_conj(publisher, "and")))
|
83
83
|
agency_addr(xml)
|
84
84
|
end
|
85
85
|
|