isodoc 2.3.6 → 2.4.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/isodoc.gemspec +2 -1
- data/lib/isodoc/base_style/typography.scss +5 -2
- data/lib/isodoc/class_utils.rb +6 -1
- data/lib/isodoc/convert.rb +7 -4
- data/lib/isodoc/function/blocks.rb +1 -1
- data/lib/isodoc/function/inline.rb +4 -4
- data/lib/isodoc/function/inline_simple.rb +2 -1
- data/lib/isodoc/function/references.rb +38 -52
- data/lib/isodoc/function/table.rb +21 -12
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/function/utils.rb +4 -0
- data/lib/isodoc/html_function/html.rb +6 -25
- data/lib/isodoc/html_function/postprocess_cover.rb +6 -9
- data/lib/isodoc/metadata.rb +5 -0
- data/lib/isodoc/presentation_function/bibdata.rb +9 -9
- data/lib/isodoc/presentation_function/block.rb +99 -33
- data/lib/isodoc/presentation_function/erefs.rb +49 -35
- data/lib/isodoc/presentation_function/refs.rb +76 -4
- data/lib/isodoc/presentation_function/section.rb +1 -1
- data/lib/isodoc/presentation_function/terms.rb +28 -23
- data/lib/isodoc/presentation_function/xrefs.rb +16 -7
- data/lib/isodoc/presentation_xml_convert.rb +2 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +32 -3
- data/lib/isodoc/word_function/table.rb +24 -13
- data/lib/isodoc/xref/xref_gen.rb +11 -11
- metadata +19 -5
@@ -52,11 +52,17 @@ module IsoDoc
|
|
52
52
|
@wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
|
53
53
|
end
|
54
54
|
|
55
|
+
def sourcecode_style
|
56
|
+
"Sourcecode"
|
57
|
+
end
|
58
|
+
|
55
59
|
def wordstylesheet_update
|
56
60
|
return if @wordstylesheet.nil?
|
57
61
|
|
58
62
|
f = File.open(@wordstylesheet.path, "a")
|
59
63
|
@landscapestyle.empty? or f.write(@landscapestyle)
|
64
|
+
s = @meta.get[:code_css] and
|
65
|
+
f.write(s.gsub(/sourcecode/, "p.#{sourcecode_style}"))
|
60
66
|
if @wordstylesheet_override && @wordstylesheet
|
61
67
|
f.write(@wordstylesheet_override.read)
|
62
68
|
@wordstylesheet_override.close
|
@@ -70,13 +76,15 @@ module IsoDoc
|
|
70
76
|
def word_admonition_images(docxml)
|
71
77
|
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
72
78
|
i["width"], i["height"] =
|
73
|
-
Html2Doc.new({}).image_resize(i, image_localfile(i), @maxheight,
|
79
|
+
Html2Doc.new({}).image_resize(i, image_localfile(i), @maxheight,
|
80
|
+
300)
|
74
81
|
end
|
75
82
|
end
|
76
83
|
|
77
84
|
def word_cleanup(docxml)
|
78
85
|
word_annex_cleanup(docxml)
|
79
86
|
word_preface(docxml)
|
87
|
+
word_sourcecode_table(docxml)
|
80
88
|
word_nested_tables(docxml)
|
81
89
|
word_colgroup(docxml)
|
82
90
|
word_table_align(docxml)
|
@@ -93,6 +101,27 @@ module IsoDoc
|
|
93
101
|
docxml
|
94
102
|
end
|
95
103
|
|
104
|
+
def word_sourcecode_table(docxml)
|
105
|
+
docxml.xpath("//p[@class='Sourcecode']/div[@class='table_container']")
|
106
|
+
.each do |d|
|
107
|
+
pre = d.at(".//p[@class='Sourcecode']")
|
108
|
+
to_sourcecode_para(pre)
|
109
|
+
d["id"] = d.parent["id"]
|
110
|
+
d.parent.replace(d)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def to_sourcecode_para(pre)
|
115
|
+
@sourcecode = true
|
116
|
+
pre.traverse do |x|
|
117
|
+
x.text? or next
|
118
|
+
ret = []
|
119
|
+
text_parse(x, ret)
|
120
|
+
x.replace(ret.join)
|
121
|
+
end
|
122
|
+
@sourcecode = false
|
123
|
+
end
|
124
|
+
|
96
125
|
def word_tab_clean(docxml)
|
97
126
|
docxml.xpath("//p[@class='Biblio']//span[@style='mso-tab-count:1']")
|
98
127
|
.each do |s|
|
@@ -155,7 +184,7 @@ module IsoDoc
|
|
155
184
|
.each do |t|
|
156
185
|
if t&.previous_element&.name == "img"
|
157
186
|
img = t.previous_element
|
158
|
-
t.previous_element.swap("<p class
|
187
|
+
t.previous_element.swap("<p class='figure'>#{img.to_xml}</p>")
|
159
188
|
end
|
160
189
|
style_update(t&.previous_element, "page-break-after:avoid;")
|
161
190
|
end
|
@@ -231,7 +260,7 @@ module IsoDoc
|
|
231
260
|
docxml.xpath("//a[@epub:type = 'footnote']").each do |x|
|
232
261
|
footnote_reference_format(x)
|
233
262
|
end
|
234
|
-
docxml.xpath("//a[@class = 'TableFootnoteRef'] | "\
|
263
|
+
docxml.xpath("//a[@class = 'TableFootnoteRef'] | " \
|
235
264
|
"//span[@class = 'TableFootnoteRef']").each do |x|
|
236
265
|
table_footnote_reference_format(x)
|
237
266
|
end
|
@@ -15,39 +15,50 @@ module IsoDoc
|
|
15
15
|
table.at(".//tr").xpath("./td | ./th").each do |td|
|
16
16
|
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
17
17
|
end
|
18
|
-
style = "border-top:0pt;mso-border-top-alt:0pt;"\
|
18
|
+
style = "border-top:0pt;mso-border-top-alt:0pt;" \
|
19
19
|
"border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;"
|
20
20
|
tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
|
21
21
|
tfoot.xpath(".//td").last
|
22
22
|
end
|
23
23
|
|
24
|
-
def make_tr_attr(
|
25
|
-
style =
|
26
|
-
rowmax =
|
27
|
-
style +=
|
24
|
+
def make_tr_attr(cell, row, totalrows, header, bordered)
|
25
|
+
style = cell.name == "th" ? "font-weight:bold;" : ""
|
26
|
+
rowmax = cell["rowspan"] ? row + cell["rowspan"].to_i - 1 : row
|
27
|
+
style += make_tr_attr_style(row, rowmax, totalrows, header, bordered)
|
28
|
+
{ rowspan: cell["rowspan"], colspan: cell["colspan"],
|
29
|
+
valign: cell["valign"], align: cell["align"], style: style }
|
30
|
+
end
|
31
|
+
|
32
|
+
def make_tr_attr_style(row, rowmax, totalrows, header, bordered)
|
33
|
+
ret = <<~STYLE.gsub(/\n/, "")
|
28
34
|
border-top:#{row.zero? ? "#{SW1} 1.5pt;" : 'none;'}
|
29
35
|
mso-border-top-alt:#{row.zero? ? "#{SW1} 1.5pt;" : 'none;'}
|
30
|
-
border-bottom:#{SW1} #{rowmax
|
31
|
-
mso-border-bottom-alt:#{SW1} #{rowmax
|
36
|
+
border-bottom:#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;
|
37
|
+
mso-border-bottom-alt:#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;
|
32
38
|
STYLE
|
33
|
-
|
34
|
-
|
39
|
+
bordered or ret = ""
|
40
|
+
pb = header || (totalrows <= 10 && rowmax < totalrows) ? "avoid" : "auto"
|
41
|
+
"#{ret}page-break-after:#{pb};"
|
35
42
|
end
|
36
43
|
|
37
44
|
def table_attrs(node)
|
45
|
+
c = node["class"]
|
46
|
+
bordered = "border-spacing:0;border-width:1px;"
|
47
|
+
(%w(modspec).include?(c) || !c) or bordered = nil
|
38
48
|
ret = {
|
39
49
|
summary: node["summary"],
|
40
50
|
width: node["width"],
|
41
|
-
style: "mso-table-anchor-horizontal:column;mso-table-overlap:never;"\
|
42
|
-
"
|
51
|
+
style: "mso-table-anchor-horizontal:column;mso-table-overlap:never;" \
|
52
|
+
"#{bordered}#{keep_style(node)}",
|
43
53
|
class: (node.text.length > 4000 ? "MsoISOTableBig" : "MsoISOTable"),
|
44
54
|
}
|
55
|
+
bordered or ret.delete(:class)
|
45
56
|
super.merge(attr_code(ret))
|
46
57
|
end
|
47
58
|
|
48
|
-
def colgroup(node,
|
59
|
+
def colgroup(node, table)
|
49
60
|
colgroup = node.at(ns("./colgroup")) or return
|
50
|
-
|
61
|
+
table.colgroup do |cg|
|
51
62
|
colgroup.xpath(ns("./col")).each do |c|
|
52
63
|
cg.col **{ width: c["width"] }
|
53
64
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -62,7 +62,7 @@ module IsoDoc
|
|
62
62
|
@anchors[n["id"]] =
|
63
63
|
{ label: termnote_label(c.print), type: "termnote",
|
64
64
|
value: c.print, elem: @labels["termnote"],
|
65
|
-
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
65
|
+
xref: l10n("#{anchor(t['id'], :xref)}, " \
|
66
66
|
"#{@labels['note_xref']} #{c.print}") }
|
67
67
|
end
|
68
68
|
end
|
@@ -82,10 +82,10 @@ module IsoDoc
|
|
82
82
|
end
|
83
83
|
|
84
84
|
SECTIONS_XPATH =
|
85
|
-
"//foreword | //introduction | //acknowledgements | "\
|
86
|
-
"//preface/terms | preface/definitions | preface/references | "\
|
87
|
-
"//preface/clause | //sections/terms | //annex | "\
|
88
|
-
"//sections/clause | //sections/definitions | "\
|
85
|
+
"//foreword | //introduction | //acknowledgements | " \
|
86
|
+
"//preface/terms | preface/definitions | preface/references | " \
|
87
|
+
"//preface/clause | //sections/terms | //annex | " \
|
88
|
+
"//sections/clause | //sections/definitions | " \
|
89
89
|
"//bibliography/references | //bibliography/clause".freeze
|
90
90
|
|
91
91
|
def sections_xpath
|
@@ -93,8 +93,8 @@ module IsoDoc
|
|
93
93
|
end
|
94
94
|
|
95
95
|
CHILD_NOTES_XPATH =
|
96
|
-
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
|
97
|
-
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:note | "\
|
96
|
+
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and " \
|
97
|
+
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:note | " \
|
98
98
|
"./xmlns:note".freeze
|
99
99
|
|
100
100
|
def note_anchor_names(sections)
|
@@ -117,11 +117,11 @@ module IsoDoc
|
|
117
117
|
end
|
118
118
|
|
119
119
|
CHILD_EXAMPLES_XPATH =
|
120
|
-
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
|
121
|
-
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//"\
|
120
|
+
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and " \
|
121
|
+
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//" \
|
122
122
|
"xmlns:example | ./xmlns:example".freeze
|
123
123
|
|
124
|
-
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | "\
|
124
|
+
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | " \
|
125
125
|
"./references".freeze
|
126
126
|
|
127
127
|
def example_anchor_names(sections)
|
@@ -205,7 +205,7 @@ module IsoDoc
|
|
205
205
|
label = dterm.dup
|
206
206
|
label.xpath(ns(".//p")).each { |x| x.replace(x.children) }
|
207
207
|
label.xpath(ns(".//index")).each(&:remove)
|
208
|
-
label.children
|
208
|
+
Common::to_xml(label.children)
|
209
209
|
end
|
210
210
|
|
211
211
|
def bookmark_anchor_names(xml)
|
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.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
131
|
+
version: 0.3.1
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.3.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: relaton-cli
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rouge
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '4.0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '4.0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: thread_safe
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -497,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
497
511
|
- !ruby/object:Gem::Version
|
498
512
|
version: '0'
|
499
513
|
requirements: []
|
500
|
-
rubygems_version: 3.3.
|
514
|
+
rubygems_version: 3.3.26
|
501
515
|
signing_key:
|
502
516
|
specification_version: 4
|
503
517
|
summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.
|