isodoc 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/function/to_word_html.rb +4 -2
- data/lib/isodoc/html_function/html.rb +4 -4
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +6 -7
- data/spec/isodoc/postproc_spec.rb +35 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93ba96559e2759a596b63d1a785bfb669b3e0b1b400a091af8a6c54c4c6f1470
|
4
|
+
data.tar.gz: 0c48f7c99b83091ab02ad792a6d5dd555fcc0777da4d3931dac7ed824884e0c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b89709b81819fe0b5ed8b48fcb33f7f25f998659f74d97fa65d4642acf762d8c96aca75f525d8941596cea8ba60ad1fd6c3687ae1a178e95d49ce48a7d93e2cc
|
7
|
+
data.tar.gz: c0c0b053b432bafed3e2c926f33cf39b926bfc4e4b0467f4e5c66223d5d9df7e8d4a77fe0b188de319af2f5113a75f5b2c38a111f51e6b690e2b85dacd6819ba
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
isodoc (0.9.
|
4
|
+
isodoc (0.9.7)
|
5
5
|
asciimath
|
6
|
-
html2doc (~> 0.8.
|
6
|
+
html2doc (~> 0.8.6)
|
7
7
|
htmlentities (~> 4.3.4)
|
8
8
|
liquid
|
9
9
|
metanorma (~> 0.3.0)
|
@@ -42,7 +42,7 @@ GEM
|
|
42
42
|
guard (~> 2.1)
|
43
43
|
guard-compat (~> 1.1)
|
44
44
|
rspec (>= 2.99.0, < 4.0)
|
45
|
-
html2doc (0.8.
|
45
|
+
html2doc (0.8.6)
|
46
46
|
asciimath
|
47
47
|
htmlentities (~> 4.3.4)
|
48
48
|
image_size
|
@@ -74,7 +74,7 @@ GEM
|
|
74
74
|
nenv (~> 0.1)
|
75
75
|
shellany (~> 0.0)
|
76
76
|
parallel (1.12.1)
|
77
|
-
parser (2.5.
|
77
|
+
parser (2.5.3.0)
|
78
78
|
ast (~> 2.4.0)
|
79
79
|
powerpack (0.1.2)
|
80
80
|
pry (0.11.3)
|
@@ -146,4 +146,4 @@ DEPENDENCIES
|
|
146
146
|
timecop (~> 0.9)
|
147
147
|
|
148
148
|
BUNDLED WITH
|
149
|
-
1.
|
149
|
+
1.17.1
|
data/isodoc.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "ruby-xslt"
|
35
35
|
spec.add_dependency "thread_safe"
|
36
36
|
spec.add_dependency "uuidtools"
|
37
|
-
spec.add_dependency "html2doc", "~> 0.8.
|
37
|
+
spec.add_dependency "html2doc", "~> 0.8.6"
|
38
38
|
spec.add_dependency "liquid"
|
39
39
|
spec.add_dependency "roman-numerals"
|
40
40
|
spec.add_dependency "sassc", "~> 1.12.1"
|
@@ -23,11 +23,13 @@ module IsoDoc::Function
|
|
23
23
|
FileUtils.rm_rf "#{dir}/*"
|
24
24
|
end
|
25
25
|
@filename = filename
|
26
|
+
@localdir = %r{/}.match(filename) ? filename.sub(%r{/[^/]+$}, "/") : "./"
|
26
27
|
[filename, dir]
|
27
28
|
end
|
28
29
|
|
30
|
+
# tmp image dir is same directory as @filename
|
29
31
|
def tmpimagedir
|
30
|
-
@filename + @tmpimagedir
|
32
|
+
@filename.sub(%r{^.*/([^/]+)$}, "\\1") + @tmpimagedir
|
31
33
|
end
|
32
34
|
|
33
35
|
|
@@ -39,7 +41,7 @@ module IsoDoc::Function
|
|
39
41
|
if @standardstylesheet
|
40
42
|
head.style do |style|
|
41
43
|
stylesheet = File.read(@standardstylesheet, encoding: "utf-8").
|
42
|
-
gsub("FILENAME", filename)
|
44
|
+
gsub("FILENAME", File.basename(filename))
|
43
45
|
style.comment "\n#{stylesheet}\n"
|
44
46
|
end
|
45
47
|
end
|
@@ -205,8 +205,7 @@ module IsoDoc::HtmlFunction
|
|
205
205
|
|
206
206
|
def datauri(i)
|
207
207
|
type = i["src"].split(".")[-1]
|
208
|
-
|
209
|
-
bin = File.read(i["src"], encoding: "utf-8")
|
208
|
+
bin = File.read(@localdir + i["src"], encoding: "utf-8")
|
210
209
|
data = Base64.strict_encode64(bin)
|
211
210
|
i["src"] = "data:image/#{type};base64,#{data}"
|
212
211
|
end
|
@@ -215,9 +214,10 @@ module IsoDoc::HtmlFunction
|
|
215
214
|
matched = /\.(?<suffix>\S+)$/.match i["src"]
|
216
215
|
uuid = UUIDTools::UUID.random_create.to_s
|
217
216
|
new_full_filename = File.join(tmpimagedir, "#{uuid}.#{matched[:suffix]}")
|
218
|
-
|
217
|
+
local_filename = File.join(@localdir, i["src"])
|
218
|
+
FileUtils.cp local_filename, new_full_filename
|
219
219
|
i["src"] = new_full_filename
|
220
|
-
i["width"], i["height"] = Html2Doc.image_resize(i, @maxheight, @maxwidth)
|
220
|
+
i["width"], i["height"] = Html2Doc.image_resize(i, local_filename, @maxheight, @maxwidth)
|
221
221
|
end
|
222
222
|
|
223
223
|
def html_toc(docxml)
|
data/lib/isodoc/version.rb
CHANGED
@@ -29,7 +29,8 @@ module IsoDoc::WordFunction
|
|
29
29
|
|
30
30
|
def word_admonition_images(docxml)
|
31
31
|
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
32
|
-
|
32
|
+
i["width"], i["height"] =
|
33
|
+
Html2Doc.image_resize(i, File.join(@localdir, i["src"]), @maxheight, 300)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -85,16 +86,14 @@ module IsoDoc::WordFunction
|
|
85
86
|
|
86
87
|
def generate_header(filename, _dir)
|
87
88
|
return nil unless @header
|
88
|
-
#template = Liquid::Template.parse(File.read(@header, encoding: "UTF-8"))
|
89
89
|
template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
|
90
90
|
meta = @meta.get
|
91
91
|
meta[:filename] = filename
|
92
92
|
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
93
|
-
File.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
"header.html"
|
93
|
+
headerfile = File.join(@localdir, "header.html")
|
94
|
+
File.open(headerfile, "w:UTF-8") { |f| f.write(template.render(params)) }
|
95
|
+
@files_to_delete << headerfile
|
96
|
+
headerfile
|
98
97
|
end
|
99
98
|
|
100
99
|
def word_toc_entry(toclevel, heading)
|
@@ -544,6 +544,41 @@ CkZJTEVOQU1FOiB0ZXN0Cgo=
|
|
544
544
|
|
545
545
|
end
|
546
546
|
|
547
|
+
it "moves images in HTML, using relative file location" do
|
548
|
+
FileUtils.rm_f "spec/test.html"
|
549
|
+
FileUtils.rm_rf "spec/test_images"
|
550
|
+
IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/test", <<~"INPUT", false)
|
551
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
552
|
+
<preface><foreword>
|
553
|
+
<figure id="_">
|
554
|
+
<name>Split-it-right sample divider</name>
|
555
|
+
<image src="assets/rice_image1.png" id="_" imagetype="PNG"/>
|
556
|
+
<image src="assets/rice_image1.png" id="_" width="20000" height="300000" imagetype="PNG"/>
|
557
|
+
<image src="assets/rice_image1.png" id="_" width="99" height="auto" imagetype="PNG"/>
|
558
|
+
</figure>
|
559
|
+
</foreword></preface>
|
560
|
+
</iso-standard>
|
561
|
+
INPUT
|
562
|
+
html = File.read("spec/test.html").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
|
563
|
+
sub(%r{</main>.*$}m, "</main>")
|
564
|
+
expect(`ls test_images`).to match(/\.png$/)
|
565
|
+
expect(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")).to be_equivalent_to <<~"OUTPUT"
|
566
|
+
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
567
|
+
<br />
|
568
|
+
<div>
|
569
|
+
<h1 class="ForewordTitle">Foreword</h1>
|
570
|
+
<div id="_" class="figure">
|
571
|
+
<img src="test_images/_.png" height="776" width="922" />
|
572
|
+
<img src="test_images/_.png" height="800" width="53" />
|
573
|
+
<img src="test_images/_.png" height="83" width="99" />
|
574
|
+
<p class="FigureTitle" align="center">Figure 1 — Split-it-right sample divider</p></div>
|
575
|
+
</div>
|
576
|
+
<p class="zzSTDTitle1"></p>
|
577
|
+
</main>
|
578
|
+
OUTPUT
|
579
|
+
end
|
580
|
+
|
581
|
+
|
547
582
|
it "encodes images in HTML as data URIs" do
|
548
583
|
FileUtils.rm_f "test.html"
|
549
584
|
FileUtils.rm_rf "test_images"
|
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.7
|
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-10-
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.8.
|
103
|
+
version: 0.8.6
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.8.
|
110
|
+
version: 0.8.6
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: liquid
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|