isodoc 1.2.5 → 1.3.1
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/.github/workflows/rake.yml +69 -0
- data/README.adoc +1 -3
- data/isodoc.gemspec +3 -1
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +8 -7
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/base_style/all.css +5 -1
- data/lib/isodoc/base_style/blocks.scss +2 -2
- data/lib/isodoc/base_style/reset.css +5 -1
- data/lib/isodoc/base_style/reset.scss +6 -1
- data/lib/isodoc/base_style/typography.scss +1 -1
- data/lib/isodoc/convert.rb +12 -97
- data/lib/isodoc/css.rb +95 -0
- data/lib/isodoc/function/inline.rb +0 -33
- data/lib/isodoc/function/inline_simple.rb +4 -1
- data/lib/isodoc/function/lists.rb +2 -1
- data/lib/isodoc/function/references.rb +8 -13
- data/lib/isodoc/function/table.rb +10 -0
- data/lib/isodoc/function/to_word_html.rb +3 -2
- data/lib/isodoc/gem_tasks.rb +4 -0
- data/lib/isodoc/html_function/html.rb +1 -0
- data/lib/isodoc/html_function/postprocess.rb +12 -3
- data/lib/isodoc/i18n.rb +23 -51
- data/lib/isodoc/metadata.rb +42 -115
- data/lib/isodoc/metadata_contributor.rb +90 -0
- data/lib/isodoc/metadata_date.rb +11 -0
- data/lib/isodoc/presentation_function/bibdata.rb +79 -7
- data/lib/isodoc/presentation_function/block.rb +14 -9
- data/lib/isodoc/presentation_function/inline.rb +126 -22
- data/lib/isodoc/presentation_function/section.rb +6 -0
- data/lib/isodoc/presentation_xml_convert.rb +4 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +0 -20
- data/lib/isodoc/word_function/body.rb +12 -0
- data/lib/isodoc/word_function/postprocess.rb +38 -80
- data/lib/isodoc/word_function/postprocess_cover.rb +55 -0
- data/lib/isodoc/word_function/table.rb +10 -0
- data/lib/isodoc/xref.rb +1 -0
- data/lib/isodoc/xref/xref_counter.rb +20 -9
- data/lib/isodoc/xref/xref_gen.rb +20 -2
- data/lib/isodoc/xslfo_convert.rb +6 -1
- data/spec/assets/html.scss +14 -0
- data/spec/assets/i18n.yaml +17 -9
- data/spec/isodoc/blocks_spec.rb +88 -240
- data/spec/isodoc/cleanup_spec.rb +0 -1
- data/spec/isodoc/footnotes_spec.rb +4 -5
- data/spec/isodoc/i18n_spec.rb +73 -38
- data/spec/isodoc/inline_spec.rb +177 -199
- data/spec/isodoc/lists_spec.rb +1 -1
- data/spec/isodoc/metadata_spec.rb +68 -20
- data/spec/isodoc/postproc_spec.rb +306 -8
- data/spec/isodoc/presentation_xml_spec.rb +584 -1
- data/spec/isodoc/ref_spec.rb +327 -12
- data/spec/isodoc/table_spec.rb +28 -0
- data/spec/isodoc/xref_spec.rb +162 -17
- data/spec/spec_helper.rb +6 -0
- metadata +35 -7
- data/.github/workflows/macos.yml +0 -42
- data/.github/workflows/ubuntu.yml +0 -62
- data/.github/workflows/windows.yml +0 -44
@@ -30,6 +30,7 @@ module IsoDoc
|
|
30
30
|
clause docxml
|
31
31
|
annex docxml
|
32
32
|
term docxml
|
33
|
+
index docxml
|
33
34
|
end
|
34
35
|
|
35
36
|
def block(docxml)
|
@@ -51,7 +52,10 @@ module IsoDoc
|
|
51
52
|
xref docxml
|
52
53
|
eref docxml
|
53
54
|
origin docxml
|
55
|
+
concept docxml
|
54
56
|
quotesource docxml
|
57
|
+
mathml docxml
|
58
|
+
variant docxml
|
55
59
|
end
|
56
60
|
|
57
61
|
def postprocess(result, filename, dir)
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/word_convert.rb
CHANGED
@@ -4,26 +4,6 @@ require_relative "word_function/body.rb"
|
|
4
4
|
require_relative "word_function/postprocess.rb"
|
5
5
|
|
6
6
|
module IsoDoc
|
7
|
-
|
8
|
-
=begin
|
9
|
-
module WordConvertModule
|
10
|
-
# http://tech.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/
|
11
|
-
# https://www.ruby-forum.com/topic/148303
|
12
|
-
#
|
13
|
-
# The following is ugly indeed, but the only way I can split module override methods
|
14
|
-
# across files
|
15
|
-
def self.included base
|
16
|
-
base.class_eval do
|
17
|
-
|
18
|
-
eval File.open(File.join(File.dirname(__FILE__),"wordconvertmodule.rb")).read
|
19
|
-
eval File.open(File.join(File.dirname(__FILE__),"comments.rb")).read
|
20
|
-
eval File.open(File.join(File.dirname(__FILE__),"footnotes.rb")).read
|
21
|
-
eval File.open(File.join(File.dirname(__FILE__),"postprocess.rb")).read
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
=end
|
26
|
-
|
27
7
|
class WordConvert < ::IsoDoc::Convert
|
28
8
|
include WordFunction::Comments
|
29
9
|
include WordFunction::Footnotes
|
@@ -196,6 +196,18 @@ module IsoDoc::WordFunction
|
|
196
196
|
out.parent.at("./table")["class"] = "formula_dl"
|
197
197
|
end
|
198
198
|
|
199
|
+
def formula_parse1(node, out)
|
200
|
+
out.div **attr_code(class: "formula") do |div|
|
201
|
+
div.p do |p|
|
202
|
+
parse(node.at(ns("./stem")), div)
|
203
|
+
insert_tab(div, 1)
|
204
|
+
if lbl = node&.at(ns("./name"))&.text
|
205
|
+
div << "(#{lbl})"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
199
211
|
def li_parse(node, out)
|
200
212
|
out.li **attr_code(id: node["id"]) do |li|
|
201
213
|
if node["uncheckedcheckbox"] == "true"
|
@@ -5,11 +5,9 @@ module IsoDoc::WordFunction
|
|
5
5
|
module Postprocess
|
6
6
|
# add namespaces for Word fragments
|
7
7
|
WORD_NOKOHEAD = <<~HERE.freeze
|
8
|
-
<!DOCTYPE html SYSTEM
|
9
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
8
|
+
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
10
9
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
11
|
-
xmlns:v="urn:schemas-microsoft-com:vml"
|
12
|
-
xmlns:o="urn:schemas-microsoft-com:office:office"
|
10
|
+
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
|
13
11
|
xmlns:w="urn:schemas-microsoft-com:office:word"
|
14
12
|
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
15
13
|
<head> <title></title> <meta charset="UTF-8" /> </head>
|
@@ -18,15 +16,13 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
18
16
|
|
19
17
|
def to_word_xhtml_fragment(xml)
|
20
18
|
doc = ::Nokogiri::XML.parse(WORD_NOKOHEAD)
|
21
|
-
|
22
|
-
fragment
|
19
|
+
::Nokogiri::XML::DocumentFragment.new(doc, xml, doc.root)
|
23
20
|
end
|
24
21
|
|
25
22
|
def table_note_cleanup(docxml)
|
26
23
|
super
|
27
24
|
# preempt html2doc putting MsoNormal there
|
28
|
-
docxml.xpath("//p[not(self::*[@class])]"
|
29
|
-
"[ancestor::*[@class = 'Note']]").each do |p|
|
25
|
+
docxml.xpath("//p[not(self::*[@class])][ancestor::*[@class = 'Note']]").each do |p|
|
30
26
|
p["class"] = "Note"
|
31
27
|
end
|
32
28
|
end
|
@@ -56,8 +52,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
56
52
|
|
57
53
|
def word_admonition_images(docxml)
|
58
54
|
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
59
|
-
i["width"], i["height"] =
|
60
|
-
Html2Doc.image_resize(i, image_localfile(i), @maxheight, 300)
|
55
|
+
i["width"], i["height"] = Html2Doc.image_resize(i, image_localfile(i), @maxheight, 300)
|
61
56
|
end
|
62
57
|
end
|
63
58
|
|
@@ -65,6 +60,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
65
60
|
word_annex_cleanup(docxml)
|
66
61
|
word_preface(docxml)
|
67
62
|
word_nested_tables(docxml)
|
63
|
+
word_colgroup(docxml)
|
68
64
|
word_table_align(docxml)
|
69
65
|
word_table_separator(docxml)
|
70
66
|
word_admonition_images(docxml)
|
@@ -78,28 +74,44 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
78
74
|
docxml
|
79
75
|
end
|
80
76
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
def word_colgroup(docxml)
|
78
|
+
cells2d = {}
|
79
|
+
docxml.xpath("//table[colgroup]").each do |t|
|
80
|
+
w = colgroup_widths(t)
|
81
|
+
t.xpath(".//tr").each_with_index { |tr, r| cells2d[r] = {} }
|
82
|
+
t.xpath(".//tr").each_with_index do |tr, r|
|
83
|
+
tr.xpath("./td | ./th").each_with_index do |td, i|
|
84
|
+
x = 0
|
85
|
+
rs = td&.attr("rowspan")&.to_i || 1
|
86
|
+
cs = td&.attr("colspan")&.to_i || 1
|
87
|
+
while cells2d[r][x] do
|
88
|
+
x += 1
|
89
|
+
end
|
90
|
+
for y2 in r..(r + rs - 1)
|
91
|
+
for x2 in x..(x + cs - 1)
|
92
|
+
cells2d[y2][x2] = 1
|
93
|
+
end
|
94
|
+
end
|
95
|
+
width = (x..(x+cs-1)).each_with_object({width: 0}) { |z, m| m[:width] += w[z] }
|
96
|
+
td["width"] = "#{width[:width]}%"
|
97
|
+
x += cs
|
98
|
+
end
|
85
99
|
end
|
86
100
|
end
|
87
101
|
end
|
88
102
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
auth&.xpath(".//h1 | .//h2")&.each do |h|
|
94
|
-
h.name = "p"
|
95
|
-
h["class"] = "TitlePageSubhead"
|
103
|
+
# assume percentages
|
104
|
+
def colgroup_widths(t)
|
105
|
+
t.xpath("./colgroup/col").each_with_object([]) do |c, m|
|
106
|
+
m << c["width"].sub(/%$/, "").to_f
|
96
107
|
end
|
97
|
-
dest and auth and dest.replace(auth.remove)
|
98
108
|
end
|
99
109
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
110
|
+
def word_nested_tables(docxml)
|
111
|
+
docxml.xpath("//table").each do |t|
|
112
|
+
t.xpath(".//table").reverse.each do |tt|
|
113
|
+
t.next = tt.remove
|
114
|
+
end
|
103
115
|
end
|
104
116
|
end
|
105
117
|
|
@@ -144,19 +156,6 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
144
156
|
end
|
145
157
|
end
|
146
158
|
|
147
|
-
=begin
|
148
|
-
EMPTY_PARA = "<p style='margin-top:0cm;margin-right:0cm;"\
|
149
|
-
"margin-bottom:0cm;margin-left:0.0pt;margin-bottom:.0001pt;"\
|
150
|
-
"line-height:1.0pt;mso-line-height-rule:exactly'>"\
|
151
|
-
"<span lang=EN-GB style='display:none;mso-hide:all'> </span></p>"
|
152
|
-
|
153
|
-
def table_after_table(docxml)
|
154
|
-
docxml.xpath("//table[following-sibling::*[1]/self::table]").each do |t|
|
155
|
-
t.add_next_sibling(EMPTY_PARA)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
=end
|
159
|
-
|
160
159
|
def word_table_separator(docxml)
|
161
160
|
docxml.xpath("//p[@class = 'TableTitle']").each do |t|
|
162
161
|
next unless t.children.empty?
|
@@ -180,46 +179,6 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
180
179
|
end
|
181
180
|
end
|
182
181
|
|
183
|
-
def generate_header(filename, _dir)
|
184
|
-
return nil unless @header
|
185
|
-
template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
|
186
|
-
meta = @meta.get
|
187
|
-
meta[:filename] = filename
|
188
|
-
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
189
|
-
Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
|
190
|
-
f.write(template.render(params))
|
191
|
-
f
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def word_section_breaks(docxml)
|
196
|
-
@landscapestyle = ""
|
197
|
-
word_section_breaks1(docxml, "WordSection2")
|
198
|
-
word_section_breaks1(docxml, "WordSection3")
|
199
|
-
word_remove_pb_before_annex(docxml)
|
200
|
-
docxml.xpath("//br[@orientation]").each { |br| br.delete("orientation") }
|
201
|
-
end
|
202
|
-
|
203
|
-
def word_section_breaks1(docxml, sect)
|
204
|
-
docxml.xpath("//div[@class = '#{sect}']//br[@orientation]").reverse.
|
205
|
-
each_with_index do |br, i|
|
206
|
-
@landscapestyle += "\ndiv.#{sect}_#{i} {page:#{sect}"\
|
207
|
-
"#{br["orientation"] == "landscape" ? "L" : "P"};}\n"
|
208
|
-
split_at_section_break(docxml, sect, br, i)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def split_at_section_break(docxml, sect, br, i)
|
213
|
-
move = br.parent.xpath("following::node()") &
|
214
|
-
br.document.xpath("//div[@class = '#{sect}']//*")
|
215
|
-
ins = docxml.at("//div[@class = '#{sect}']").
|
216
|
-
after("<div class='#{sect}_#{i}'/>").next_element
|
217
|
-
move.each do |m|
|
218
|
-
next if m.at("./ancestor::div[@class = '#{sect}_#{i}']")
|
219
|
-
ins << m.remove
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
182
|
# applies for <div class="WordSectionN_M"><p><pagebreak/></p>...
|
224
183
|
def word_remove_pb_before_annex(docxml)
|
225
184
|
docxml.xpath("//div[p/br]").each do |d|
|
@@ -237,8 +196,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
237
196
|
docxml.xpath("//a[@epub:type = 'footnote']").each do |x|
|
238
197
|
footnote_reference_format(x)
|
239
198
|
end
|
240
|
-
docxml.xpath("//a[@class = 'TableFootnoteRef'] | "
|
241
|
-
"//span[@class = 'TableFootnoteRef']").each do |x|
|
199
|
+
docxml.xpath("//a[@class = 'TableFootnoteRef'] | //span[@class = 'TableFootnoteRef']").each do |x|
|
242
200
|
table_footnote_reference_format(x)
|
243
201
|
end
|
244
202
|
docxml
|
@@ -75,5 +75,60 @@ module IsoDoc::WordFunction
|
|
75
75
|
toc.sub(/(<p class="MsoToc1">)/,
|
76
76
|
%{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
|
77
77
|
end
|
78
|
+
|
79
|
+
def authority_cleanup1(docxml, klass)
|
80
|
+
dest = docxml.at("//div[@id = 'boilerplate-#{klass}-destination']")
|
81
|
+
auth = docxml.at("//div[@id = 'boilerplate-#{klass}' or @class = 'boilerplate-#{klass}']")
|
82
|
+
auth&.xpath(".//h1[not(text())] | .//h2[not(text())]")&.each { |h| h.remove }
|
83
|
+
auth&.xpath(".//h1 | .//h2")&.each do |h|
|
84
|
+
h.name = "p"
|
85
|
+
h["class"] = "TitlePageSubhead"
|
86
|
+
end
|
87
|
+
dest and auth and dest.replace(auth.remove)
|
88
|
+
end
|
89
|
+
|
90
|
+
def authority_cleanup(docxml)
|
91
|
+
%w(copyright license legal feedback).each do |t|
|
92
|
+
authority_cleanup1(docxml, t)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def generate_header(filename, _dir)
|
97
|
+
return nil unless @header
|
98
|
+
template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
|
99
|
+
meta = @meta.get.merge(@labels || {}).merge(@meta.labels || {})
|
100
|
+
meta[:filename] = filename
|
101
|
+
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
102
|
+
Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
|
103
|
+
f.write(template.render(params))
|
104
|
+
f
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def word_section_breaks(docxml)
|
109
|
+
@landscapestyle = ""
|
110
|
+
word_section_breaks1(docxml, "WordSection2")
|
111
|
+
word_section_breaks1(docxml, "WordSection3")
|
112
|
+
word_remove_pb_before_annex(docxml)
|
113
|
+
docxml.xpath("//br[@orientation]").each { |br| br.delete("orientation") }
|
114
|
+
end
|
115
|
+
|
116
|
+
def word_section_breaks1(docxml, sect)
|
117
|
+
docxml.xpath("//div[@class = '#{sect}']//br[@orientation]").reverse.
|
118
|
+
each_with_index do |br, i|
|
119
|
+
@landscapestyle += "\ndiv.#{sect}_#{i} {page:#{sect}#{br["orientation"] == "landscape" ? "L" : "P"};}\n"
|
120
|
+
split_at_section_break(docxml, sect, br, i)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def split_at_section_break(docxml, sect, br, i)
|
125
|
+
move = br.parent.xpath("following::node()") &
|
126
|
+
br.document.xpath("//div[@class = '#{sect}']//*")
|
127
|
+
ins = docxml.at("//div[@class = '#{sect}']").after("<div class='#{sect}_#{i}'/>").next_element
|
128
|
+
move.each do |m|
|
129
|
+
next if m.at("./ancestor::div[@class = '#{sect}_#{i}']")
|
130
|
+
ins << m.remove
|
131
|
+
end
|
132
|
+
end
|
78
133
|
end
|
79
134
|
end
|
@@ -43,11 +43,21 @@ module IsoDoc::WordFunction
|
|
43
43
|
}))
|
44
44
|
end
|
45
45
|
|
46
|
+
def colgroup(node, t)
|
47
|
+
colgroup = node.at(ns("./colgroup")) or return
|
48
|
+
t.colgroup do |cg|
|
49
|
+
colgroup.xpath(ns("./col")).each do |c|
|
50
|
+
cg.col **{ width: c["width"] }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
46
55
|
def table_parse(node, out)
|
47
56
|
@in_table = true
|
48
57
|
table_title_parse(node, out)
|
49
58
|
out.div **{ align: "center", class: "table_container" } do |div|
|
50
59
|
div.table **table_attrs(node) do |t|
|
60
|
+
colgroup(node, t)
|
51
61
|
thead_parse(node, t)
|
52
62
|
tbody_parse(node, t)
|
53
63
|
tfoot_parse(node, t)
|
data/lib/isodoc/xref.rb
CHANGED
@@ -49,6 +49,7 @@ module IsoDoc
|
|
49
49
|
note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
50
50
|
example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
51
51
|
list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
52
|
+
bookmark_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
52
53
|
end
|
53
54
|
|
54
55
|
def ns(xpath)
|
@@ -2,8 +2,8 @@ require "roman-numerals"
|
|
2
2
|
|
3
3
|
module IsoDoc::XrefGen
|
4
4
|
class Counter
|
5
|
-
def initialize
|
6
|
-
@num =
|
5
|
+
def initialize(num = 0)
|
6
|
+
@num = num
|
7
7
|
@letter = ""
|
8
8
|
@subseq = ""
|
9
9
|
@letter_override = nil
|
@@ -76,13 +76,24 @@ module IsoDoc::XrefGen
|
|
76
76
|
"#{@base}#{@number_override || @num}#{@letter_override || @letter}"
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
80
|
-
return
|
81
|
-
return
|
82
|
-
return
|
83
|
-
return
|
84
|
-
return
|
85
|
-
return
|
79
|
+
def ol_type(list, depth)
|
80
|
+
return list["type"].to_sym if list["type"]
|
81
|
+
return :arabic if [2, 7].include? depth
|
82
|
+
return :alphabet if [1, 6].include? depth
|
83
|
+
return :alphabet_upper if [4, 9].include? depth
|
84
|
+
return :roman if [3, 8].include? depth
|
85
|
+
return :roman_upper if [5, 10].include? depth
|
86
|
+
return :arabic
|
87
|
+
end
|
88
|
+
|
89
|
+
def listlabel(list, depth)
|
90
|
+
case ol_type(list, depth)
|
91
|
+
when :arabic then @num.to_s
|
92
|
+
when :alphabet then (96 + @num).chr.to_s
|
93
|
+
when :alphabet_upper then (64 + @num).chr.to_s
|
94
|
+
when :roman then RomanNumerals.to_roman(@num).downcase
|
95
|
+
when :roman_upper then RomanNumerals.to_roman(@num).upcase
|
96
|
+
end
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -66,6 +66,10 @@ module IsoDoc::XrefGen
|
|
66
66
|
"//sections/clause | //sections/definitions | "\
|
67
67
|
"//bibliography/references | //bibliography/clause".freeze
|
68
68
|
|
69
|
+
def sections_xpath
|
70
|
+
SECTIONS_XPATH
|
71
|
+
end
|
72
|
+
|
69
73
|
CHILD_NOTES_XPATH =
|
70
74
|
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
|
71
75
|
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:note | "\
|
@@ -123,9 +127,9 @@ module IsoDoc::XrefGen
|
|
123
127
|
end
|
124
128
|
|
125
129
|
def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
|
126
|
-
c = Counter.new
|
130
|
+
c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
|
127
131
|
list.xpath(ns("./li")).each do |li|
|
128
|
-
label = c.increment(li).listlabel(depth)
|
132
|
+
label = c.increment(li).listlabel(list, depth)
|
129
133
|
label = "#{prev_label}.#{label}" unless prev_label.empty?
|
130
134
|
label = "#{list_anchor[:xref]} #{label}" if refer_list
|
131
135
|
li["id"] and @anchors[li["id"]] =
|
@@ -136,5 +140,19 @@ module IsoDoc::XrefGen
|
|
136
140
|
end
|
137
141
|
end
|
138
142
|
end
|
143
|
+
|
144
|
+
def bookmark_anchor_names(sections)
|
145
|
+
sections.each do |s|
|
146
|
+
notes = s.xpath(ns(".//bookmark")) - s.xpath(ns(".//clause//bookmark")) -
|
147
|
+
s.xpath(ns(".//appendix//bookmark"))
|
148
|
+
notes.each do |n|
|
149
|
+
next if n["id"].nil? || n["id"].empty?
|
150
|
+
@anchors[n["id"]] = {
|
151
|
+
type: "bookmark", label: nil, value: nil,
|
152
|
+
xref: @anchors[s["id"]][:xref] }
|
153
|
+
end
|
154
|
+
bookmark_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
155
|
+
end
|
156
|
+
end
|
139
157
|
end
|
140
158
|
end
|
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -23,6 +23,10 @@ module IsoDoc
|
|
23
23
|
nil
|
24
24
|
end
|
25
25
|
|
26
|
+
def pdf_options(docxml)
|
27
|
+
""
|
28
|
+
end
|
29
|
+
|
26
30
|
def convert(input_filename, file = nil, debug = false, output_filename = nil)
|
27
31
|
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
28
32
|
docxml, filename, dir = convert_init(file, input_filename, debug)
|
@@ -34,7 +38,8 @@ module IsoDoc
|
|
34
38
|
FileUtils.rm_rf dir
|
35
39
|
::Metanorma::Output::XslfoPdf.new.convert(input_filename,
|
36
40
|
output_filename || "#{filename}.#{@suffix}",
|
37
|
-
File.join(@libdir, pdf_stylesheet(docxml))
|
41
|
+
File.join(@libdir, pdf_stylesheet(docxml)),
|
42
|
+
pdf_options(docxml))
|
38
43
|
end
|
39
44
|
|
40
45
|
def xref_parse(node, out)
|