isodoc 2.4.4 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +0 -1
- data/lib/isodoc/base_style/all.css +4 -0
- data/lib/isodoc/base_style/reset.css +4 -0
- data/lib/isodoc/base_style/reset.scss +6 -0
- data/lib/isodoc/convert.rb +3 -6
- data/lib/isodoc/function/blocks.rb +2 -14
- data/lib/isodoc/function/blocks_example_note.rb +5 -5
- data/lib/isodoc/function/cleanup.rb +3 -3
- data/lib/isodoc/function/lists.rb +1 -1
- data/lib/isodoc/function/references.rb +1 -1
- data/lib/isodoc/function/section.rb +22 -9
- data/lib/isodoc/function/section_titles.rb +10 -10
- data/lib/isodoc/function/table.rb +12 -9
- data/lib/isodoc/function/to_word_html.rb +10 -8
- data/lib/isodoc/html_function/postprocess_cover.rb +19 -10
- data/lib/isodoc/init.rb +9 -0
- data/lib/isodoc/metadata.rb +12 -4
- data/lib/isodoc/metadata_contributor.rb +7 -9
- data/lib/isodoc/presentation_function/block.rb +8 -0
- data/lib/isodoc/presentation_function/erefs.rb +4 -3
- data/lib/isodoc/presentation_function/image.rb +2 -2
- data/lib/isodoc/presentation_function/refs.rb +11 -6
- data/lib/isodoc/presentation_function/section.rb +5 -3
- data/lib/isodoc/presentation_function/xrefs.rb +1 -1
- data/lib/isodoc/presentation_xml_convert.rb +10 -3
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +4 -12
- data/lib/isodoc/word_function/table.rb +8 -4
- data/lib/isodoc/xref/xref_gen.rb +1 -3
- data/lib/isodoc/xref/xref_gen_seq.rb +9 -9
- data/lib/isodoc/xref/xref_sect_gen.rb +5 -4
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
- data/lib/isodoc-yaml/i18n-de.yaml +1 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15d6f1ca680a6bb801c444655ba27e347ca04a671c207b9a74ad4c6388596394
|
4
|
+
data.tar.gz: 02e6caa0ae2463bd2966ee14a9837c0d1b1b4cfac77596380bbb3856979ee142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 857b7630d0a1146e5070b3ced33eb99b40089cf114181b6519cd1e26a5c17fc8b1e36dfe59ea115055fb2f8cbf901c57b7ad730fe39878e0cf589201eb06222a
|
7
|
+
data.tar.gz: 4ca7278d7571fc4aa64fa6443a373d77d352ffe64b79086ef142aad1260a25e57589023707a153bb54cae60bd4e441d2ed116a33f18db2905907b61b5c14875f
|
data/isodoc.gemspec
CHANGED
@@ -40,7 +40,6 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_dependency "metanorma-utils", "~> 1.4.5"
|
41
41
|
spec.add_dependency "mn2pdf"
|
42
42
|
spec.add_dependency "mn-requirements", "~> 0.3.1"
|
43
|
-
spec.add_dependency "relaton-cli"
|
44
43
|
spec.add_dependency "relaton-render", "~> 0.5.2"
|
45
44
|
spec.add_dependency "roman-numerals"
|
46
45
|
spec.add_dependency "rouge", "~> 4.0"
|
data/lib/isodoc/convert.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "isodoc/common"
|
4
2
|
require "fileutils"
|
5
3
|
require "tempfile"
|
@@ -161,10 +159,8 @@ module IsoDoc
|
|
161
159
|
end
|
162
160
|
|
163
161
|
def init_toc(options)
|
164
|
-
@
|
165
|
-
@wordToClevels = 2
|
166
|
-
@htmlToClevels = (options[:htmltoclevels] || options[:toclevels]).to_i
|
167
|
-
@htmlToClevels = 2 if @htmlToClevels.zero?
|
162
|
+
@htmlToClevels = 2
|
163
|
+
@wordToClevels = 2
|
168
164
|
@tocfigures = options[:tocfigures]
|
169
165
|
@toctables = options[:toctables]
|
170
166
|
@tocrecommendations = options[:tocrecommendations]
|
@@ -218,6 +214,7 @@ module IsoDoc
|
|
218
214
|
convert_i18n_init(docxml)
|
219
215
|
metadata_init(@lang, @script, @locale, @i18n)
|
220
216
|
xref_init(@lang, @script, self, @i18n, { locale: @locale })
|
217
|
+
toc_init(docxml)
|
221
218
|
[docxml, filename, dir]
|
222
219
|
end
|
223
220
|
|
@@ -10,8 +10,7 @@ module IsoDoc
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def figure_name_parse(_node, div, name)
|
13
|
-
|
14
|
-
|
13
|
+
name.nil? and return
|
15
14
|
div.p class: "FigureTitle", style: "text-align:center;" do |p|
|
16
15
|
name.children.each { |n| parse(n, p) }
|
17
16
|
end
|
@@ -110,16 +109,6 @@ module IsoDoc
|
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
def formula_where(dlist, out)
|
114
|
-
return unless dlist
|
115
|
-
|
116
|
-
out.p style: "page-break-after:avoid;" do |p|
|
117
|
-
p << @i18n.where
|
118
|
-
end
|
119
|
-
parse(dlist, out)
|
120
|
-
out.parent.at("./dl")["class"] = "formula_dl"
|
121
|
-
end
|
122
|
-
|
123
112
|
def formula_parse1(node, out)
|
124
113
|
out.div **attr_code(class: "formula") do |div|
|
125
114
|
div.p do |_p|
|
@@ -139,9 +128,8 @@ module IsoDoc
|
|
139
128
|
def formula_parse(node, out)
|
140
129
|
out.div **formula_attrs(node) do |div|
|
141
130
|
formula_parse1(node, div)
|
142
|
-
formula_where(node.at(ns("./dl")), div)
|
143
131
|
node.children.each do |n|
|
144
|
-
next if %w(stem
|
132
|
+
next if %w(stem name).include? n.name
|
145
133
|
|
146
134
|
parse(n, div)
|
147
135
|
end
|
@@ -4,7 +4,7 @@ module IsoDoc
|
|
4
4
|
def example_label(_node, div, name)
|
5
5
|
return if name.nil?
|
6
6
|
|
7
|
-
div.p
|
7
|
+
div.p class: "example-title" do |_p|
|
8
8
|
name.children.each { |n| parse(n, div) }
|
9
9
|
end
|
10
10
|
end
|
@@ -29,7 +29,7 @@ module IsoDoc
|
|
29
29
|
|
30
30
|
def example_table_attr(node)
|
31
31
|
attr_code(id: node["id"], class: "example",
|
32
|
-
style: "border-collapse:collapse;border-spacing:0;"\
|
32
|
+
style: "border-collapse:collapse;border-spacing:0;" \
|
33
33
|
"#{keep_style(node)}")
|
34
34
|
end
|
35
35
|
|
@@ -60,7 +60,7 @@ module IsoDoc
|
|
60
60
|
def note_p_parse(node, div)
|
61
61
|
name = node&.at(ns("./name"))&.remove
|
62
62
|
div.p do |p|
|
63
|
-
name and p.span
|
63
|
+
name and p.span class: "note_label" do |s|
|
64
64
|
name.children.each { |n| parse(n, s) }
|
65
65
|
s << note_delim
|
66
66
|
end
|
@@ -73,7 +73,7 @@ module IsoDoc
|
|
73
73
|
def note_parse1(node, div)
|
74
74
|
name = node&.at(ns("./name"))&.remove
|
75
75
|
name and div.p do |p|
|
76
|
-
p.span
|
76
|
+
p.span class: "note_label" do |s|
|
77
77
|
name.children.each { |n| parse(n, s) }
|
78
78
|
s << note_delim
|
79
79
|
end
|
@@ -117,7 +117,7 @@ module IsoDoc
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def admonition_name_parse(_node, div, name)
|
120
|
-
div.p
|
120
|
+
div.p class: "AdmonitionTitle", style: "text-align:center;" do |p|
|
121
121
|
name.children.each { |n| parse(n, p) }
|
122
122
|
end
|
123
123
|
end
|
@@ -88,7 +88,7 @@ module IsoDoc
|
|
88
88
|
end
|
89
89
|
|
90
90
|
FIGURE_WITH_FOOTNOTES =
|
91
|
-
"//div[@class = 'figure'][descendant::aside]"\
|
91
|
+
"//div[@class = 'figure'][descendant::aside]" \
|
92
92
|
"[not(descendant::div[@class = 'figure'])]".freeze
|
93
93
|
|
94
94
|
def figure_aside_process(elem, aside, key)
|
@@ -159,7 +159,7 @@ module IsoDoc
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def table_footnote_cleanup_propagate(docxml)
|
162
|
-
docxml.xpath("//p[not(self::*[@class])]"\
|
162
|
+
docxml.xpath("//p[not(self::*[@class])]" \
|
163
163
|
"[ancestor::*[@class = 'TableFootnote']]").each do |p|
|
164
164
|
p["class"] = "TableFootnote"
|
165
165
|
end
|
@@ -194,7 +194,7 @@ module IsoDoc
|
|
194
194
|
end
|
195
195
|
|
196
196
|
def table_note_cleanup(docxml)
|
197
|
-
docxml.xpath("//table[div[@class = 'Note' or "\
|
197
|
+
docxml.xpath("//table[div[@class = 'Note' or " \
|
198
198
|
"@class = 'TableFootnote']]").each do |t|
|
199
199
|
tfoot = table_get_or_make_tfoot(t)
|
200
200
|
insert_here = new_fullcolspan_row(t, tfoot)
|
@@ -153,7 +153,7 @@ module IsoDoc
|
|
153
153
|
return num
|
154
154
|
out.div do |div|
|
155
155
|
num += 1
|
156
|
-
clause_name(
|
156
|
+
clause_name(f, f.at(ns("./title")), div, nil)
|
157
157
|
if f.name == "clause"
|
158
158
|
f.elements.each { |e| parse(e, div) unless e.name == "title" }
|
159
159
|
else biblio_list(f, div, false)
|
@@ -20,7 +20,7 @@ module IsoDoc
|
|
20
20
|
def clause(isoxml, out)
|
21
21
|
isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
|
22
22
|
out.div **attr_code(clause_attrs(c)) do |s|
|
23
|
-
clause_name(
|
23
|
+
clause_name(c, c&.at(ns("./title")), s, nil)
|
24
24
|
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
25
25
|
parse(c1, s)
|
26
26
|
end
|
@@ -50,7 +50,7 @@ module IsoDoc
|
|
50
50
|
f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
|
51
51
|
out.div **attr_code(id: f["id"]) do |div|
|
52
52
|
num = num + 1
|
53
|
-
clause_name(
|
53
|
+
clause_name(f, f&.at(ns("./title")), div, nil)
|
54
54
|
f.elements.each do |e|
|
55
55
|
parse(e, div) unless e.name == "title"
|
56
56
|
end
|
@@ -65,7 +65,7 @@ module IsoDoc
|
|
65
65
|
f = isoxml.at(ns(TERM_CLAUSE)) or return num
|
66
66
|
out.div **attr_code(id: f["id"]) do |div|
|
67
67
|
num = num + 1
|
68
|
-
clause_name(
|
68
|
+
clause_name(f, f&.at(ns("./title")), div, nil)
|
69
69
|
f.elements.each do |e|
|
70
70
|
parse(e, div) unless %w{title source}.include? e.name
|
71
71
|
end
|
@@ -82,7 +82,7 @@ module IsoDoc
|
|
82
82
|
f = isoxml.at(ns("//sections/definitions")) or return num
|
83
83
|
out.div **attr_code(id: f["id"], class: "Symbols") do |div|
|
84
84
|
num = num + 1
|
85
|
-
clause_name(
|
85
|
+
clause_name(f, f.at(ns("./title")), div, nil)
|
86
86
|
f.elements.each do |e|
|
87
87
|
parse(e, div) unless e.name == "title"
|
88
88
|
end
|
@@ -101,7 +101,7 @@ module IsoDoc
|
|
101
101
|
f = isoxml.at(ns("//introduction")) || return
|
102
102
|
page_break(out)
|
103
103
|
out.div class: "Section3", id: f["id"] do |div|
|
104
|
-
clause_name(
|
104
|
+
clause_name(f, f.at(ns("./title")), div, { class: "IntroTitle" })
|
105
105
|
f.elements.each do |e|
|
106
106
|
parse(e, div) unless e.name == "title"
|
107
107
|
end
|
@@ -112,7 +112,7 @@ module IsoDoc
|
|
112
112
|
f = isoxml.at(ns("//foreword")) || return
|
113
113
|
page_break(out)
|
114
114
|
out.div **attr_code(id: f["id"]) do |s|
|
115
|
-
clause_name(
|
115
|
+
clause_name(f, f.at(ns("./title")) || @i18n.foreword, s,
|
116
116
|
{ class: "ForewordTitle" })
|
117
117
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
118
118
|
end
|
@@ -123,7 +123,7 @@ module IsoDoc
|
|
123
123
|
title_attr = { class: "IntroTitle" }
|
124
124
|
page_break(out)
|
125
125
|
out.div class: "Section3", id: f["id"] do |div|
|
126
|
-
clause_name(
|
126
|
+
clause_name(f, f&.at(ns("./title")), div, title_attr)
|
127
127
|
f.elements.each do |e|
|
128
128
|
parse(e, div) unless e.name == "title"
|
129
129
|
end
|
@@ -134,7 +134,7 @@ module IsoDoc
|
|
134
134
|
f = isoxml.at(ns("//preface/abstract")) || return
|
135
135
|
page_break(out)
|
136
136
|
out.div **attr_code(id: f["id"]) do |s|
|
137
|
-
clause_name(
|
137
|
+
clause_name(f, f.at(ns("./title")), s, { class: "AbstractTitle" })
|
138
138
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
139
139
|
end
|
140
140
|
end
|
@@ -144,7 +144,20 @@ module IsoDoc
|
|
144
144
|
"//preface/definitions | //preface/terms")).each do |f|
|
145
145
|
page_break(out)
|
146
146
|
out.div class: "Section3", id: f["id"] do |div|
|
147
|
-
clause_name(
|
147
|
+
clause_name(f, f&.at(ns("./title")), div, { class: "IntroTitle" })
|
148
|
+
f.elements.each do |e|
|
149
|
+
parse(e, div) unless e.name == "title"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def colophon(isoxml, out)
|
156
|
+
isoxml.at(ns("//colophon")) or return
|
157
|
+
page_break(out)
|
158
|
+
isoxml.xpath(ns("//colophon/clause")).each do |f|
|
159
|
+
out.div class: "Section3", id: f["id"] do |div|
|
160
|
+
clause_name(f, f&.at(ns("./title")), div, { class: "IntroTitle" })
|
148
161
|
f.elements.each do |e|
|
149
162
|
parse(e, div) unless e.name == "title"
|
150
163
|
end
|
@@ -10,7 +10,7 @@ module IsoDoc
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def inline_header_title(out, node, title)
|
13
|
-
out.span
|
13
|
+
out.span class: "zzMoveToFollowing" do |s|
|
14
14
|
s.b do |b|
|
15
15
|
title&.children&.each { |c2| parse(c2, b) }
|
16
16
|
clausedelimspace(node, out) if /\S/.match?(title&.text)
|
@@ -38,15 +38,15 @@ module IsoDoc
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def clause_title_depth(node, title)
|
41
|
-
depth = node.ancestors("clause, annex, terms, references, "\
|
42
|
-
"definitions, acknowledgements, introduction, "\
|
41
|
+
depth = node.ancestors("clause, annex, terms, references, " \
|
42
|
+
"definitions, acknowledgements, introduction, " \
|
43
43
|
"foreword").size + 1
|
44
44
|
depth = title["depth"] if title && title["depth"]
|
45
45
|
depth
|
46
46
|
end
|
47
47
|
|
48
48
|
def clause_parse_subtitle(title, heading)
|
49
|
-
if var = title&.at("./following-sibling::xmlns:variant-title"\
|
49
|
+
if var = title&.at("./following-sibling::xmlns:variant-title" \
|
50
50
|
"[@type = 'sub']")&.remove
|
51
51
|
heading.br nil
|
52
52
|
heading.br nil
|
@@ -55,8 +55,8 @@ module IsoDoc
|
|
55
55
|
end
|
56
56
|
|
57
57
|
# top level clause names
|
58
|
-
def clause_name(
|
59
|
-
preceding_floating_titles(
|
58
|
+
def clause_name(node, title, div, header_class)
|
59
|
+
preceding_floating_titles(node, div)
|
60
60
|
header_class = {} if header_class.nil?
|
61
61
|
div.h1 **attr_code(header_class) do |h1|
|
62
62
|
if title.is_a?(String) then h1 << title
|
@@ -72,7 +72,7 @@ module IsoDoc
|
|
72
72
|
preceding_floating_titles(name, div)
|
73
73
|
return if name.nil?
|
74
74
|
|
75
|
-
div.h1
|
75
|
+
div.h1 class: "Annex" do |t|
|
76
76
|
name.children.each { |c2| parse(c2, t) }
|
77
77
|
clause_parse_subtitle(name, t)
|
78
78
|
end
|
@@ -85,10 +85,10 @@ module IsoDoc
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
def preceding_floating_titles(
|
89
|
-
return if
|
88
|
+
def preceding_floating_titles(node, div)
|
89
|
+
return if node.nil?
|
90
90
|
|
91
|
-
out =
|
91
|
+
out = node.xpath("./preceding-sibling::*")
|
92
92
|
.reverse.each_with_object([]) do |p, m|
|
93
93
|
break m unless p.name == "p"
|
94
94
|
|
@@ -3,7 +3,7 @@ module IsoDoc
|
|
3
3
|
module Table
|
4
4
|
def table_title_parse(node, out)
|
5
5
|
name = node.at(ns("./name")) or return
|
6
|
-
out.p
|
6
|
+
out.p class: "TableTitle", style: "text-align:center;" do |p|
|
7
7
|
name&.children&.each { |n| parse(n, p) }
|
8
8
|
end
|
9
9
|
end
|
@@ -56,7 +56,7 @@ module IsoDoc
|
|
56
56
|
return unless node["summary"]
|
57
57
|
|
58
58
|
table.caption do |c|
|
59
|
-
c.span
|
59
|
+
c.span style: "display:none" do |s|
|
60
60
|
s << node["summary"]
|
61
61
|
end
|
62
62
|
end
|
@@ -66,7 +66,7 @@ module IsoDoc
|
|
66
66
|
colgroup = node.at(ns("./colgroup")) or return
|
67
67
|
table.colgroup do |cg|
|
68
68
|
colgroup.xpath(ns("./col")).each do |c|
|
69
|
-
cg.col
|
69
|
+
cg.col style: "width: #{c['width']};"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -75,16 +75,19 @@ module IsoDoc
|
|
75
75
|
@in_table = true
|
76
76
|
table_title_parse(node, out)
|
77
77
|
out.table **table_attrs(node) do |t|
|
78
|
-
|
79
|
-
colgroup(node, t)
|
80
|
-
thead_parse(node, t)
|
81
|
-
tbody_parse(node, t)
|
82
|
-
tfoot_parse(node, t)
|
78
|
+
table_parse_core(node, t)
|
83
79
|
(dl = node.at(ns("./dl"))) && parse(dl, out)
|
84
80
|
node.xpath(ns("./note")).each { |n| parse(n, out) }
|
85
81
|
end
|
86
82
|
@in_table = false
|
87
|
-
|
83
|
+
end
|
84
|
+
|
85
|
+
def table_parse_core(node, out)
|
86
|
+
tcaption(node, out)
|
87
|
+
colgroup(node, out)
|
88
|
+
thead_parse(node, out)
|
89
|
+
tbody_parse(node, out)
|
90
|
+
tfoot_parse(node, out)
|
88
91
|
end
|
89
92
|
|
90
93
|
SW = "solid windowtext".freeze
|
@@ -69,21 +69,21 @@ module IsoDoc
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def make_body1(body, _docxml)
|
72
|
-
body.div
|
72
|
+
body.div class: "title-section" do |div1|
|
73
73
|
div1.p { |p| p << " " } # placeholder
|
74
74
|
end
|
75
75
|
section_break(body)
|
76
76
|
end
|
77
77
|
|
78
78
|
def make_body2(body, _docxml)
|
79
|
-
body.div
|
79
|
+
body.div class: "prefatory-section" do |div2|
|
80
80
|
div2.p { |p| p << " " } # placeholder
|
81
81
|
end
|
82
82
|
section_break(body)
|
83
83
|
end
|
84
84
|
|
85
85
|
def make_body3(body, docxml)
|
86
|
-
body.div
|
86
|
+
body.div class: "main-section" do |div3|
|
87
87
|
boilerplate docxml, div3
|
88
88
|
preface_block docxml, div3
|
89
89
|
abstract docxml, div3
|
@@ -112,26 +112,28 @@ module IsoDoc
|
|
112
112
|
@meta.url isoxml, out
|
113
113
|
@meta.keywords isoxml, out
|
114
114
|
@meta.note isoxml, out
|
115
|
+
@meta.presentation isoxml, out
|
115
116
|
@meta.get
|
116
117
|
end
|
117
118
|
|
118
119
|
def middle(isoxml, out)
|
119
120
|
middle_title(isoxml, out)
|
120
121
|
middle_admonitions(isoxml, out)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
symbols_abbrevs isoxml, out,
|
122
|
+
scope isoxml, out, 0
|
123
|
+
norm_ref isoxml, out, 0
|
124
|
+
terms_defs isoxml, out, 0
|
125
|
+
symbols_abbrevs isoxml, out, 0
|
125
126
|
clause isoxml, out
|
126
127
|
annex isoxml, out
|
127
128
|
bibliography isoxml, out
|
129
|
+
colophon isoxml, out
|
128
130
|
end
|
129
131
|
|
130
132
|
def boilerplate(node, out)
|
131
133
|
return if @bare
|
132
134
|
|
133
135
|
boilerplate = node.at(ns("//boilerplate")) or return
|
134
|
-
out.div
|
136
|
+
out.div class: "authority" do |s|
|
135
137
|
boilerplate.children.each do |n|
|
136
138
|
if n.name == "title"
|
137
139
|
s.h1 do |h|
|
@@ -100,12 +100,14 @@ module IsoDoc
|
|
100
100
|
#{header_strip(content)}</a></li>)
|
101
101
|
end
|
102
102
|
|
103
|
+
# array of arrays, one per level, containing XPath fragments for the elems
|
104
|
+
# matching that ToC level
|
103
105
|
def toclevel_classes
|
104
|
-
(1..@htmlToClevels).reduce([]) { |m, i| m << "h#{i}" }
|
106
|
+
(1..@htmlToClevels).reduce([]) { |m, i| m << ["h#{i}"] }
|
105
107
|
end
|
106
108
|
|
107
109
|
def toclevel
|
108
|
-
ret = toclevel_classes.map do |l|
|
110
|
+
ret = toclevel_classes.flatten.map do |l|
|
109
111
|
"#{l}:not(:empty):not(.TermNum):not(.noTOC)"
|
110
112
|
end
|
111
113
|
<<~HEAD.freeze
|
@@ -116,18 +118,25 @@ module IsoDoc
|
|
116
118
|
# needs to be same output as toclevel
|
117
119
|
def html_toc(docxml)
|
118
120
|
idx = docxml.at("//div[@id = 'toc']") or return docxml
|
119
|
-
|
120
|
-
|
121
|
-
"//main//#{l}#{toc_exclude_class}"
|
121
|
+
path = toclevel_classes.map do |x|
|
122
|
+
x.map { |l| "//main//#{l}#{toc_exclude_class}" }
|
122
123
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
127
|
-
idx.children = "#{toc}</ul>"
|
124
|
+
toc = html_toc_entries(docxml, path)
|
125
|
+
.map { |k| k[:entry] }.join("\n")
|
126
|
+
idx.children = "<ul>#{toc}</ul>"
|
128
127
|
docxml
|
129
128
|
end
|
130
129
|
|
130
|
+
def html_toc_entries(docxml, path)
|
131
|
+
path.each_with_index.with_object([]) do |(p, i), m|
|
132
|
+
docxml.xpath(p.join(" | ")).each do |h|
|
133
|
+
h["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
134
|
+
m << { entry: html_toc_entry("h#{i + 1}", h),
|
135
|
+
line: h.line }
|
136
|
+
end
|
137
|
+
end.sort_by { |k| k[:line] }
|
138
|
+
end
|
139
|
+
|
131
140
|
def toc_exclude_class
|
132
141
|
"[not(@class = 'TermNum')][not(@class = 'noTOC')]" \
|
133
142
|
"[string-length(normalize-space(.))>0]"
|
data/lib/isodoc/init.rb
CHANGED
@@ -17,5 +17,14 @@ module IsoDoc
|
|
17
17
|
def l10n(expr, lang = @lang, script = @script, locale = @locale)
|
18
18
|
@i18n.l10n(expr, lang, script, locale)
|
19
19
|
end
|
20
|
+
|
21
|
+
def toc_init(docxml)
|
22
|
+
x = "//metanorma-extension/presentation-metadata" \
|
23
|
+
"[name[text() = 'TOC Heading Levels']]/value"
|
24
|
+
n = docxml.at(ns(x.sub(/TOC/, "DOC TOC"))) and
|
25
|
+
@wordToClevels = n.text.to_i
|
26
|
+
n = docxml.at(ns(x.sub(/TOC/, "HTML TOC"))) and
|
27
|
+
@htmlToClevels = n.text.to_i
|
28
|
+
end
|
20
29
|
end
|
21
30
|
end
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative "./metadata_date"
|
4
2
|
require_relative "./metadata_contributor"
|
5
3
|
|
@@ -39,7 +37,7 @@ module IsoDoc
|
|
39
37
|
@metadata[key] = value
|
40
38
|
end
|
41
39
|
|
42
|
-
NOLANG = "[not(@language) or @language = '']"
|
40
|
+
NOLANG = "[not(@language) or @language = '']".freeze
|
43
41
|
|
44
42
|
def currlang
|
45
43
|
"[@language = '#{@lang}']"
|
@@ -109,7 +107,8 @@ module IsoDoc
|
|
109
107
|
|
110
108
|
def version(isoxml, _out)
|
111
109
|
set(:edition, isoxml&.at(ns("//bibdata/edition#{NOLANG}"))&.text)
|
112
|
-
set(:edition_display,
|
110
|
+
set(:edition_display,
|
111
|
+
isoxml&.at(ns("//bibdata/edition#{currlang}"))&.text)
|
113
112
|
set(:docyear, isoxml&.at(ns("//bibdata/copyright/from"))&.text)
|
114
113
|
set(:draft, isoxml&.at(ns("//bibdata/version/draft"))&.text)
|
115
114
|
revdate = isoxml&.at(ns("//bibdata/version/revision-date"))&.text
|
@@ -173,5 +172,14 @@ module IsoDoc
|
|
173
172
|
c = isoxml.at(ns("//metanorma-extension/source-highlighter-css")) or return
|
174
173
|
set(:code_css, c.text)
|
175
174
|
end
|
175
|
+
|
176
|
+
def presentation(xml, _out)
|
177
|
+
xml.xpath(ns("//metanorma-extension/presentation-metadata")).each do |p|
|
178
|
+
((n = p.at(ns("./name"))) && (v = p.at(ns("./value")))) or next
|
179
|
+
lbl = "presentation_metadata_#{n.text}".to_sym
|
180
|
+
m = get[lbl] || []
|
181
|
+
set(lbl, m << v.text)
|
182
|
+
end
|
183
|
+
end
|
176
184
|
end
|
177
185
|
end
|
@@ -20,16 +20,14 @@ module IsoDoc
|
|
20
20
|
|
21
21
|
def extract_person_affiliations(authors)
|
22
22
|
authors.reduce([]) do |m, a|
|
23
|
+
pos = a.at(ns("./affiliation/name"))&.text
|
23
24
|
name = a.at(ns("./affiliation/organization/name"))&.text
|
24
|
-
subdivs = a.xpath(ns("./affiliation/organization/subdivision"))
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
m << (
|
29
|
-
|
30
|
-
else
|
31
|
-
(name || location || "")
|
32
|
-
end)
|
25
|
+
subdivs = a.xpath(ns("./affiliation/organization/subdivision"))
|
26
|
+
&.map(&:text)&.join(", ")
|
27
|
+
location =
|
28
|
+
a.at(ns("./affiliation/organization/address/formattedAddress"))&.text
|
29
|
+
m << l10n([pos, name, subdivs, location].map { |x| x&.empty? ? nil : x }
|
30
|
+
.compact.join(", "))
|
33
31
|
m
|
34
32
|
end
|
35
33
|
end
|
@@ -31,10 +31,18 @@ module IsoDoc
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def formula1(elem)
|
34
|
+
formula_where(elem.at(ns("./dl")))
|
34
35
|
lbl = @xrefs.anchor(elem["id"], :label, false)
|
35
36
|
prefix_name(elem, "", lbl, "name")
|
36
37
|
end
|
37
38
|
|
39
|
+
def formula_where(dlist)
|
40
|
+
dlist or return
|
41
|
+
dlist["class"] = "formula_dl"
|
42
|
+
where = dlist.xpath(ns("./dt")).size > 1 ? @i18n.where : @i18n.where_one
|
43
|
+
dlist.previous = "<p keep-with-next='true'>#{where}</p>"
|
44
|
+
end
|
45
|
+
|
38
46
|
def example(docxml)
|
39
47
|
docxml.xpath(ns("//example")).each { |f| example1(f) }
|
40
48
|
end
|
@@ -17,10 +17,11 @@ module IsoDoc
|
|
17
17
|
|
18
18
|
def eref_localities(refs, target, node)
|
19
19
|
if can_conflate_eref_rendering?(refs)
|
20
|
-
l10n(", #{eref_localities_conflated(refs, target, node)}"
|
20
|
+
l10n(", #{eref_localities_conflated(refs, target, node)}"
|
21
|
+
.gsub(/\s+/, " "))
|
21
22
|
else
|
22
23
|
ret = resolve_eref_connectives(eref_locality_stacks(refs, target, node))
|
23
|
-
l10n(ret.join)
|
24
|
+
l10n(ret.join.gsub(/\s+/, " "))
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -68,7 +69,7 @@ module IsoDoc
|
|
68
69
|
end
|
69
70
|
|
70
71
|
def resolve_comma_connectives1(locs, locs1, add)
|
71
|
-
if [", ", " "].include?(locs[1])
|
72
|
+
if [", ", " ", ""].include?(locs[1])
|
72
73
|
add += locs[0..2].join
|
73
74
|
locs.shift(3)
|
74
75
|
else
|
@@ -16,8 +16,8 @@ module IsoDoc
|
|
16
16
|
def svg_wrap(elem)
|
17
17
|
return if elem.parent.name == "image"
|
18
18
|
|
19
|
-
elem.
|
20
|
-
|
19
|
+
elem.wrap("<image src='' mimetype='image/svg+xml' height='auto' " \
|
20
|
+
"width='auto'></image>")
|
21
21
|
end
|
22
22
|
|
23
23
|
def svgmap_extract(elem)
|
@@ -6,11 +6,16 @@ module IsoDoc
|
|
6
6
|
docxml.xpath(ns("//references/bibitem")).each do |x|
|
7
7
|
bibitem(x, renderings)
|
8
8
|
end
|
9
|
+
hidden_items(docxml)
|
10
|
+
@xrefs.parse_inclusions(refs: true).parse(docxml)
|
11
|
+
end
|
12
|
+
|
13
|
+
def hidden_items(docxml)
|
9
14
|
docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x|
|
10
15
|
x.at(ns("./bibitem[not(@hidden = 'true')]")) and next
|
16
|
+
x.elements.map(&:name).any? { |n| n != "bibitem" } and next
|
11
17
|
x["hidden"] = "true"
|
12
18
|
end
|
13
|
-
@xrefs.parse_inclusions(refs: true).parse(docxml)
|
14
19
|
end
|
15
20
|
|
16
21
|
def references_render(docxml)
|
@@ -125,13 +130,13 @@ module IsoDoc
|
|
125
130
|
ids = @xrefs.klass.bibitem_ref_code(bib)
|
126
131
|
idents = @xrefs.klass.render_identifier(ids)
|
127
132
|
ret = if biblio then biblio_ref_entry_code(ordinal, idents, ids,
|
128
|
-
standard, datefn)
|
129
|
-
else norm_ref_entry_code(ordinal, idents, ids, standard, datefn)
|
133
|
+
standard, datefn, bib)
|
134
|
+
else norm_ref_entry_code(ordinal, idents, ids, standard, datefn, bib)
|
130
135
|
end
|
131
136
|
bib << "<biblio-tag>#{ret}</biblio-tag>"
|
132
137
|
end
|
133
138
|
|
134
|
-
def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn)
|
139
|
+
def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
|
135
140
|
ret = (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
|
136
141
|
(idents[:ordinal] || idents[:metanorma]) && idents[:sdo] and
|
137
142
|
ret += ", #{idents[:sdo]}"
|
@@ -143,8 +148,8 @@ module IsoDoc
|
|
143
148
|
|
144
149
|
# if ids is just a number, only use that ([1] Non-Standard)
|
145
150
|
# else, use both ordinal, as prefix, and ids
|
146
|
-
def biblio_ref_entry_code(ordinal, ids, _id, standard, datefn)
|
147
|
-
standard and id = nil
|
151
|
+
def biblio_ref_entry_code(ordinal, ids, _id, standard, datefn, _bib)
|
152
|
+
#standard and id = nil
|
148
153
|
ret = (ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]")
|
149
154
|
if ids[:sdo]
|
150
155
|
ret = prefix_bracketed_ref(ret)
|
@@ -28,12 +28,13 @@ module IsoDoc
|
|
28
28
|
def floattitle(docxml)
|
29
29
|
docxml.xpath(ns("//clause | //annex | //appendix | //introduction | " \
|
30
30
|
"//foreword | //preface/abstract | //acknowledgements | " \
|
31
|
-
"//terms | //definitions | //references"))
|
31
|
+
"//terms | //definitions | //references | //colophon"))
|
32
32
|
.each do |f|
|
33
33
|
floattitle1(f)
|
34
34
|
end
|
35
35
|
# top-level
|
36
|
-
docxml.xpath(ns("//sections | //preface
|
36
|
+
docxml.xpath(ns("//sections | //preface | //colophon"))
|
37
|
+
.each { |f| floattitle1(f) }
|
37
38
|
end
|
38
39
|
|
39
40
|
def floattitle1(elem)
|
@@ -119,7 +120,8 @@ module IsoDoc
|
|
119
120
|
i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
|
120
121
|
i = display_order_xpath(docxml, "//annex", i)
|
121
122
|
i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
|
122
|
-
display_order_xpath(docxml, "//indexsect", i)
|
123
|
+
i = display_order_xpath(docxml, "//indexsect", i)
|
124
|
+
display_order_xpath(docxml, "//colophon/*", i)
|
123
125
|
end
|
124
126
|
|
125
127
|
def clausetitle(docxml); end
|
@@ -75,7 +75,7 @@ module IsoDoc
|
|
75
75
|
def combine_conflated_xref_locations(locs)
|
76
76
|
out = locs.each { |l| l[:label] = anchor_value(l[:target]) }
|
77
77
|
label = @i18n.inflect(locs.first[:elem], number: "pl")
|
78
|
-
out[0][:label] = l10n("#{label} #{out[0][:label]}")
|
78
|
+
out[0][:label] = l10n("#{label} #{out[0][:label]}").strip
|
79
79
|
combine_conflated_xref_locations_container(locs, l10n(combine_conn(out)))
|
80
80
|
end
|
81
81
|
|
@@ -108,9 +108,16 @@ module IsoDoc
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def embedable_semantic_xml_tags(xml)
|
111
|
-
|
112
|
-
.sub(/ xmlns=['"][^"']+['"]/, "")
|
113
|
-
.
|
111
|
+
ret = to_xml(xml)
|
112
|
+
.sub(/ xmlns=['"][^"']+['"]/, "") # root XMLNS
|
113
|
+
.split(/(?=[<> \t\r\n\f\v])/).map do |x|
|
114
|
+
case x
|
115
|
+
when /^<[^:]+:/ then x.sub(/:/, ":semantic__")
|
116
|
+
when /^<[^:]+$/ then x.sub(%r{(</?)([[:alpha:]])},
|
117
|
+
"\\1semantic__\\2")
|
118
|
+
else x end
|
119
|
+
end
|
120
|
+
Nokogiri::XML(ret.join).root
|
114
121
|
end
|
115
122
|
|
116
123
|
def embedable_semantic_xml_attributes(xml)
|
data/lib/isodoc/version.rb
CHANGED
@@ -93,7 +93,7 @@ module IsoDoc
|
|
93
93
|
|
94
94
|
def dl_parse_table(node, out)
|
95
95
|
list_title_parse(node, out)
|
96
|
-
out.table class: "dl" do |v|
|
96
|
+
out.table class: (node["class"] || "dl") do |v|
|
97
97
|
node.elements.select { |n| dt_dd?(n) }
|
98
98
|
.each_slice(2) do |dt, dd|
|
99
99
|
dl_parse_table1(v, dt, dd)
|
@@ -204,14 +204,6 @@ module IsoDoc
|
|
204
204
|
)
|
205
205
|
end
|
206
206
|
|
207
|
-
def formula_where(deflist, out)
|
208
|
-
return unless deflist
|
209
|
-
|
210
|
-
out.p { |p| p << @i18n.where }
|
211
|
-
parse(deflist, out)
|
212
|
-
t = out.parent.at("./table") and t["class"] = "formula_dl"
|
213
|
-
end
|
214
|
-
|
215
207
|
def formula_parse1(node, out)
|
216
208
|
out.div **attr_code(class: "formula") do |div|
|
217
209
|
div.p do |_p|
|
@@ -244,11 +236,11 @@ module IsoDoc
|
|
244
236
|
|
245
237
|
def info(isoxml, out)
|
246
238
|
@tocfigurestitle =
|
247
|
-
isoxml
|
239
|
+
isoxml.at(ns("//metanorma-extension/toc[@type = 'figure']/title"))&.text
|
248
240
|
@toctablestitle =
|
249
|
-
isoxml
|
241
|
+
isoxml.at(ns("//metanorma-extension/toc[@type = 'table']/title"))&.text
|
250
242
|
@tocrecommendationstitle = isoxml
|
251
|
-
|
243
|
+
.at(ns("//metanorma-extension/toc[@type = 'recommendation']/title"))&.text
|
252
244
|
super
|
253
245
|
end
|
254
246
|
end
|
@@ -89,16 +89,20 @@ module IsoDoc
|
|
89
89
|
table_title_parse(node, out)
|
90
90
|
out.div align: "center", class: "table_container" do |div|
|
91
91
|
div.table **table_attrs(node) do |t|
|
92
|
-
|
93
|
-
thead_parse(node, t)
|
94
|
-
tbody_parse(node, t)
|
95
|
-
tfoot_parse(node, t)
|
92
|
+
table_parse_core(node, out)
|
96
93
|
(dl = node.at(ns("./dl"))) && parse(dl, out)
|
97
94
|
node.xpath(ns("./note")).each { |n| parse(n, out) }
|
98
95
|
end
|
99
96
|
end
|
100
97
|
@in_table = false
|
101
98
|
end
|
99
|
+
|
100
|
+
def table_parse_core(node, out)
|
101
|
+
colgroup(node, out)
|
102
|
+
thead_parse(node, out)
|
103
|
+
tbody_parse(node, out)
|
104
|
+
tfoot_parse(node, out)
|
105
|
+
end
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -108,9 +108,7 @@ module IsoDoc
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def note_anchor_names1(notes, counter)
|
111
|
-
notes.each do |n|
|
112
|
-
next if @anchors[n["id"]] || blank?(n["id"])
|
113
|
-
|
111
|
+
notes.noblank.each do |n|
|
114
112
|
@anchors[n["id"]] =
|
115
113
|
anchor_struct(increment_label(notes, n, counter), n,
|
116
114
|
@labels["note_xref"], "note", false)
|
@@ -45,10 +45,14 @@ module IsoDoc
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def subfigure_label(subfignum)
|
49
|
+
subfignum.zero? and return ""
|
50
|
+
"-#{subfignum}"
|
51
|
+
end
|
52
|
+
|
48
53
|
def sequential_figure_body(subfignum, counter, block, klass)
|
49
54
|
label = counter.print
|
50
|
-
label &&= label + (subfignum
|
51
|
-
|
55
|
+
label &&= label + subfigure_label(subfignum)
|
52
56
|
@anchors[block["id"]] = anchor_struct(
|
53
57
|
label, nil, @labels[klass] || klass.capitalize, klass,
|
54
58
|
block["unnumbered"]
|
@@ -58,8 +62,7 @@ module IsoDoc
|
|
58
62
|
def sequential_table_names(clause)
|
59
63
|
c = Counter.new
|
60
64
|
clause.xpath(ns(".//table")).noblank.each do |t|
|
61
|
-
|
62
|
-
|
65
|
+
labelled_ancestor(t) and next
|
63
66
|
@anchors[t["id"]] = anchor_struct(
|
64
67
|
c.increment(t).print, nil,
|
65
68
|
@labels["table"], "table", t["unnumbered"]
|
@@ -117,7 +120,6 @@ module IsoDoc
|
|
117
120
|
block, anchor_struct(id, block,
|
118
121
|
label, klass, block["unnumbered"])
|
119
122
|
)
|
120
|
-
|
121
123
|
model.permission_parts(block, id, label, klass).each do |n|
|
122
124
|
@anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
|
123
125
|
n[:klass], false)
|
@@ -171,8 +173,7 @@ module IsoDoc
|
|
171
173
|
|
172
174
|
def hierarchical_figure_body(num, subfignum, counter, block, klass)
|
173
175
|
label = "#{num}#{hiersep}#{counter.print}" +
|
174
|
-
(subfignum
|
175
|
-
|
176
|
+
subfigure_label(subfignum)
|
176
177
|
@anchors[block["id"]] =
|
177
178
|
anchor_struct(label, nil, @labels[klass] || klass.capitalize,
|
178
179
|
klass, block["unnumbered"])
|
@@ -181,8 +182,7 @@ module IsoDoc
|
|
181
182
|
def hierarchical_table_names(clause, num)
|
182
183
|
c = Counter.new
|
183
184
|
clause.xpath(ns(".//table")).noblank.each do |t|
|
184
|
-
|
185
|
-
|
185
|
+
labelled_ancestor(t) and next
|
186
186
|
@anchors[t["id"]] =
|
187
187
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
|
188
188
|
nil, @labels["table"], "table", t["unnumbered"])
|
@@ -1,17 +1,18 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module XrefGen
|
3
3
|
module Sections
|
4
|
-
def back_anchor_names(
|
4
|
+
def back_anchor_names(xml)
|
5
5
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
6
6
|
i = Counter.new("@")
|
7
|
-
|
7
|
+
xml.xpath(ns("//annex")).each do |c|
|
8
8
|
annex_names(c, i.increment(c).print)
|
9
9
|
end
|
10
|
-
|
10
|
+
xml.xpath(ns(@klass.bibliography_xpath)).each do |b|
|
11
11
|
preface_names(b)
|
12
12
|
end
|
13
|
+
xml.xpath(ns("//colophon/clause")).each { |b| preface_names(b) }
|
13
14
|
end
|
14
|
-
references(
|
15
|
+
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
15
16
|
end
|
16
17
|
|
17
18
|
def references(docxml)
|
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.5.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: 2023-
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -136,20 +136,6 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.3.1
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: relaton-cli
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :runtime
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: relaton-render
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|