isodoc 0.9.0 → 0.9.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/lib/isodoc/function/inline.rb +7 -4
- data/lib/isodoc/function/to_word_html.rb +6 -0
- data/lib/isodoc/function/xref_gen.rb +14 -12
- data/lib/isodoc/function/xref_sect_gen.rb +6 -6
- data/lib/isodoc/headlesshtml_convert.rb +1 -1
- data/lib/isodoc/html_function/html.rb +2 -2
- data/lib/isodoc/pdf_convert.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/spec/isodoc/inline_spec.rb +2 -2
- data/spec/isodoc/postproc_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14a2b122e4618bfd1d6ef74231405ad9b28d18bb7a8b812df2381c65f3443ca9
|
4
|
+
data.tar.gz: 47ee8c2b1bc90444256371e188ffec407ca79facafe199684ac8693c1254dd80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d74be6c585040de05deb7aeb5d92ec39651dc5a77f4f210479b77ef9cbb6fb82013ac87dfa77863853132b4026c3946039e79e51aad691243ca8fbfa86c5cf
|
7
|
+
data.tar.gz: '010093e4801400b6308c204cdd9745944def9a405b98934f57f16529e0cd1272cdcaf03ef85befe4acb91392d694161af5a38ea35d67dffeeda2ccede0ea1298'
|
@@ -22,16 +22,19 @@ module IsoDoc::Function
|
|
22
22
|
out << " <#{node.text}>"
|
23
23
|
end
|
24
24
|
|
25
|
+
def prefix_container(container, linkend, _target)
|
26
|
+
l10n(get_anchors[container][:xref] + ", " + linkend)
|
27
|
+
end
|
28
|
+
|
25
29
|
def anchor_linkend(node, linkend)
|
26
30
|
if node["citeas"].nil? && node["bibitemid"] &&
|
27
31
|
get_anchors.has_key?(node["bibitemid"])
|
28
|
-
#return get_anchors[node["bibitemid"]][:xref]
|
29
32
|
return get_anchors.dig(node["bibitemid"] ,:xref)
|
30
33
|
elsif node["target"] && get_anchors.has_key?(node["target"])
|
31
34
|
linkend = get_anchors[node["target"]][:xref]
|
32
35
|
container = get_anchors[node["target"]][:container]
|
33
36
|
(container && get_note_container_id(node) != container) &&
|
34
|
-
linkend =
|
37
|
+
linkend = prefix_container(container, linkend, node["target"])
|
35
38
|
end
|
36
39
|
linkend
|
37
40
|
end
|
@@ -76,10 +79,10 @@ module IsoDoc::Function
|
|
76
79
|
|
77
80
|
def stem_parse(node, out)
|
78
81
|
ooml = if node["type"] == "AsciiMath"
|
79
|
-
"#{@openmathdelim}#{node.text}#{@closemathdelim}"
|
82
|
+
"#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}#{@closemathdelim}"
|
80
83
|
elsif node["type"] == "MathML" then node.first_element_child.to_s
|
81
84
|
else
|
82
|
-
node.text
|
85
|
+
HTMLEntities.new.encode(node.text)
|
83
86
|
end
|
84
87
|
out.span **{ class: "stem" } do |span|
|
85
88
|
span.parent.add_child ooml
|
@@ -20,9 +20,15 @@ module IsoDoc::Function
|
|
20
20
|
Dir.mkdir(dir) unless File.exists?(dir)
|
21
21
|
system "rm -r #{dir}/*"
|
22
22
|
end
|
23
|
+
@filename = filename
|
23
24
|
[filename, dir]
|
24
25
|
end
|
25
26
|
|
27
|
+
def tmpimagedir
|
28
|
+
@filename + @tmpimagedir
|
29
|
+
end
|
30
|
+
|
31
|
+
|
26
32
|
# isodoc.css overrides any CSS injected by Html2Doc, which
|
27
33
|
# is inserted before this CSS.
|
28
34
|
def define_head(html, filename, _dir)
|
@@ -19,7 +19,7 @@ module IsoDoc::Function
|
|
19
19
|
return if n["id"].nil? || n["id"].empty?
|
20
20
|
@anchors[n["id"]] =
|
21
21
|
{ label: termnote_label(i + 1),
|
22
|
-
|
22
|
+
type: "termnote",
|
23
23
|
xref: l10n("#{@anchors.dig(t['id'], :xref)}, "\
|
24
24
|
"#{@note_xref_lbl} #{i + 1}") }
|
25
25
|
end
|
@@ -33,7 +33,7 @@ module IsoDoc::Function
|
|
33
33
|
return if n["id"].nil? || n["id"].empty?
|
34
34
|
idx = examples.size == 1 ? "" : (i + 1).to_s
|
35
35
|
@anchors[n["id"]] = {
|
36
|
-
|
36
|
+
type: "termexample",
|
37
37
|
label: idx, xref: l10n("#{@anchors.dig(t['id'], :xref)}, "\
|
38
38
|
"#{@note_xref_lbl} #{i + 1}") }
|
39
39
|
end
|
@@ -56,7 +56,7 @@ module IsoDoc::Function
|
|
56
56
|
next if @anchors[n["id"]]
|
57
57
|
next if n["id"].nil? || n["id"].empty?
|
58
58
|
idx = notes.size == 1 ? "" : " #{i + 1}"
|
59
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @note_xref_lbl)
|
59
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @note_xref_lbl, "note")
|
60
60
|
end
|
61
61
|
note_anchor_names(s.xpath(ns("./clause | ./appendix")))
|
62
62
|
end
|
@@ -73,7 +73,7 @@ module IsoDoc::Function
|
|
73
73
|
next if @anchors[n["id"]]
|
74
74
|
next if n["id"].nil? || n["id"].empty?
|
75
75
|
idx = notes.size == 1 ? "" : " #{i + 1}"
|
76
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @example_xref_lbl)
|
76
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @example_xref_lbl, "example")
|
77
77
|
end
|
78
78
|
example_anchor_names(s.xpath(ns("./clause | ./appendix")))
|
79
79
|
end
|
@@ -86,7 +86,7 @@ module IsoDoc::Function
|
|
86
86
|
notes.each_with_index do |n, i|
|
87
87
|
next if n["id"].nil? || n["id"].empty?
|
88
88
|
idx = notes.size == 1 ? "" : " #{i + 1}"
|
89
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @list_lbl)
|
89
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @list_lbl, "list")
|
90
90
|
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
91
91
|
end
|
92
92
|
list_anchor_names(s.xpath(ns("./clause | ./appendix")))
|
@@ -108,6 +108,7 @@ module IsoDoc::Function
|
|
108
108
|
label = "#{prev_label}.#{label}" unless prev_label.empty?
|
109
109
|
label = "#{list_anchor[:xref]} #{label}" if refer_list
|
110
110
|
li["id"] && @anchors[li["id"]] = { xref: "#{label})",
|
111
|
+
type: "listitem",
|
111
112
|
container: list_anchor[:container] }
|
112
113
|
li.xpath(ns("./ol")).each do |ol|
|
113
114
|
list_item_anchor_names(ol, list_anchor, depth + 1, label, false)
|
@@ -137,7 +138,7 @@ module IsoDoc::Function
|
|
137
138
|
end
|
138
139
|
label = i.to_s + (j.zero? ? "" : "-#{j}")
|
139
140
|
next if t["id"].nil? || t["id"].empty?
|
140
|
-
@anchors[t["id"]] = anchor_struct(label, nil, @figure_lbl)
|
141
|
+
@anchors[t["id"]] = anchor_struct(label, nil, @figure_lbl, "figure")
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
@@ -157,24 +158,25 @@ module IsoDoc::Function
|
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
160
|
-
def anchor_struct(lbl, container, elem)
|
161
|
+
def anchor_struct(lbl, container, elem, type)
|
161
162
|
ret = {}
|
162
163
|
ret[:label] = anchor_struct_label(lbl, elem)
|
163
164
|
ret[:xref] = anchor_struct_xref(lbl, elem)
|
164
165
|
ret[:xref].gsub!(/ $/, "")
|
165
166
|
ret[:container] = get_clause_id(container) unless container.nil?
|
167
|
+
ret[:type] = type
|
166
168
|
ret
|
167
169
|
end
|
168
170
|
|
169
171
|
def sequential_asset_names(clause)
|
170
172
|
clause.xpath(ns(".//table")).each_with_index do |t, i|
|
171
173
|
next if t["id"].nil? || t["id"].empty?
|
172
|
-
@anchors[t["id"]] = anchor_struct(i + 1, nil, @table_lbl)
|
174
|
+
@anchors[t["id"]] = anchor_struct(i + 1, nil, @table_lbl, "table")
|
173
175
|
end
|
174
176
|
sequential_figure_names(clause)
|
175
177
|
clause.xpath(ns(".//formula")).each_with_index do |t, i|
|
176
178
|
next if t["id"].nil? || t["id"].empty?
|
177
|
-
@anchors[t["id"]] = anchor_struct(i + 1, t, @formula_lbl)
|
179
|
+
@anchors[t["id"]] = anchor_struct(i + 1, t, @formula_lbl, "formula")
|
178
180
|
end
|
179
181
|
end
|
180
182
|
|
@@ -188,19 +190,19 @@ module IsoDoc::Function
|
|
188
190
|
end
|
189
191
|
label = "#{num}.#{i}" + (j.zero? ? "" : "-#{j}")
|
190
192
|
next if t["id"].nil? || t["id"].empty?
|
191
|
-
@anchors[t["id"]] = anchor_struct(label, nil, @figure_lbl)
|
193
|
+
@anchors[t["id"]] = anchor_struct(label, nil, @figure_lbl, "figure")
|
192
194
|
end
|
193
195
|
end
|
194
196
|
|
195
197
|
def hierarchical_asset_names(clause, num)
|
196
198
|
clause.xpath(ns(".//table")).each_with_index do |t, i|
|
197
199
|
next if t["id"].nil? || t["id"].empty?
|
198
|
-
@anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}", nil, @table_lbl)
|
200
|
+
@anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}", nil, @table_lbl, "table")
|
199
201
|
end
|
200
202
|
hierarchical_figure_names(clause, num)
|
201
203
|
clause.xpath(ns(".//formula")).each_with_index do |t, i|
|
202
204
|
next if t["id"].nil? || t["id"].empty?
|
203
|
-
@anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}", t, @formula_lbl)
|
205
|
+
@anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}", t, @formula_lbl, "formula")
|
204
206
|
end
|
205
207
|
end
|
206
208
|
end
|
@@ -34,7 +34,7 @@ module IsoDoc::Function
|
|
34
34
|
def preface_names(clause)
|
35
35
|
return if clause.nil?
|
36
36
|
@anchors[clause["id"]] =
|
37
|
-
{ label: nil, level: 1, xref: preface_clause_name(clause) }
|
37
|
+
{ label: nil, level: 1, xref: preface_clause_name(clause), type: "clause" }
|
38
38
|
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
39
39
|
preface_names1(c, c.at(ns("./title"))&.text, "#{preface_clause_name(clause)}, #{i+1}", 2)
|
40
40
|
end
|
@@ -43,7 +43,7 @@ module IsoDoc::Function
|
|
43
43
|
def preface_names1(clause, title, parent_title, level)
|
44
44
|
label = title || parent_title
|
45
45
|
@anchors[clause["id"]] =
|
46
|
-
{ label: nil, level: level, xref: label }
|
46
|
+
{ label: nil, level: level, xref: label, type: "clause" }
|
47
47
|
clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).
|
48
48
|
each_with_index do |c, i|
|
49
49
|
preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i+1}", level + 1)
|
@@ -71,7 +71,7 @@ module IsoDoc::Function
|
|
71
71
|
return num if clause.nil?
|
72
72
|
num = num + 1
|
73
73
|
@anchors[clause["id"]] =
|
74
|
-
{ label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
|
74
|
+
{ label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl, type: "clause" }
|
75
75
|
clause.xpath(ns("./clause | ./term | ./terms | ./definitions")).
|
76
76
|
each_with_index do |c, i|
|
77
77
|
section_names1(c, "#{num}.#{i + 1}", lvl + 1)
|
@@ -81,7 +81,7 @@ module IsoDoc::Function
|
|
81
81
|
|
82
82
|
def section_names1(clause, num, level)
|
83
83
|
@anchors[clause["id"]] =
|
84
|
-
{ label: num, level: level, xref: l10n("#{@clause_lbl} #{num}") }
|
84
|
+
{ label: num, level: level, xref: l10n("#{@clause_lbl} #{num}"), type: "clause" }
|
85
85
|
clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).
|
86
86
|
each_with_index do |c, i|
|
87
87
|
section_names1(c, "#{num}.#{i + 1}", level + 1)
|
@@ -95,7 +95,7 @@ module IsoDoc::Function
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def annex_names(clause, num)
|
98
|
-
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
|
98
|
+
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
|
99
99
|
xref: "#{@annex_lbl} #{num}", level: 1 }
|
100
100
|
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
101
101
|
annex_names1(c, "#{num}.#{i + 1}", 2)
|
@@ -106,7 +106,7 @@ module IsoDoc::Function
|
|
106
106
|
|
107
107
|
def annex_names1(clause, num, level)
|
108
108
|
@anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
|
109
|
-
level: level }
|
109
|
+
level: level, type: "clause" }
|
110
110
|
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
111
111
|
annex_names1(c, "#{num}.#{i + 1}", level + 1)
|
112
112
|
end
|
@@ -23,7 +23,7 @@ module IsoDoc
|
|
23
23
|
postprocess(result, filename + ".tmp", dir)
|
24
24
|
system "rm -fr #{dir}"
|
25
25
|
strip_head(filename + ".tmp.html", outname_html + ".headless.html")
|
26
|
-
system "rm -r #{filename + '.tmp.html'} #{
|
26
|
+
system "rm -r #{filename + '.tmp.html'} #{tmpimagedir}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def strip_head(input, output)
|
@@ -192,12 +192,12 @@ module IsoDoc::HtmlFunction
|
|
192
192
|
|
193
193
|
# presupposes that the image source is local
|
194
194
|
def move_images(docxml)
|
195
|
-
system "rm -r #{
|
195
|
+
system "rm -r #{tmpimagedir}; mkdir #{tmpimagedir}"
|
196
196
|
docxml.xpath("//*[local-name() = 'img']").each do |i|
|
197
197
|
next if /^data:image/.match i["src"]
|
198
198
|
matched = /\.(?<suffix>\S+)$/.match i["src"]
|
199
199
|
uuid = UUIDTools::UUID.random_create.to_s
|
200
|
-
new_full_filename = File.join(
|
200
|
+
new_full_filename = File.join(tmpimagedir, "#{uuid}.#{matched[:suffix]}")
|
201
201
|
move_image1(i, new_full_filename)
|
202
202
|
end
|
203
203
|
docxml
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -28,7 +28,7 @@ module IsoDoc
|
|
28
28
|
postprocess(result, filename, dir)
|
29
29
|
system "rm -fr #{dir}"
|
30
30
|
::Metanorma::Output::Pdf.new.convert(filename + ".html", outname_html + ".pdf")
|
31
|
-
system "rm -r #{filename + '.html'} #{
|
31
|
+
system "rm -r #{filename + '.html'} #{tmpimagedir}"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/isodoc/version.rb
CHANGED
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -94,7 +94,7 @@ RSpec.describe IsoDoc do
|
|
94
94
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
95
95
|
<preface><foreword>
|
96
96
|
<p>
|
97
|
-
<stem type="AsciiMath"
|
97
|
+
<stem type="AsciiMath"><A></stem>
|
98
98
|
<stem type="MathML"><m:math><m:row>X</m:row></m:math></stem>
|
99
99
|
<stem type="None">Latex?</stem>
|
100
100
|
</p>
|
@@ -107,7 +107,7 @@ RSpec.describe IsoDoc do
|
|
107
107
|
<div>
|
108
108
|
<h1 class="ForewordTitle">Foreword</h1>
|
109
109
|
<p>
|
110
|
-
<span class="stem">(#(A)#)</span>
|
110
|
+
<span class="stem">(#(<A>)#)</span>
|
111
111
|
<span class="stem"><m:math>
|
112
112
|
<m:row>X</m:row>
|
113
113
|
</m:math></span>
|
@@ -468,7 +468,7 @@ CkZJTEVOQU1FOiB0ZXN0Cgo=
|
|
468
468
|
|
469
469
|
it "moves images in HTML" do
|
470
470
|
system "rm -f test.html"
|
471
|
-
system "rm -rf
|
471
|
+
system "rm -rf test_images"
|
472
472
|
IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
|
473
473
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
474
474
|
<preface><foreword>
|
@@ -483,16 +483,16 @@ CkZJTEVOQU1FOiB0ZXN0Cgo=
|
|
483
483
|
INPUT
|
484
484
|
html = File.read("test.html").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
|
485
485
|
sub(%r{</main>.*$}m, "</main>")
|
486
|
-
expect(`ls
|
486
|
+
expect(`ls test_images`).to match(/\.png$/)
|
487
487
|
expect(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")).to be_equivalent_to <<~"OUTPUT"
|
488
488
|
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
489
489
|
<br />
|
490
490
|
<div>
|
491
491
|
<h1 class="ForewordTitle">Foreword</h1>
|
492
492
|
<div id="_" class="figure">
|
493
|
-
<img src="
|
494
|
-
<img src="
|
495
|
-
<img src="
|
493
|
+
<img src="test_images/_.png" height="776" width="922" />
|
494
|
+
<img src="test_images/_.png" height="800" width="53" />
|
495
|
+
<img src="test_images/_.png" height="83" width="99" />
|
496
496
|
<p class="FigureTitle" align="center">Figure 1 — Split-it-right sample divider</p></div>
|
497
497
|
</div>
|
498
498
|
<p class="zzSTDTitle1"></p>
|
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: 0.9.
|
4
|
+
version: 0.9.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: 2018-09-
|
11
|
+
date: 2018-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|