isodoc 1.7.3 → 1.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +7 -4
- data/lib/isodoc/class_utils.rb +2 -2
- data/lib/isodoc/convert.rb +2 -0
- data/lib/isodoc/function/blocks_example_note.rb +85 -79
- data/lib/isodoc/function/cleanup.rb +181 -175
- data/lib/isodoc/function/inline.rb +110 -108
- data/lib/isodoc/function/inline_simple.rb +55 -55
- data/lib/isodoc/function/lists.rb +75 -71
- data/lib/isodoc/function/references.rb +165 -160
- data/lib/isodoc/function/section.rb +140 -190
- data/lib/isodoc/function/section_titles.rb +82 -0
- data/lib/isodoc/function/table.rb +90 -87
- data/lib/isodoc/function/terms.rb +58 -56
- data/lib/isodoc/function/to_word_html.rb +3 -1
- data/lib/isodoc/function/utils.rb +34 -14
- data/lib/isodoc/html_function/comments.rb +107 -111
- data/lib/isodoc/html_function/footnotes.rb +68 -67
- data/lib/isodoc/html_function/html.rb +113 -103
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
- data/lib/isodoc/presentation_function/block.rb +73 -78
- data/lib/isodoc/presentation_function/concept.rb +68 -0
- data/lib/isodoc/presentation_function/image.rb +112 -0
- data/lib/isodoc/presentation_function/inline.rb +6 -39
- data/lib/isodoc/presentation_function/math.rb +9 -0
- data/lib/isodoc/presentation_function/section.rb +12 -1
- data/lib/isodoc/presentation_xml_convert.rb +3 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +176 -174
- data/lib/isodoc/word_function/comments.rb +117 -112
- data/lib/isodoc/word_function/footnotes.rb +88 -86
- data/lib/isodoc/word_function/inline.rb +42 -67
- data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
- data/lib/isodoc/xref/xref_gen.rb +153 -150
- data/lib/isodoc/xslfo_convert.rb +2 -2
- data/lib/isodoc.rb +1 -1
- data/spec/assets/odf.svg +1 -4
- data/spec/isodoc/blocks_spec.rb +187 -32
- data/spec/isodoc/inline_spec.rb +300 -116
- data/spec/isodoc/postproc_spec.rb +38 -0
- data/spec/isodoc/presentation_xml_spec.rb +144 -0
- data/spec/isodoc/section_spec.rb +764 -0
- data/spec/isodoc/terms_spec.rb +116 -0
- metadata +63 -18
@@ -1,133 +1,144 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module IsoDoc
|
2
|
+
module WordFunction
|
3
|
+
module Postprocess
|
4
|
+
def word_preface(docxml)
|
5
|
+
word_cover(docxml) if @wordcoverpage
|
6
|
+
word_intro(docxml, @wordToClevels) if @wordintropage
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
def word_cover(docxml)
|
10
|
+
cover = File.read(@wordcoverpage, encoding: "UTF-8")
|
11
|
+
cover = populate_template(cover, :word)
|
12
|
+
coverxml = to_word_xhtml_fragment(cover)
|
13
|
+
docxml.at('//div[@class="WordSection1"]').children.first.previous =
|
14
|
+
coverxml.to_xml(encoding: "US-ASCII")
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
def word_intro(docxml, level)
|
18
|
+
intro = insert_toc(File.read(@wordintropage, encoding: "UTF-8"),
|
19
|
+
docxml, level)
|
20
|
+
intro = populate_template(intro, :word)
|
21
|
+
introxml = to_word_xhtml_fragment(intro)
|
22
|
+
docxml.at('//div[@class="WordSection2"]').children.first.previous =
|
23
|
+
introxml.to_xml(encoding: "US-ASCII")
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def insert_toc(intro, docxml, level)
|
27
|
+
intro.sub(/WORDTOC/, make_WordToC(docxml, level))
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<span lang="EN-GB"
|
40
|
-
class="MsoTocTextSpan"> PAGEREF _Toc#{bookmark} \\h </span>
|
41
|
-
<span lang="EN-GB" class="MsoTocTextSpan"><span
|
42
|
-
style='mso-element:field-separator'></span></span><span
|
43
|
-
lang="EN-GB" class="MsoTocTextSpan">1</span>
|
30
|
+
def word_toc_entry(toclevel, heading)
|
31
|
+
bookmark = bookmarkid # Random.rand(1000000000)
|
32
|
+
<<~TOC
|
33
|
+
<p class="MsoToc#{toclevel}"><span class="MsoHyperlink"><span
|
34
|
+
lang="EN-GB" style='mso-no-proof:yes'>
|
35
|
+
<a href="#_Toc#{bookmark}">#{heading}<span lang="EN-GB"
|
36
|
+
class="MsoTocTextSpan">
|
37
|
+
<span style='mso-tab-count:1 dotted'>. </span>
|
38
|
+
</span><span lang="EN-GB" class="MsoTocTextSpan">
|
39
|
+
<span style='mso-element:field-begin'></span></span>
|
44
40
|
<span lang="EN-GB"
|
45
|
-
class="MsoTocTextSpan"
|
46
|
-
|
47
|
-
|
41
|
+
class="MsoTocTextSpan"> PAGEREF _Toc#{bookmark} \\h </span>
|
42
|
+
<span lang="EN-GB" class="MsoTocTextSpan"><span
|
43
|
+
style='mso-element:field-separator'></span></span><span
|
44
|
+
lang="EN-GB" class="MsoTocTextSpan">1</span>
|
45
|
+
<span lang="EN-GB"
|
46
|
+
class="MsoTocTextSpan"></span><span
|
47
|
+
lang="EN-GB" class="MsoTocTextSpan"><span
|
48
|
+
style='mso-element:field-end'></span></span></a></span></span></p>
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
TOC
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
def word_toc_preface(level)
|
54
|
+
<<~TOC.freeze
|
55
|
+
<span lang="EN-GB"><span
|
56
|
+
style='mso-element:field-begin'></span><span
|
57
|
+
style='mso-spacerun:yes'> </span>TOC
|
58
|
+
\\o "1-#{level}" \\h \\z \\u <span
|
59
|
+
style='mso-element:field-separator'></span></span>
|
60
|
+
TOC
|
61
|
+
end
|
62
|
+
|
63
|
+
WORD_TOC_SUFFIX1 = <<~TOC.freeze
|
64
|
+
<p class="MsoToc1"><span lang="EN-GB"><span
|
65
|
+
style='mso-element:field-end'></span></span><span
|
66
|
+
lang="EN-GB"><o:p> </o:p></span></p>
|
59
67
|
TOC
|
60
|
-
end
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
xpath = (1..level).each.map { |i| "//h#{i}" }.join (" | ")
|
72
|
-
docxml.xpath(xpath).each do |h|
|
73
|
-
toc += word_toc_entry(h.name[1].to_i, header_strip(h))
|
69
|
+
def make_WordToC(docxml, level)
|
70
|
+
toc = ""
|
71
|
+
# docxml.xpath("//h1 | //h2[not(ancestor::*[@class = 'Section3'])]").
|
72
|
+
xpath = (1..level).each.map { |i| "//h#{i}" }.join (" | ")
|
73
|
+
docxml.xpath(xpath).each do |h|
|
74
|
+
toc += word_toc_entry(h.name[1].to_i, header_strip(h))
|
75
|
+
end
|
76
|
+
toc.sub(/(<p class="MsoToc1">)/,
|
77
|
+
%{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
|
74
78
|
end
|
75
|
-
toc.sub(/(<p class="MsoToc1">)/,
|
76
|
-
%{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
|
77
|
-
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
def authority_cleanup1(docxml, klass)
|
81
|
+
dest = docxml.at("//div[@id = 'boilerplate-#{klass}-destination']")
|
82
|
+
auth = docxml.at("//div[@id = 'boilerplate-#{klass}' "\
|
83
|
+
"or @class = 'boilerplate-#{klass}']")
|
84
|
+
auth&.xpath(".//h1[not(text())] | .//h2[not(text())]")&.each(&:remove)
|
85
|
+
auth&.xpath(".//h1 | .//h2")&.each do |h|
|
86
|
+
h.name = "p"
|
87
|
+
h["class"] = "TitlePageSubhead"
|
88
|
+
end
|
89
|
+
dest and auth and dest.replace(auth.remove)
|
86
90
|
end
|
87
|
-
dest and auth and dest.replace(auth.remove)
|
88
|
-
end
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
-
|
92
|
+
def authority_cleanup(docxml)
|
93
|
+
%w(copyright license legal feedback).each do |t|
|
94
|
+
authority_cleanup1(docxml, t)
|
95
|
+
end
|
93
96
|
end
|
94
|
-
end
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
f
|
98
|
+
def generate_header(filename, _dir)
|
99
|
+
return nil unless @header
|
100
|
+
|
101
|
+
template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
|
102
|
+
meta = @meta.get.merge(@labels ? { labels: @labels } : {})
|
103
|
+
.merge(@meta.labels ? { labels: @meta.labels } : {})
|
104
|
+
meta[:filename] = filename
|
105
|
+
params = meta.transform_keys(&:to_s)
|
106
|
+
Tempfile.open(%w(header html), encoding: "utf-8") do |f|
|
107
|
+
f.write(template.render(params))
|
108
|
+
f
|
109
|
+
end
|
105
110
|
end
|
106
|
-
end
|
107
111
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
def word_section_breaks(docxml)
|
113
|
+
@landscapestyle = ""
|
114
|
+
word_section_breaks1(docxml, "WordSection2")
|
115
|
+
word_section_breaks1(docxml, "WordSection3")
|
116
|
+
word_remove_pb_before_annex(docxml)
|
117
|
+
docxml.xpath("//br[@orientation]").each do |br|
|
118
|
+
br.delete("orientation")
|
119
|
+
end
|
120
|
+
end
|
115
121
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
122
|
+
def word_section_breaks1(docxml, sect)
|
123
|
+
docxml.xpath("//div[@class = '#{sect}']//br[@orientation]").reverse
|
124
|
+
.each_with_index do |br, i|
|
125
|
+
@landscapestyle +=
|
126
|
+
"\ndiv.#{sect}_#{i} {page:#{sect}"\
|
127
|
+
"#{br['orientation'] == 'landscape' ? 'L' : 'P'};}\n"
|
128
|
+
split_at_section_break(docxml, sect, br, i)
|
129
|
+
end
|
121
130
|
end
|
122
|
-
end
|
123
131
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
132
|
+
def split_at_section_break(docxml, sect, brk, idx)
|
133
|
+
move = brk.parent.xpath("following::node()") &
|
134
|
+
brk.document.xpath("//div[@class = '#{sect}']//*")
|
135
|
+
ins = docxml.at("//div[@class = '#{sect}']")
|
136
|
+
.after("<div class='#{sect}_#{idx}'/>").next_element
|
137
|
+
move.each do |m|
|
138
|
+
next if m.at("./ancestor::div[@class = '#{sect}_#{idx}']")
|
139
|
+
|
140
|
+
ins << m.remove
|
141
|
+
end
|
131
142
|
end
|
132
143
|
end
|
133
144
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -1,198 +1,201 @@
|
|
1
1
|
require_relative "xref_gen_seq"
|
2
2
|
|
3
|
-
module IsoDoc
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
a
|
13
|
-
|
14
|
-
|
3
|
+
module IsoDoc
|
4
|
+
module XrefGen
|
5
|
+
module Blocks
|
6
|
+
NUMBERED_BLOCKS = %w(termnote termexample note example requirement
|
7
|
+
recommendation permission figure table formula
|
8
|
+
admonition sourcecode).freeze
|
9
|
+
|
10
|
+
def amend_preprocess(xmldoc)
|
11
|
+
xmldoc.xpath(ns("//amend[newcontent]")).each do |a|
|
12
|
+
autonum = amend_autonums(a)
|
13
|
+
NUMBERED_BLOCKS.each do |b|
|
14
|
+
a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i|
|
15
|
+
autonum[b] && i.zero? and e["number"] = autonum[b]
|
16
|
+
!autonum[b] and e["unnumbered"] = "true"
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
18
|
-
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def amend_autonums(amend)
|
23
|
+
autonum = {}
|
24
|
+
amend.xpath(ns("./autonumber")).each do |n|
|
25
|
+
autonum[n["type"]] = n.text
|
26
|
+
end
|
27
|
+
autonum
|
24
28
|
end
|
25
|
-
autonum
|
26
|
-
end
|
27
|
-
|
28
|
-
def termnote_label(note)
|
29
|
-
@labels["termnote"].gsub(/%/, note.to_s)
|
30
|
-
end
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
def termnote_label(note)
|
31
|
+
@labels["termnote"].gsub(/%/, note.to_s)
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
34
|
+
def increment_label(elems, node, counter, increment = true)
|
35
|
+
return "" if elems.size == 1 && !node["number"]
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
t.xpath(ns(".//termnote")).each do |n|
|
43
|
-
next if n["id"].nil? || n["id"].empty?
|
37
|
+
counter.increment(node) if increment
|
38
|
+
" #{counter.print}"
|
39
|
+
end
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
def termnote_anchor_names(docxml)
|
42
|
+
docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
|
43
|
+
c = Counter.new
|
44
|
+
t.xpath(ns(".//termnote")).each do |n|
|
45
|
+
next if n["id"].nil? || n["id"].empty?
|
46
|
+
|
47
|
+
c.increment(n)
|
48
|
+
@anchors[n["id"]] =
|
49
|
+
{ label: termnote_label(c.print), type: "termnote", value: c.print,
|
50
|
+
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
51
|
+
"#{@labels['note_xref']} #{c.print}") }
|
52
|
+
end
|
50
53
|
end
|
51
54
|
end
|
52
|
-
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
def termexample_anchor_names(docxml)
|
57
|
+
docxml.xpath(ns("//term[descendant::termexample]")).each do |t|
|
58
|
+
examples = t.xpath(ns(".//termexample"))
|
59
|
+
c = Counter.new
|
60
|
+
examples.each do |n|
|
61
|
+
next if n["id"].nil? || n["id"].empty?
|
62
|
+
|
63
|
+
c.increment(n)
|
64
|
+
idx = increment_label(examples, n, c, false)
|
65
|
+
@anchors[n["id"]] =
|
66
|
+
{ type: "termexample", label: idx, value: c.print,
|
67
|
+
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
68
|
+
"#{@labels['example_xref']} #{c.print}") }
|
69
|
+
end
|
67
70
|
end
|
68
71
|
end
|
69
|
-
end
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
SECTIONS_XPATH =
|
74
|
+
"//foreword | //introduction | //acknowledgements | "\
|
75
|
+
"//preface/terms | preface/definitions | preface/references | "\
|
76
|
+
"//preface/clause | //sections/terms | //annex | "\
|
77
|
+
"//sections/clause | //sections/definitions | "\
|
78
|
+
"//bibliography/references | //bibliography/clause".freeze
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
def sections_xpath
|
81
|
+
SECTIONS_XPATH
|
82
|
+
end
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
84
|
+
CHILD_NOTES_XPATH =
|
85
|
+
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
|
86
|
+
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:note | "\
|
87
|
+
"./xmlns:note".freeze
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
def note_anchor_names(sections)
|
90
|
+
sections.each do |s|
|
91
|
+
c = Counter.new
|
92
|
+
(notes = s.xpath(CHILD_NOTES_XPATH)).each do |n|
|
93
|
+
next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
@anchors[n["id"]] =
|
96
|
+
anchor_struct(increment_label(notes, n, c), n,
|
97
|
+
@labels["note_xref"], "note", false)
|
98
|
+
end
|
99
|
+
note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
96
100
|
end
|
97
|
-
note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
98
101
|
end
|
99
|
-
end
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
CHILD_EXAMPLES_XPATH =
|
104
|
+
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
|
105
|
+
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//"\
|
106
|
+
"xmlns:example | ./xmlns:example".freeze
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
+
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | "\
|
109
|
+
"./references".freeze
|
108
110
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
def example_anchor_names(sections)
|
112
|
+
sections.each do |s|
|
113
|
+
c = Counter.new
|
114
|
+
(notes = s.xpath(CHILD_EXAMPLES_XPATH)).each do |n|
|
115
|
+
next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
-
|
117
|
+
@anchors[n["id"]] =
|
118
|
+
anchor_struct(increment_label(notes, n, c), n,
|
119
|
+
@labels["example_xref"], "example", n["unnumbered"])
|
120
|
+
end
|
121
|
+
example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
118
122
|
end
|
119
|
-
example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
120
123
|
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def list_anchor_names(sections)
|
124
|
-
sections.each do |s|
|
125
|
-
notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
|
126
|
-
s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
|
127
|
-
c = Counter.new
|
128
|
-
notes.each do |n|
|
129
|
-
next if n["id"].nil? || n["id"].empty?
|
130
124
|
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
def list_anchor_names(sections)
|
126
|
+
sections.each do |s|
|
127
|
+
notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
|
128
|
+
s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
|
129
|
+
c = Counter.new
|
130
|
+
notes.each do |n|
|
131
|
+
next if n["id"].nil? || n["id"].empty?
|
132
|
+
|
133
|
+
@anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
|
134
|
+
@labels["list"], "list", false)
|
135
|
+
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
136
|
+
end
|
137
|
+
list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
134
138
|
end
|
135
|
-
list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
136
139
|
end
|
137
|
-
end
|
138
140
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
141
|
+
def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
|
142
|
+
c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
|
143
|
+
list.xpath(ns("./li")).each do |li|
|
144
|
+
label = c.increment(li).listlabel(list, depth)
|
145
|
+
label = "#{prev_label}.#{label}" unless prev_label.empty?
|
146
|
+
label = "#{list_anchor[:xref]} #{label}" if refer_list
|
147
|
+
li["id"] and @anchors[li["id"]] =
|
148
|
+
{ xref: "#{label})", type: "listitem",
|
149
|
+
container: list_anchor[:container] }
|
150
|
+
li.xpath(ns("./ol")).each do |ol|
|
151
|
+
list_item_anchor_names(ol, list_anchor, depth + 1, label, false)
|
152
|
+
end
|
150
153
|
end
|
151
154
|
end
|
152
|
-
end
|
153
155
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
156
|
+
def deflist_anchor_names(sections)
|
157
|
+
sections.each do |s|
|
158
|
+
notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
|
159
|
+
s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
|
160
|
+
c = Counter.new
|
161
|
+
notes.each do |n|
|
162
|
+
next if n["id"].nil? || n["id"].empty?
|
163
|
+
|
164
|
+
@anchors[n["id"]] =
|
165
|
+
anchor_struct(increment_label(notes, n, c), n,
|
166
|
+
@labels["deflist"], "deflist", false)
|
167
|
+
deflist_term_anchor_names(n, @anchors[n["id"]])
|
168
|
+
end
|
169
|
+
deflist_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
166
170
|
end
|
167
|
-
deflist_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
168
171
|
end
|
169
|
-
end
|
170
172
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
173
|
+
def deflist_term_anchor_names(list, list_anchor)
|
174
|
+
list.xpath(ns("./dt")).each do |li|
|
175
|
+
label = li.text
|
176
|
+
label = l10n("#{list_anchor[:xref]}: #{label}")
|
177
|
+
li["id"] and @anchors[li["id"]] =
|
178
|
+
{ xref: label, type: "deflistitem",
|
179
|
+
container: list_anchor[:container] }
|
180
|
+
li.xpath(ns("./dl")).each do |dl|
|
181
|
+
deflist_term_anchor_names(dl, list_anchor)
|
182
|
+
end
|
180
183
|
end
|
181
184
|
end
|
182
|
-
end
|
183
185
|
|
184
|
-
|
185
|
-
|
186
|
-
|
186
|
+
def bookmark_anchor_names(docxml)
|
187
|
+
docxml.xpath(ns(".//bookmark")).each do |n|
|
188
|
+
next if n["id"].nil? || n["id"].empty?
|
187
189
|
|
188
|
-
|
189
|
-
|
190
|
-
|
190
|
+
parent = nil
|
191
|
+
n.ancestors.each do |a|
|
192
|
+
next unless a["id"] && parent = @anchors.dig(a["id"], :xref)
|
191
193
|
|
192
|
-
|
194
|
+
break
|
195
|
+
end
|
196
|
+
@anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
|
197
|
+
xref: parent || "???" }
|
193
198
|
end
|
194
|
-
@anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
|
195
|
-
xref: parent || "???" }
|
196
199
|
end
|
197
200
|
end
|
198
201
|
end
|
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -37,12 +37,12 @@ module IsoDoc
|
|
37
37
|
input_filename,
|
38
38
|
output_filename || "#{filename}.#{@suffix}",
|
39
39
|
File.join(@libdir, pdf_stylesheet(docxml)),
|
40
|
-
pdf_options(docxml)
|
40
|
+
pdf_options(docxml),
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
44
44
|
def xref_parse(node, out)
|
45
|
-
out.a(**{
|
45
|
+
out.a(**{ href: target_pdf(node) }) { |l| l << get_linkend(node) }
|
46
46
|
end
|
47
47
|
|
48
48
|
def input_xml_path(input_filename, xml_file, debug)
|
data/lib/isodoc.rb
CHANGED
@@ -17,8 +17,8 @@ require "isodoc/convert"
|
|
17
17
|
require "isodoc/metadata"
|
18
18
|
require "isodoc/html_convert"
|
19
19
|
require "isodoc/word_convert"
|
20
|
-
require "isodoc/pdf_convert"
|
21
20
|
require "isodoc/xslfo_convert"
|
21
|
+
require "isodoc/pdf_convert"
|
22
22
|
require "isodoc/headlesshtml_convert"
|
23
23
|
require "isodoc/presentation_xml_convert"
|
24
24
|
require "isodoc/xref"
|
data/spec/assets/odf.svg
CHANGED
@@ -1,4 +1 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
2
|
-
<circle fill="#009" r="45" cx="50" cy="50"/>
|
3
|
-
<path d="M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z" fill="#FFF"/>
|
4
|
-
</svg>
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle fill="#009" r="45" cx="50" cy="50"/><path d="M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z" fill="#FFF"/></svg>
|