isodoc 2.10.1 → 2.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6867b3f44bce43fcfbd4c65115b8b71b6eb38cb7b1e39c20215addc7af8ad086
4
- data.tar.gz: f335e4aecc20758c7c9810083d7da486ec73e0db4c377b9528841b46166085de
3
+ metadata.gz: d57eb699105f5f1b40c5b31cf51259a1bd60b458ac2b6ab0326beaa915c63750
4
+ data.tar.gz: 99b2d95988e2f1bb989f0779a60298c57fe08e69127bc07f063bd813403e5858
5
5
  SHA512:
6
- metadata.gz: 0bda93db557ef73dc1c5999bbd88d9ba06ac9977f48b93f4adca7aaac7e762d5b4fed0d62d8934151ce3ecf1becea0060d3fab65c92e2150a8a00a0c49895ee6
7
- data.tar.gz: 1b0d780a2e450e8a22e8f6d4dcbcaa991e73bdcf1343ca3675c2e81b5f52688be7882f58762c18820fd2e99c4c37ea6043af8efc7f454ec44b553e00c3d356e3
6
+ metadata.gz: 5657c1f981918049eab6e6cd2d17d9d929309714025936dc27256f4ce0ec6b04b3c60a8bbd8839daec8eb322515425349cba06972ef888706ed44ea886cd8527
7
+ data.tar.gz: 1129bf0dbb9d6e31ef5a8fc50d2dd1f63aa70658c4ffdc60329c6e60fd6da3ffb7127fb32c99609ddd68da4b703f8712f0487820362081d1752d2ac983f5b079
@@ -1,3 +1,4 @@
1
+ @charset "UTF-8";
1
2
  html, body, div, span, applet, object, iframe,
2
3
  h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3
4
  a, abbr, acronym, address, big, cite, code,
@@ -169,6 +170,58 @@ table.rouge-line-table pre {
169
170
  overflow-x: visible;
170
171
  font-size: 100%; }
171
172
 
173
+ /* header § links */
174
+ a.header {
175
+ color: inherit;
176
+ text-decoration: none; }
177
+
178
+ a.header:hover {
179
+ color: #a53221 !important;
180
+ background: inherit;
181
+ box-shadow: none; }
182
+
183
+ a.header:visited {
184
+ color: inherit;
185
+ text-decoration: none; }
186
+
187
+ a.anchor {
188
+ position: absolute;
189
+ z-index: 1001;
190
+ width: 1.5ex;
191
+ margin-left: -1.5ex;
192
+ display: block;
193
+ text-decoration: none !important;
194
+ visibility: hidden;
195
+ text-align: center;
196
+ font-weight: 400; }
197
+
198
+ a.anchor::before {
199
+ content: "\00A7";
200
+ font-size: .85em;
201
+ display: block;
202
+ padding-top: .1em; }
203
+
204
+ a.anchor:hover {
205
+ color: #a53221;
206
+ background: inherit;
207
+ box-shadow: none; }
208
+
209
+ h1 > a.anchor:hover,
210
+ h2 > a.anchor:hover,
211
+ h3 > a.anchor:hover,
212
+ h4 > a.anchor:hover,
213
+ h5 > a.anchor:hover,
214
+ h6 > a.anchor:hover,
215
+ .inline-header > a.anchor:hover,
216
+ h1:hover > a.anchor,
217
+ h2:hover > a.anchor,
218
+ h3:hover > a.anchor,
219
+ h4:hover > a.anchor,
220
+ h5:hover > a.anchor,
221
+ h6:hover > a.anchor,
222
+ .inline-header:hover > a.anchor {
223
+ visibility: visible; }
224
+
172
225
  #standard-band {
173
226
  background-color: #0AC442; }
174
227
 
@@ -1,3 +1,4 @@
1
+ @charset "UTF-8";
1
2
  html, body, div, span, applet, object, iframe,
2
3
  h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3
4
  a, abbr, acronym, address, big, cite, code,
@@ -168,3 +169,55 @@ table.rouge-line-table pre {
168
169
  padding: 0;
169
170
  overflow-x: visible;
170
171
  font-size: 100%; }
172
+
173
+ /* header § links */
174
+ a.header {
175
+ color: inherit;
176
+ text-decoration: none; }
177
+
178
+ a.header:hover {
179
+ color: #a53221 !important;
180
+ background: inherit;
181
+ box-shadow: none; }
182
+
183
+ a.header:visited {
184
+ color: inherit;
185
+ text-decoration: none; }
186
+
187
+ a.anchor {
188
+ position: absolute;
189
+ z-index: 1001;
190
+ width: 1.5ex;
191
+ margin-left: -1.5ex;
192
+ display: block;
193
+ text-decoration: none !important;
194
+ visibility: hidden;
195
+ text-align: center;
196
+ font-weight: 400; }
197
+
198
+ a.anchor::before {
199
+ content: "\00A7";
200
+ font-size: .85em;
201
+ display: block;
202
+ padding-top: .1em; }
203
+
204
+ a.anchor:hover {
205
+ color: #a53221;
206
+ background: inherit;
207
+ box-shadow: none; }
208
+
209
+ h1 > a.anchor:hover,
210
+ h2 > a.anchor:hover,
211
+ h3 > a.anchor:hover,
212
+ h4 > a.anchor:hover,
213
+ h5 > a.anchor:hover,
214
+ h6 > a.anchor:hover,
215
+ .inline-header > a.anchor:hover,
216
+ h1:hover > a.anchor,
217
+ h2:hover > a.anchor,
218
+ h3:hover > a.anchor,
219
+ h4:hover > a.anchor,
220
+ h5:hover > a.anchor,
221
+ h6:hover > a.anchor,
222
+ .inline-header:hover > a.anchor {
223
+ visibility: visible; }
@@ -199,3 +199,27 @@ table.rouge-line-table pre {
199
199
  overflow-x: visible;
200
200
  font-size: 100%;
201
201
  }
202
+
203
+ /* header § links */
204
+ a.header{color:inherit;text-decoration:none;}
205
+ a.header:hover{color:#a53221 !important;background:inherit;box-shadow:none;}
206
+ a.header:visited{color:inherit;text-decoration:none;}
207
+ a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
208
+ a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
209
+ a.anchor:hover{color:#a53221;background:inherit;box-shadow:none;}
210
+ h1>a.anchor:hover,
211
+ h2>a.anchor:hover,
212
+ h3>a.anchor:hover,
213
+ h4>a.anchor:hover,
214
+ h5>a.anchor:hover,
215
+ h6>a.anchor:hover,
216
+ .inline-header>a.anchor:hover,
217
+ h1:hover>a.anchor,
218
+ h2:hover>a.anchor,
219
+ h3:hover>a.anchor,
220
+ h4:hover>a.anchor,
221
+ h5:hover>a.anchor,
222
+ h6:hover>a.anchor,
223
+ .inline-header:hover>a.anchor{
224
+ visibility:visible;
225
+ }
@@ -157,13 +157,14 @@ module IsoDoc
157
157
  tfoot.xpath(".//td").last
158
158
  end
159
159
 
160
+ TABLENOTE_CSS = "div[@class = 'Note' or @class = 'BlockSource' " \
161
+ "or @class = 'TableFootnote' or @class = 'figdl']".freeze
162
+
160
163
  def table_note_cleanup(docxml)
161
- docxml.xpath("//table[dl or div[@class = 'Note' or @class = 'BlockSource' " \
162
- "or @class = 'TableFootnote']]").each do |t|
164
+ docxml.xpath("//table[dl or #{TABLENOTE_CSS}]").each do |t|
163
165
  tfoot = table_get_or_make_tfoot(t)
164
166
  insert_here = new_fullcolspan_row(t, tfoot)
165
- t.xpath("dl | div[@class = 'Note' or @class = 'BlockSource' or " \
166
- "@class = 'TableFootnote']")
167
+ t.xpath("dl | p[@class = 'ListTitle'] | #{TABLENOTE_CSS}")
167
168
  .each do |d|
168
169
  d.parent = insert_here
169
170
  end
@@ -13,9 +13,11 @@ module IsoDoc
13
13
  end
14
14
 
15
15
  def ul_parse(node, out)
16
- list_title_parse(node, out)
17
- out.ul **attr_code(ul_attrs(node)) do |ul|
18
- node.children.each { |n| n.name == "name" or parse(n, ul) }
16
+ out.div **attr_code(class: "ul_wrap") do |div|
17
+ list_title_parse(node, div)
18
+ div.ul **attr_code(ul_attrs(node)) do |ul|
19
+ node.children.each { |n| n.name == "name" or parse(n, ul) }
20
+ end
19
21
  end
20
22
  end
21
23
 
@@ -52,9 +54,11 @@ module IsoDoc
52
54
  end
53
55
 
54
56
  def ol_parse(node, out)
55
- list_title_parse(node, out)
56
- out.ol **attr_code(ol_attrs(node)) do |ol|
57
- node.children.each { |n| n.name == "name" or parse(n, ol) }
57
+ out.div **attr_code(class: "ol_wrap") do |div|
58
+ list_title_parse(node, div)
59
+ div.ol **attr_code(ol_attrs(node)) do |ol|
60
+ node.children.each { |n| n.name == "name" or parse(n, ol) }
61
+ end
58
62
  end
59
63
  end
60
64
 
@@ -90,13 +94,15 @@ module IsoDoc
90
94
  end
91
95
 
92
96
  def dl_parse(node, out)
93
- list_title_parse(node, out)
94
- out.dl **dl_attrs(node) do |v|
95
- node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
96
- dl_parse1(v, dt, dd)
97
+ out.div **attr_code(class: "figdl") do |div|
98
+ list_title_parse(node, div)
99
+ div.dl **dl_attrs(node) do |v|
100
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
101
+ dl_parse1(v, dt, dd)
102
+ end
97
103
  end
104
+ dl_parse_notes(node, div)
98
105
  end
99
- dl_parse_notes(node, out)
100
106
  end
101
107
 
102
108
  def dl_parse_notes(node, out)
@@ -10,7 +10,7 @@ module IsoDoc
10
10
  end
11
11
 
12
12
  def inline_header_title(out, node, title)
13
- out.span class: "zzMoveToFollowing" do |s|
13
+ out.span class: "zzMoveToFollowing inline-header" 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)
@@ -26,9 +26,26 @@ module IsoDoc
26
26
 
27
27
  def html_cleanup(html)
28
28
  html = term_header(html_footnote_filter(html_preface(htmlstyle(html))))
29
- html = footnote_format(footnote_backlinks(html_toc(html)))
29
+ html = footnote_format(footnote_backlinks(html))
30
30
  html = mathml(html_list_clean(remove_placeholder_paras(html)))
31
- sourcecode_cleanup(html)
31
+ html_toc(heading_anchors(sourcecode_cleanup(html)))
32
+ end
33
+
34
+ def heading_anchors(html)
35
+ html.xpath("//h1 | //h2 | //h3 | //h4 | //h5 | //h6 | //h7 | //h8 "\
36
+ "//span[@class = 'inline-header']").each do |h|
37
+ h.at("./ancestor::div[@id='toc']") and next
38
+ div = h.xpath("./ancestor::div[@id]")
39
+ div.empty? and next
40
+ heading_anchor(h, div[-1]["id"])
41
+ end
42
+ html
43
+ end
44
+
45
+ def heading_anchor(hdr, id)
46
+ hdr.children = <<~HTML.strip
47
+ <a class='anchor' href='##{id}'/><a class='header' href='##{id}'>#{hdr.children.to_xml}</a>
48
+ HTML
32
49
  end
33
50
 
34
51
  def sourcecode_cleanup(html)
@@ -52,7 +69,7 @@ module IsoDoc
52
69
 
53
70
  def html_list_clean(html)
54
71
  html.xpath("//ol/div | //ul/div").each do |div|
55
- li = div&.xpath("./preceding-sibling::li")&.last ||
72
+ li = div.xpath("./preceding-sibling::li")&.last ||
56
73
  div.at("./following-sibling::li")
57
74
  div.parent = li
58
75
  end
@@ -92,7 +109,6 @@ module IsoDoc
92
109
  type = img["mimetype"]&.sub(%r{^[^/*]+/}, "")
93
110
  matched = /\.(?<suffix>[^. \r\n\t]+)$/.match img["src"]
94
111
  type and !type.empty? and return type
95
-
96
112
  !matched.nil? and matched[:suffix] and return matched[:suffix]
97
113
  "png"
98
114
  end
@@ -111,6 +127,9 @@ module IsoDoc
111
127
  %w(h1 h2 h3 h4 h5 h6 h7 h8).each do |h|
112
128
  docxml.xpath("//p[@class = 'TermNum'][../#{h}]").each do |p|
113
129
  p.name = "h#{h[1].to_i + 1}"
130
+ id = p["id"]
131
+ p["id"] = "_#{UUIDTools::UUID.random_create}"
132
+ p.wrap("<div id='#{id}'></div>")
114
133
  end
115
134
  end
116
135
  docxml
@@ -98,7 +98,9 @@ module IsoDoc
98
98
  def html_toc_entry(level, header)
99
99
  content = header.at("./following-sibling::p" \
100
100
  "[@class = 'variant-title-toc']") || header
101
- %(<li class="#{level}"><a href="##{header['id']}">\
101
+ id = header.at(".//a[@class = 'anchor']/@href")&.text&.sub(/^#/, "") ||
102
+ header["id"]
103
+ %(<li class="#{level}"><a href="##{id}">\
102
104
  #{header_strip(content)}</a></li>)
103
105
  end
104
106
 
@@ -48,6 +48,8 @@ module IsoDoc
48
48
  set(:doctype, status_print(b))
49
49
  b1 = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}"))&.text || b
50
50
  set(:doctype_display, status_print(b1))
51
+ b = isoxml&.at(ns("//bibdata/ext/subdoctype#{NOLANG}"))&.text || return
52
+ set(:subdoctype, status_print(b))
51
53
  end
52
54
 
53
55
  def docstatus(xml, _out)
@@ -79,12 +79,12 @@ module IsoDoc
79
79
 
80
80
  def parse_localize_number
81
81
  @localizenumber or return {}
82
- m = %r{(?<group>[^#])?(?<groupdigits>#+0)(?<decimal>.)(?<fractdigits>#+)(?<fractgroup>[^#])?}
82
+ m = %r{(?<grp>[^#])?(?<grpdig>#+0)(?<decpt>.)(?<frdig>#+)(?<frgrp>[^#])?}
83
83
  .match(@localizenumber) or return {}
84
- ret = { decimal: m[:decimal], group_digits: m[:groupdigits].size,
85
- fraction_group_digits: m[:fractdigits].size,
86
- group: m[:group] || "",
87
- fraction_group: m[:fractgroup] || "" }.compact
84
+ ret = { decimal: m[:decpt], group_digits: m[:grpdig].size,
85
+ fraction_group_digits: m[:frdig].size,
86
+ group: m[:grp] || "",
87
+ fraction_group: m[:frgrp] || "" }.compact
88
88
  %i(group fraction_group).each { |x| ret[x] == " " and ret[x] = "\u00A0" }
89
89
  ret
90
90
  end
@@ -3,6 +3,7 @@ module IsoDoc
3
3
  def metadata(docxml)
4
4
  toc_metadata(docxml)
5
5
  fonts_metadata(docxml)
6
+ attachments_extract(docxml)
6
7
  preprocess_xslt_insert(docxml)
7
8
  a = docxml.at(ns("//bibdata")) or return
8
9
  a.next =
@@ -10,6 +11,22 @@ module IsoDoc
10
11
  "</localized-strings>"
11
12
  end
12
13
 
14
+ def attachments_extract(docxml)
15
+ docxml.at(ns("//metanorma-extension/attachment")) or return
16
+ dir = File.join(@localdir, "_#{@outputfile}_attachments")
17
+ FileUtils.rm_rf(dir)
18
+ FileUtils.mkdir_p(dir)
19
+ docxml.xpath(ns("//metanorma-extension/attachment")).each do |a|
20
+ save_attachment(a, dir)
21
+ end
22
+ end
23
+
24
+ def save_attachment(attachment, dir)
25
+ n = File.join(dir, attachment["name"])
26
+ c = attachment.text.sub(%r{^data:[^;]+;(?:charset=[^;]+;)?base64,}, "")
27
+ File.open(n, "wb") { |f| f.write(Base64.strict_decode64(c)) }
28
+ end
29
+
13
30
  def extension_insert(xml, path = [])
14
31
  ins = extension_insert_pt(xml)
15
32
  path.each do |n|
@@ -25,7 +25,9 @@ module IsoDoc
25
25
  def hidden_items(docxml)
26
26
  docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x|
27
27
  x.at(ns("./bibitem[not(@hidden = 'true')]")) and next
28
- x.elements.map(&:name).any? { |n| n != "bibitem" } and next
28
+ x.elements.map(&:name).any? do |n|
29
+ !%w(title bibitem).include?(n)
30
+ end and next
29
31
  x["hidden"] = "true"
30
32
  end
31
33
  end
@@ -141,8 +141,8 @@ module IsoDoc
141
141
  end
142
142
 
143
143
  def source_lex(elem)
144
- lexer = (Rouge::Lexer.find(elem["lang"] || "plaintext") ||
145
- Rouge::Lexer.find("plaintext"))
144
+ lexer = Rouge::Lexer.find(elem["lang"] || "plaintext") ||
145
+ Rouge::Lexer.find("plaintext")
146
146
  l = Rouge::Lexers::Escape.new(start: "{^^{", end: "}^^}", lang: lexer)
147
147
  source = to_xml(elem.children).gsub(/</, "{^^{<").gsub(/>/, ">}^^}")
148
148
  l.lang.reset!
@@ -18,10 +18,13 @@ module IsoDoc
18
18
  super
19
19
  end
20
20
 
21
- def convert1(docxml, _filename, _dir)
21
+ def convert1(docxml, filename, dir)
22
+ @outputdir = dir
23
+ @outputfile = filename
22
24
  docid_prefixes(docxml) # feeds @xrefs.parse citation processing
23
25
  @xrefs.parse docxml
24
- info docxml, nil
26
+ @xrefs.klass.meta = @meta
27
+ @xrefs.klass.info docxml, nil
25
28
  conversions(docxml)
26
29
  docxml.root["type"] = "presentation"
27
30
  docxml.to_xml.gsub("&lt;", "&#x3c;").gsub("&gt;", "&#x3e;")
@@ -120,7 +123,7 @@ module IsoDoc
120
123
  def metanorma_extension_insert_pt(xml)
121
124
  xml.at(ns("//metanorma-extension")) ||
122
125
  xml.at(ns("//bibdata"))&.after("<metanorma-extension/>")
123
- &.next_element ||
126
+ &.next_element ||
124
127
  xml.root.elements.first.before("<metanorma-extension/>")
125
128
  .previous_element
126
129
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.1".freeze
2
+ VERSION = "2.10.3".freeze
3
3
  end
@@ -24,13 +24,15 @@ module IsoDoc
24
24
  end
25
25
 
26
26
  def dl_parse_nontable(node, out)
27
- node["id"] and bookmark_parse(node, out)
28
- list_title_parse(node, out)
27
+ out.div **attr_code(class: "figdl") do |div|
28
+ node["id"] and bookmark_parse(node, div)
29
+ list_title_parse(node, div)
29
30
  node.elements.select { |n| dt_dd?(n) }
30
31
  .each_slice(2) do |dt, dd|
31
- dl_parse_nontable1(out, dt, dd)
32
+ dl_parse_nontable1(div, dt, dd)
33
+ end
34
+ dl_parse_notes(node, div)
32
35
  end
33
- dl_parse_notes(node, out)
34
36
  end
35
37
 
36
38
  WORD_EMBED_DL_ATTRS =
@@ -27,7 +27,7 @@ module IsoDoc
27
27
  def sequential_figure_names(clause, container: false)
28
28
  c = Counter.new
29
29
  j = 0
30
- clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
30
+ clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
31
31
  j = subfigure_increment(j, c, t)
32
32
  sequential_figure_body(j, c, t, "figure", container: container)
33
33
  end
@@ -155,7 +155,7 @@ module IsoDoc
155
155
  def hierarchical_figure_names(clause, num)
156
156
  c = Counter.new
157
157
  j = 0
158
- clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
158
+ clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
159
159
  # next if labelled_ancestor(t) && t.ancestors("figure").empty?
160
160
  j = subfigure_increment(j, c, t)
161
161
  hierarchical_figure_body(num, j, c, t, "figure")
@@ -89,7 +89,7 @@ deprecated: 推奨しない用語
89
89
  source: 出典
90
90
  and: and
91
91
  all_parts: 規格群
92
- edition_ordinal: "第3版{{ var1 }}版"
92
+ edition_ordinal: "第{{ var1 }}版"
93
93
  edition: 版
94
94
  version: version
95
95
  toc_figures: List of figures
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.10.1
4
+ version: 2.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc
@@ -425,7 +425,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
425
425
  - !ruby/object:Gem::Version
426
426
  version: '0'
427
427
  requirements: []
428
- rubygems_version: 3.3.26
428
+ rubygems_version: 3.3.27
429
429
  signing_key:
430
430
  specification_version: 4
431
431
  summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.