isodoc 1.0.28 → 1.1.3.pre.alpha
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/macos.yml +4 -8
- data/.github/workflows/ubuntu.yml +18 -16
- data/.github/workflows/windows.yml +4 -8
- data/Rakefile +3 -1
- data/isodoc.gemspec +2 -2
- data/lib/isodoc.rb +2 -0
- data/lib/isodoc/base_style/metanorma_word.scss +0 -1
- data/lib/isodoc/base_style/reset.scss +3 -3
- data/lib/isodoc/common.rb +0 -4
- data/lib/isodoc/convert.rb +121 -58
- data/lib/isodoc/function/blocks.rb +42 -53
- data/lib/isodoc/function/blocks_example_note.rb +108 -0
- data/lib/isodoc/function/i18n.rb +1 -0
- data/lib/isodoc/function/inline.rb +25 -8
- data/lib/isodoc/function/lists.rb +12 -6
- data/lib/isodoc/function/references.rb +31 -36
- data/lib/isodoc/function/reqt.rb +14 -5
- data/lib/isodoc/function/section.rb +7 -11
- data/lib/isodoc/function/table.rb +4 -4
- data/lib/isodoc/function/terms.rb +3 -3
- data/lib/isodoc/function/to_word_html.rb +2 -2
- data/lib/isodoc/function/utils.rb +57 -50
- data/lib/isodoc/gem_tasks.rb +110 -0
- data/lib/isodoc/headlesshtml_convert.rb +7 -6
- data/lib/isodoc/html_convert.rb +2 -1
- data/lib/isodoc/html_function/html.rb +2 -2
- data/lib/isodoc/html_function/postprocess.rb +1 -1
- data/lib/isodoc/metadata.rb +69 -63
- data/lib/isodoc/pdf_convert.rb +8 -6
- data/lib/isodoc/presentation_xml_convert.rb +29 -0
- data/lib/isodoc/sassc_importer.rb +11 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +2 -1
- data/lib/isodoc/word_function/body.rb +14 -48
- data/lib/isodoc/word_function/inline.rb +75 -0
- data/lib/isodoc/word_function/postprocess.rb +1 -0
- data/lib/isodoc/word_function/table.rb +3 -3
- data/lib/isodoc/xref.rb +59 -0
- data/lib/isodoc/{function → xref}/xref_anchor.rb +10 -21
- data/lib/isodoc/xref/xref_counter.rb +74 -0
- data/lib/isodoc/{function → xref}/xref_gen.rb +9 -22
- data/lib/isodoc/{function → xref}/xref_gen_seq.rb +41 -32
- data/lib/isodoc/{function → xref}/xref_sect_gen.rb +33 -23
- data/lib/isodoc/xslfo_convert.rb +16 -4
- data/spec/assets/{html.css → html.scss} +0 -0
- data/spec/assets/odf.emf +0 -0
- data/spec/assets/odf.svg +4 -0
- data/spec/assets/odf1.svg +4 -0
- data/spec/isodoc/blocks_spec.rb +216 -44
- data/spec/isodoc/footnotes_spec.rb +2 -2
- data/spec/isodoc/inline_spec.rb +208 -1
- data/spec/isodoc/lists_spec.rb +8 -8
- data/spec/isodoc/metadata_spec.rb +107 -3
- data/spec/isodoc/postproc_spec.rb +1320 -1350
- data/spec/isodoc/presentation_xml_spec.rb +20 -0
- data/spec/isodoc/ref_spec.rb +5 -5
- data/spec/isodoc/section_spec.rb +52 -0
- data/spec/isodoc/table_spec.rb +4 -4
- data/spec/isodoc/terms_spec.rb +7 -7
- data/spec/isodoc/xref_spec.rb +165 -45
- metadata +37 -29
- data/lib/isodoc/function/blocks_example.rb +0 -53
- data/lib/isodoc/function/xref_counter.rb +0 -50
@@ -16,18 +16,19 @@ module IsoDoc
|
|
16
16
|
|
17
17
|
def initialize(options)
|
18
18
|
@format = :html
|
19
|
+
@suffix = "headless.html"
|
19
20
|
super
|
20
21
|
end
|
21
22
|
|
22
|
-
def convert(
|
23
|
-
file = File.read(
|
23
|
+
def convert(input_filename, file = nil, debug = false, output_filename = nil)
|
24
|
+
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
24
25
|
@openmathdelim, @closemathdelim = extract_delims(file)
|
25
|
-
docxml,
|
26
|
-
result = convert1(docxml,
|
26
|
+
docxml, filename, dir = convert_init(file, input_filename, debug)
|
27
|
+
result = convert1(docxml, filename, dir)
|
27
28
|
return result if debug
|
28
|
-
postprocess(result, filename + ".tmp", dir)
|
29
|
+
postprocess(result, filename + ".tmp.html", dir)
|
29
30
|
FileUtils.rm_rf dir
|
30
|
-
strip_head(filename + ".tmp.html",
|
31
|
+
strip_head(filename + ".tmp.html", output_filename || "#{filename}.#{@suffix}")
|
31
32
|
FileUtils.rm_rf ["#{filename}.tmp.html", tmpimagedir]
|
32
33
|
end
|
33
34
|
|
data/lib/isodoc/html_convert.rb
CHANGED
@@ -16,10 +16,11 @@ module IsoDoc
|
|
16
16
|
|
17
17
|
def initialize(options)
|
18
18
|
@format = :html
|
19
|
+
@suffix = "html"
|
19
20
|
super
|
20
21
|
end
|
21
22
|
|
22
|
-
def convert(filename, file = nil, debug = false)
|
23
|
+
def convert(filename, file = nil, debug = false, output_filename = nil)
|
23
24
|
ret = super
|
24
25
|
Dir.exists?(tmpimagedir) and Dir["#{tmpimagedir}/*"].empty? and
|
25
26
|
FileUtils.rm_r tmpimagedir
|
@@ -4,7 +4,7 @@ require "base64"
|
|
4
4
|
module IsoDoc::HtmlFunction
|
5
5
|
module Html
|
6
6
|
def convert1(docxml, filename, dir)
|
7
|
-
|
7
|
+
@xrefs.parse docxml
|
8
8
|
noko do |xml|
|
9
9
|
xml.html **{ lang: "#{@lang}" } do |html|
|
10
10
|
info docxml, nil
|
@@ -102,7 +102,7 @@ module IsoDoc::HtmlFunction
|
|
102
102
|
def sourcecode_parse(node, out)
|
103
103
|
name = node.at(ns("./name"))
|
104
104
|
class1 = "prettyprint #{sourcecodelang(node&.at(ns('./@lang'))&.value)}"
|
105
|
-
out.pre **
|
105
|
+
out.pre **sourcecode_attrs(node).merge(class: class1) do |div|
|
106
106
|
@sourcecode = true
|
107
107
|
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
108
108
|
@sourcecode = false
|
@@ -18,7 +18,7 @@ module IsoDoc::HtmlFunction
|
|
18
18
|
#result = populate_template(result, :html)
|
19
19
|
result = from_xhtml(move_images(to_xhtml(result)))
|
20
20
|
result = html5(script_cdata(inject_script(result)))
|
21
|
-
File.open(
|
21
|
+
File.open(filename, "w:UTF-8") { |f| f.write(result) }
|
22
22
|
end
|
23
23
|
|
24
24
|
def html5(doc)
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './metadata_date'
|
2
4
|
|
3
5
|
module IsoDoc
|
4
6
|
class Metadata
|
5
7
|
DATETYPES = %w{published accessed created implemented obsoleted confirmed
|
6
|
-
|
7
|
-
|
8
|
+
updated issued received transmitted copied unchanged
|
9
|
+
circulated vote-started
|
10
|
+
vote-ended}.freeze
|
11
|
+
|
12
|
+
attr_accessor :fonts_options
|
8
13
|
|
9
14
|
def ns(xpath)
|
10
15
|
Common::ns(xpath)
|
@@ -14,13 +19,14 @@ module IsoDoc
|
|
14
19
|
IsoDoc::Function::I18n::l10n(a, b, c)
|
15
20
|
end
|
16
21
|
|
17
|
-
def initialize(lang, script, labels)
|
22
|
+
def initialize(lang, script, labels, fonts_options = {})
|
18
23
|
@metadata = {}
|
19
|
-
DATETYPES.each { |w| @metadata["#{w.gsub(/-/,
|
24
|
+
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = 'XXX' }
|
20
25
|
@lang = lang
|
21
26
|
@script = script
|
22
27
|
@c = HTMLEntities.new
|
23
28
|
@labels = labels
|
29
|
+
@fonts_options = fonts_options
|
24
30
|
end
|
25
31
|
|
26
32
|
def get
|
@@ -36,26 +42,26 @@ module IsoDoc
|
|
36
42
|
end
|
37
43
|
|
38
44
|
def extract_person_names(authors)
|
39
|
-
authors.
|
40
|
-
if a.at(ns(
|
41
|
-
ret << a.at(ns(
|
45
|
+
authors.reduce([]) do |ret, a|
|
46
|
+
if a.at(ns('./name/completename'))
|
47
|
+
ret << a.at(ns('./name/completename')).text
|
42
48
|
else
|
43
49
|
fn = []
|
44
|
-
forenames = a.xpath(ns(
|
50
|
+
forenames = a.xpath(ns('./name/forename'))
|
45
51
|
forenames.each { |f| fn << f.text }
|
46
|
-
surname = a&.at(ns(
|
47
|
-
ret << fn.join(
|
52
|
+
surname = a&.at(ns('./name/surname'))&.text
|
53
|
+
ret << fn.join(' ') + ' ' + surname
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
58
|
def extract_person_affiliations(authors)
|
53
|
-
authors.
|
54
|
-
name = a&.at(ns(
|
55
|
-
location = a&.at(ns(
|
56
|
-
|
57
|
-
m << (
|
58
|
-
(name || location ||
|
59
|
+
authors.reduce([]) do |m, a|
|
60
|
+
name = a&.at(ns('./affiliation/organization/name'))&.text
|
61
|
+
location = a&.at(ns('./affiliation/organization/address/'\
|
62
|
+
'formattedAddress'))&.text
|
63
|
+
m << (!name.nil? && !location.nil? ? "#{name}, #{location}" :
|
64
|
+
(name || location || ''))
|
59
65
|
m
|
60
66
|
end
|
61
67
|
end
|
@@ -84,99 +90,99 @@ module IsoDoc
|
|
84
90
|
end
|
85
91
|
|
86
92
|
def bibdate(isoxml, _out)
|
87
|
-
isoxml.xpath(ns(
|
88
|
-
set("#{d['type'].gsub(/-/,
|
93
|
+
isoxml.xpath(ns('//bibdata/date')).each do |d|
|
94
|
+
set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
|
89
95
|
end
|
90
96
|
end
|
91
97
|
|
92
98
|
def doctype(isoxml, _out)
|
93
|
-
b = isoxml&.at(ns(
|
94
|
-
t = b.split(/[- ]/).map
|
99
|
+
b = isoxml&.at(ns('//bibdata/ext/doctype'))&.text || return
|
100
|
+
t = b.split(/[- ]/).map(&:capitalize).join(' ')
|
95
101
|
set(:doctype, t)
|
96
102
|
end
|
97
103
|
|
98
104
|
def iso?(org)
|
99
|
-
name = org&.at(ns(
|
100
|
-
abbrev = org&.at(ns(
|
101
|
-
(abbrev ==
|
102
|
-
name ==
|
105
|
+
name = org&.at(ns('./name'))&.text
|
106
|
+
abbrev = org&.at(ns('./abbreviation'))&.text
|
107
|
+
(abbrev == 'ISO' ||
|
108
|
+
name == 'International Organization for Standardization')
|
103
109
|
end
|
104
110
|
|
105
111
|
def agency(xml)
|
106
|
-
agency =
|
112
|
+
agency = ''
|
107
113
|
publisher = []
|
108
114
|
xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
|
109
|
-
|
110
|
-
name = org&.at(ns(
|
111
|
-
agency1 = org&.at(ns(
|
115
|
+
'organization')).each do |org|
|
116
|
+
name = org&.at(ns('./name'))&.text
|
117
|
+
agency1 = org&.at(ns('./abbreviation'))&.text || name
|
112
118
|
publisher << name if name
|
113
|
-
agency = iso?(org) ?
|
119
|
+
agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
|
114
120
|
end
|
115
|
-
set(:agency, agency.sub(%r{/$},
|
116
|
-
set(:publisher, multiple_and(publisher, @labels[
|
121
|
+
set(:agency, agency.sub(%r{/$}, ''))
|
122
|
+
set(:publisher, multiple_and(publisher, @labels['and']))
|
117
123
|
end
|
118
124
|
|
119
125
|
def multiple_and(names, andword)
|
120
|
-
return
|
126
|
+
return '' if names.empty?
|
121
127
|
return names[0] if names.length == 1
|
122
|
-
names.length == 2
|
123
|
-
return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script)
|
124
|
-
l10n(names[0..-2].join(
|
128
|
+
(names.length == 2) &&
|
129
|
+
(return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
|
130
|
+
l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
|
125
131
|
end
|
126
132
|
|
127
133
|
def docstatus(isoxml, _out)
|
128
|
-
docstatus = isoxml.at(ns(
|
134
|
+
docstatus = isoxml.at(ns('//bibdata/status/stage'))
|
129
135
|
set(:unpublished, true)
|
130
136
|
if docstatus
|
131
137
|
set(:stage, status_print(docstatus.text))
|
132
|
-
i = isoxml&.at(ns(
|
138
|
+
(i = isoxml&.at(ns('//bibdata/status/substage'))&.text) &&
|
133
139
|
set(:substage, i)
|
134
|
-
i = isoxml&.at(ns(
|
140
|
+
(i = isoxml&.at(ns('//bibdata/status/iteration'))&.text) &&
|
135
141
|
set(:iteration, i)
|
136
142
|
set(:unpublished, unpublished(docstatus.text))
|
137
|
-
unpublished(docstatus.text)
|
143
|
+
unpublished(docstatus.text) &&
|
138
144
|
set(:stageabbr, stage_abbr(docstatus.text))
|
139
145
|
end
|
140
146
|
end
|
141
147
|
|
142
148
|
def stage_abbr(docstatus)
|
143
|
-
status_print(docstatus).split(/ /)
|
144
|
-
|
149
|
+
status_print(docstatus).split(/ /)
|
150
|
+
.map { |s| s[0].upcase }.join('')
|
145
151
|
end
|
146
152
|
|
147
153
|
def unpublished(status)
|
148
|
-
!
|
154
|
+
!status.casecmp('published').zero?
|
149
155
|
end
|
150
156
|
|
151
157
|
def status_print(status)
|
152
|
-
status.split(/-/).map
|
158
|
+
status.split(/-/).map(&:capitalize).join(' ')
|
153
159
|
end
|
154
160
|
|
155
161
|
def docid(isoxml, _out)
|
156
|
-
dn = isoxml.at(ns(
|
162
|
+
dn = isoxml.at(ns('//bibdata/docidentifier'))
|
157
163
|
set(:docnumber, dn&.text)
|
158
164
|
end
|
159
165
|
|
160
166
|
def docnumeric(isoxml, _out)
|
161
|
-
dn = isoxml.at(ns(
|
167
|
+
dn = isoxml.at(ns('//bibdata/docnumber'))
|
162
168
|
set(:docnumeric, dn&.text)
|
163
169
|
end
|
164
170
|
|
165
171
|
def draftinfo(draft, revdate)
|
166
|
-
draftinfo =
|
172
|
+
draftinfo = ''
|
167
173
|
if draft
|
168
|
-
draftinfo = " (#{@labels[
|
174
|
+
draftinfo = " (#{@labels['draft_label']} #{draft}"
|
169
175
|
draftinfo += ", #{revdate}" if revdate
|
170
|
-
draftinfo +=
|
176
|
+
draftinfo += ')'
|
171
177
|
end
|
172
178
|
l10n(draftinfo, @lang, @script)
|
173
179
|
end
|
174
180
|
|
175
181
|
def version(isoxml, _out)
|
176
|
-
set(:edition, isoxml&.at(ns(
|
177
|
-
set(:docyear, isoxml&.at(ns(
|
178
|
-
set(:draft, isoxml&.at(ns(
|
179
|
-
revdate = isoxml&.at(ns(
|
182
|
+
set(:edition, isoxml&.at(ns('//bibdata/edition'))&.text)
|
183
|
+
set(:docyear, isoxml&.at(ns('//bibdata/copyright/from'))&.text)
|
184
|
+
set(:draft, isoxml&.at(ns('//version/draft'))&.text)
|
185
|
+
revdate = isoxml&.at(ns('//version/revision-date'))&.text
|
180
186
|
set(:revdate, revdate)
|
181
187
|
set(:revdate_monthyear, monthyr(revdate))
|
182
188
|
set(:draftinfo,
|
@@ -188,7 +194,7 @@ module IsoDoc
|
|
188
194
|
set(:doctitle, main)
|
189
195
|
end
|
190
196
|
|
191
|
-
def subtitle(
|
197
|
+
def subtitle(_isoxml, _out)
|
192
198
|
nil
|
193
199
|
end
|
194
200
|
|
@@ -199,29 +205,29 @@ module IsoDoc
|
|
199
205
|
|
200
206
|
def relations_partof(isoxml)
|
201
207
|
std = isoxml.at(ns("//bibdata/relation[@type = 'partOf']")) || return
|
202
|
-
id = std.at(ns(
|
208
|
+
id = std.at(ns('.//docidentifier'))
|
203
209
|
set(:partof, id.text) if id
|
204
210
|
end
|
205
211
|
|
206
212
|
def relations_obsoletes(isoxml)
|
207
213
|
std = isoxml.at(ns("//bibdata/relation[@type = 'obsoletes']")) || return
|
208
|
-
locality = std.at(ns(
|
209
|
-
id = std.at(ns(
|
214
|
+
locality = std.at(ns('.//locality'))
|
215
|
+
id = std.at(ns('.//docidentifier'))
|
210
216
|
set(:obsoletes, id.text) if id
|
211
217
|
set(:obsoletes_part, locality.text) if locality
|
212
218
|
end
|
213
219
|
|
214
220
|
def url(xml, _out)
|
215
|
-
a = xml.at(ns(
|
216
|
-
a = xml.at(ns("//bibdata/uri[@type = 'html']"))
|
217
|
-
a = xml.at(ns("//bibdata/uri[@type = 'xml']"))
|
218
|
-
a = xml.at(ns("//bibdata/uri[@type = 'pdf']"))
|
219
|
-
a = xml.at(ns("//bibdata/uri[@type = 'doc']"))
|
221
|
+
(a = xml.at(ns('//bibdata/uri[not(@type)]'))) && set(:url, a.text)
|
222
|
+
(a = xml.at(ns("//bibdata/uri[@type = 'html']"))) && set(:html, a.text)
|
223
|
+
(a = xml.at(ns("//bibdata/uri[@type = 'xml']"))) && set(:xml, a.text)
|
224
|
+
(a = xml.at(ns("//bibdata/uri[@type = 'pdf']"))) && set(:pdf, a.text)
|
225
|
+
(a = xml.at(ns("//bibdata/uri[@type = 'doc']"))) && set(:doc, a.text)
|
220
226
|
end
|
221
227
|
|
222
228
|
def keywords(isoxml, _out)
|
223
229
|
ret = []
|
224
|
-
isoxml.xpath(ns(
|
230
|
+
isoxml.xpath(ns('//bibdata/keyword')).each { |kw| ret << kw.text }
|
225
231
|
set(:keywords, ret)
|
226
232
|
end
|
227
233
|
end
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -24,19 +24,21 @@ module IsoDoc
|
|
24
24
|
|
25
25
|
def initialize(options)
|
26
26
|
@format = :pdf
|
27
|
+
@suffix = "pdf"
|
27
28
|
super
|
28
29
|
end
|
29
30
|
|
30
|
-
def convert(
|
31
|
-
file = File.read(
|
31
|
+
def convert(input_filename, file = nil, debug = false, output_filename = nil)
|
32
|
+
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
32
33
|
@openmathdelim, @closemathdelim = extract_delims(file)
|
33
|
-
docxml,
|
34
|
+
docxml, filename, dir = convert_init(file, input_filename, debug)
|
34
35
|
result = convert1(docxml, filename, dir)
|
35
36
|
return result if debug
|
36
|
-
postprocess(result, filename, dir)
|
37
|
+
postprocess(result, filename + ".tmp.html", dir)
|
37
38
|
FileUtils.rm_rf dir
|
38
|
-
::Metanorma::Output::Pdf.new.convert("#{filename}.html",
|
39
|
-
|
39
|
+
::Metanorma::Output::Pdf.new.convert("#{filename}.tmp.html",
|
40
|
+
output_filename || "#{filename}.#{@suffix}")
|
41
|
+
FileUtils.rm_rf ["#{filename}.tmp.html", tmpimagedir]
|
40
42
|
end
|
41
43
|
|
42
44
|
def xref_parse(node, out)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def initialize(options)
|
4
|
+
@format = :presentation
|
5
|
+
@suffix = "presentation.xml"
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def convert1(docxml, filename, dir)
|
10
|
+
@xrefs.parse docxml
|
11
|
+
info docxml, nil
|
12
|
+
docxml.to_xml
|
13
|
+
end
|
14
|
+
|
15
|
+
def postprocess(result, filename, dir)
|
16
|
+
#result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
|
17
|
+
toXML(result, filename)
|
18
|
+
@files_to_delete.each { |f| FileUtils.rm_rf f }
|
19
|
+
end
|
20
|
+
|
21
|
+
def toXML(result, filename)
|
22
|
+
#result = (from_xhtml(html_cleanup(to_xhtml(result))))
|
23
|
+
#result = from_xhtml(move_images(to_xhtml(result)))
|
24
|
+
#result = html5(script_cdata(inject_script(result)))
|
25
|
+
File.open(filename, "w:UTF-8") { |f| f.write(result) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/word_convert.rb
CHANGED
@@ -32,10 +32,11 @@ module IsoDoc
|
|
32
32
|
|
33
33
|
def initialize(options)
|
34
34
|
@format = :doc
|
35
|
+
@suffix = "doc"
|
35
36
|
super
|
36
37
|
end
|
37
38
|
|
38
|
-
def convert(filename, file = nil, debug = false)
|
39
|
+
def convert(filename, file = nil, debug = false, output_filename = nil)
|
39
40
|
ret = super
|
40
41
|
FileUtils.rm_rf tmpimagedir
|
41
42
|
ret
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "./table.rb"
|
2
|
+
require_relative "./inline.rb"
|
2
3
|
|
3
4
|
module IsoDoc::WordFunction
|
4
5
|
module Body
|
@@ -69,28 +70,6 @@ module IsoDoc::WordFunction
|
|
69
70
|
node.xpath(ns("./note")).each { |n| parse(n, out) }
|
70
71
|
end
|
71
72
|
|
72
|
-
def section_break(body)
|
73
|
-
body.p do |p|
|
74
|
-
p.br **{ clear: "all", class: "section" }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def page_break(out)
|
79
|
-
out.p do |p|
|
80
|
-
p.br **{ clear: "all",
|
81
|
-
style: "mso-special-character:line-break;"\
|
82
|
-
"page-break-before:always" }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def pagebreak_parse(node, out)
|
87
|
-
return page_break(out) if node["orientation"].nil?
|
88
|
-
out.p do |p|
|
89
|
-
p.br **{clear: "all", class: "section",
|
90
|
-
orientation: node["orientation"] }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
73
|
WORD_DT_ATTRS = {class: @note ? "Note" : nil, align: "left",
|
95
74
|
style: "margin-left:0pt;text-align:left;"}.freeze
|
96
75
|
|
@@ -174,10 +153,10 @@ module IsoDoc::WordFunction
|
|
174
153
|
end
|
175
154
|
|
176
155
|
def termnote_parse(node, out)
|
177
|
-
out.div **
|
156
|
+
out.div **note_attrs(node) do |div|
|
178
157
|
first = node.first_element_child
|
179
158
|
div.p **{ class: "Note" } do |p|
|
180
|
-
anchor =
|
159
|
+
anchor = @xrefs.get[node['id']]
|
181
160
|
p << "#{anchor&.dig(:label) || '???'}: "
|
182
161
|
para_then_remainder(first, node, p, div)
|
183
162
|
end
|
@@ -185,41 +164,23 @@ module IsoDoc::WordFunction
|
|
185
164
|
end
|
186
165
|
|
187
166
|
def para_attrs(node)
|
188
|
-
attrs = { class: para_class(node), id: node["id"] }
|
167
|
+
attrs = { class: para_class(node), id: node["id"], style: "" }
|
189
168
|
unless node["align"].nil?
|
190
169
|
attrs[:align] = node["align"] unless node["align"] == "justify"
|
191
|
-
attrs[:style]
|
170
|
+
attrs[:style] += "text-align:#{node['align']};"
|
192
171
|
end
|
172
|
+
attrs[:style] += "#{keep_style(node)}"
|
173
|
+
attrs[:style] = nil if attrs[:style].empty?
|
193
174
|
attrs
|
194
175
|
end
|
195
176
|
|
196
|
-
def imgsrc(uri)
|
197
|
-
return uri unless %r{^data:image/}.match uri
|
198
|
-
save_dataimage(uri)
|
199
|
-
end
|
200
|
-
|
201
|
-
def image_parse(node, out, caption)
|
202
|
-
attrs = { src: imgsrc(node["src"]),
|
203
|
-
height: node["height"],
|
204
|
-
alt: node["alt"],
|
205
|
-
title: node["title"],
|
206
|
-
width: node["width"] }
|
207
|
-
out.img **attr_code(attrs)
|
208
|
-
image_title_parse(out, caption)
|
209
|
-
end
|
210
|
-
|
211
|
-
def xref_parse(node, out)
|
212
|
-
target = /#/.match(node["target"]) ? node["target"].sub(/#/, ".doc#") :
|
213
|
-
"##{node["target"]}"
|
214
|
-
out.a(**{ "href": target }) { |l| l << get_linkend(node) }
|
215
|
-
end
|
216
|
-
|
217
177
|
def example_table_attr(node)
|
218
178
|
super.merge({
|
219
179
|
style: "mso-table-lspace:15.0cm;margin-left:423.0pt;"\
|
220
180
|
"mso-table-rspace:15.0cm;margin-right:423.0pt;"\
|
221
181
|
"mso-table-anchor-horizontal:column;"\
|
222
|
-
"mso-table-overlap:never;border-collapse:collapse;"
|
182
|
+
"mso-table-overlap:never;border-collapse:collapse;"\
|
183
|
+
"#{keep_style(node)}"
|
223
184
|
})
|
224
185
|
end
|
225
186
|
|
@@ -240,5 +201,10 @@ module IsoDoc::WordFunction
|
|
240
201
|
node.children.each { |n| parse(n, li) }
|
241
202
|
end
|
242
203
|
end
|
204
|
+
|
205
|
+
def suffix_url(url)
|
206
|
+
return url if %r{^http[s]?://}.match(url)
|
207
|
+
url.sub(/#{File.extname(url)}$/, ".doc")
|
208
|
+
end
|
243
209
|
end
|
244
210
|
end
|