isodoc 0.9.18 → 0.9.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -7
- data/Gemfile.lock +4 -4
- data/README.adoc +6 -6
- data/appveyor.yml +30 -0
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +4 -1
- data/lib/isodoc/function/to_word_html.rb +2 -2
- data/lib/isodoc/headlesshtml_convert.rb +3 -4
- data/lib/isodoc/html_convert.rb +10 -1
- data/lib/isodoc/html_function/html.rb +2 -2
- data/lib/isodoc/pdf_convert.rb +5 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +6 -0
- data/spec/isodoc/footnotes_spec.rb +1 -1
- data/spec/isodoc/postproc_spec.rb +13 -13
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee247cb9d9b705d6a00ec5a27a2cb20295f16c48ffbe4cb6152e934b7c16893b
|
4
|
+
data.tar.gz: b4ddb650b8fcc3fd95f3f6104956cba1e96639158eaf19874704e51bc48aed60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc35a27e441b0f50dcb24aed67e1576024e2246c8784193541532361aaa068981ac1bcfc31a35fc8625149daec18c55fbd14ccd231c9ea8ab155c9193100421
|
7
|
+
data.tar.gz: 73c4c6f98f010ad651d86b834514af80f90fcc9b50d5d50a26bf066a3c9a09d9d888494f732f1458dcb6eac0e098d25e911fb97fd43548da43881c412cd00776
|
data/.travis.yml
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
+
dist: trusty
|
1
2
|
sudo: false
|
2
3
|
language: ruby
|
3
|
-
|
4
4
|
rvm:
|
5
5
|
- 2.5
|
6
6
|
- 2.4
|
7
7
|
- 2.3
|
8
8
|
- ruby-head
|
9
|
-
|
10
|
-
|
11
|
-
-
|
12
|
-
- npm install -g puppeteer
|
13
|
-
- npm install
|
14
|
-
|
9
|
+
before_install:
|
10
|
+
- travis_retry sudo apt-get update
|
11
|
+
- curl -L https://raw.githubusercontent.com/metanorma/metanorma-linux-setup/master/ubuntu-install-puppeteer.sh | bash
|
15
12
|
matrix:
|
16
13
|
allow_failures:
|
17
14
|
- rvm: ruby-head
|
15
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
isodoc (0.9.
|
4
|
+
isodoc (0.9.19)
|
5
5
|
asciimath
|
6
6
|
html2doc (~> 0.8.6)
|
7
7
|
htmlentities (~> 4.3.4)
|
@@ -18,7 +18,7 @@ PATH
|
|
18
18
|
GEM
|
19
19
|
remote: https://rubygems.org/
|
20
20
|
specs:
|
21
|
-
asciidoctor (
|
21
|
+
asciidoctor (2.0.0)
|
22
22
|
asciimath (1.0.8)
|
23
23
|
ast (2.4.0)
|
24
24
|
byebug (9.1.0)
|
@@ -55,7 +55,7 @@ GEM
|
|
55
55
|
htmlentities (4.3.4)
|
56
56
|
image_size (2.0.0)
|
57
57
|
json (2.2.0)
|
58
|
-
liquid (4.0.
|
58
|
+
liquid (4.0.3)
|
59
59
|
listen (3.1.5)
|
60
60
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
61
61
|
rb-inotify (~> 0.9, >= 0.9.7)
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
nenv (~> 0.1)
|
77
77
|
shellany (~> 0.0)
|
78
78
|
parallel (1.14.0)
|
79
|
-
parser (2.6.
|
79
|
+
parser (2.6.2.0)
|
80
80
|
ast (~> 2.4.0)
|
81
81
|
powerpack (0.1.2)
|
82
82
|
pry (0.12.2)
|
data/README.adoc
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
= isodoc: Ruby gem for converting ISODoc documents into HTML/Word
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/isodoc.svg["Gem Version", link="https://rubygems.org/gems/isodoc"]
|
4
|
-
image:https://img.shields.io/travis/
|
5
|
-
image:https://codeclimate.com/github/
|
4
|
+
image:https://img.shields.io/travis/metanorma/isodoc/master.svg["Build Status", link="https://travis-ci.org/metanorma/isodoc"]
|
5
|
+
image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
|
6
6
|
|
7
7
|
== Purpose
|
8
8
|
|
9
|
-
This Gem converts documents in the https://github.com/
|
9
|
+
This Gem converts documents in the https://github.com/metanorma/metanorma-model-standoc[Metanorma document model] into HTML and Microsoft Word.
|
10
10
|
|
11
11
|
== Usage
|
12
12
|
|
13
13
|
The Gem contains the subclasses `Iso::HtmlWordConvert` (for HTML output) and `IsoDoc::WordConvert` (for Word output). They are initialised with the following rendering parameters:
|
14
14
|
|
15
|
-
i18nyaml:: YAML file giving internationalisation equivalents for keywords in rendering output; see https://github.com/
|
15
|
+
i18nyaml:: YAML file giving internationalisation equivalents for keywords in rendering output; see https://github.com/metanorma/metanorma-iso#document-attributes for further documentation
|
16
16
|
bodyfont:: Font for body text
|
17
17
|
headerfont:: Font for header text
|
18
18
|
monospacefont:: Font for monospace text
|
@@ -80,6 +80,6 @@ NOTE: In the HTML stylesheets specific to standards, the Cover page and Intro pa
|
|
80
80
|
|
81
81
|
== Converting Word output into "`Native Word`" (`.docx`)
|
82
82
|
|
83
|
-
This gem relies on https://github.com/
|
83
|
+
This gem relies on https://github.com/metanorma/html2doc[html2doc] to generate Microsoft Word documents.
|
84
84
|
|
85
|
-
Please see https://github.com/
|
85
|
+
Please see https://github.com/metanorma/html2doc#converting-document-output-to-native-word-docx[this post-processing procedure] to convert output into a native-`docx` document.
|
data/appveyor.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
|
3
|
+
environment:
|
4
|
+
matrix:
|
5
|
+
- RUBY_VERSION: 25
|
6
|
+
- RUBY_VERSION: 24
|
7
|
+
- RUBY_VERSION: 23
|
8
|
+
- RUBY_VERSION: _trunk
|
9
|
+
|
10
|
+
matrix:
|
11
|
+
allow_failures:
|
12
|
+
- RUBY_VERSION: _trunk
|
13
|
+
|
14
|
+
install:
|
15
|
+
- ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
|
16
|
+
- refreshenv
|
17
|
+
|
18
|
+
build_script:
|
19
|
+
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
20
|
+
- bundle update
|
21
|
+
- bundle install
|
22
|
+
|
23
|
+
before_test:
|
24
|
+
- ruby -v
|
25
|
+
- gem -v
|
26
|
+
- bundle -v
|
27
|
+
|
28
|
+
test_script:
|
29
|
+
- bundle exec rake
|
30
|
+
|
data/isodoc.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
This gem is in active development.
|
20
20
|
DESCRIPTION
|
21
21
|
|
22
|
-
spec.homepage = "https://github.com/
|
22
|
+
spec.homepage = "https://github.com/metanorma/isodoc"
|
23
23
|
spec.license = "BSD-2-Clause"
|
24
24
|
|
25
25
|
spec.bindir = "bin"
|
data/lib/isodoc/convert.rb
CHANGED
@@ -62,11 +62,14 @@ module IsoDoc
|
|
62
62
|
@closemathdelim = "`"
|
63
63
|
@lang = "en"
|
64
64
|
@script = "Latn"
|
65
|
-
@tmpimagedir = "_images"
|
66
65
|
@maxwidth = 1200
|
67
66
|
@maxheight = 800
|
68
67
|
end
|
69
68
|
|
69
|
+
def tmpimagedir_suffix
|
70
|
+
"_images"
|
71
|
+
end
|
72
|
+
|
70
73
|
def default_fonts(_options)
|
71
74
|
{
|
72
75
|
bodyfont: "Arial",
|
@@ -29,11 +29,11 @@ module IsoDoc::Function
|
|
29
29
|
|
30
30
|
# tmp image dir is same directory as @filename
|
31
31
|
def tmpimagedir
|
32
|
-
@filename +
|
32
|
+
@filename + tmpimagedir_suffix
|
33
33
|
end
|
34
34
|
|
35
35
|
def rel_tmpimagedir
|
36
|
-
@filename.sub(%r{^.*/([^/]+)$}, "\\1") +
|
36
|
+
@filename.sub(%r{^.*/([^/]+)$}, "\\1") + tmpimagedir_suffix
|
37
37
|
end
|
38
38
|
|
39
39
|
# isodoc.css overrides any CSS injected by Html2Doc, which
|
@@ -10,9 +10,8 @@ module IsoDoc
|
|
10
10
|
include HtmlFunction::Footnotes
|
11
11
|
include HtmlFunction::Html
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
@tmpimagedir = "_headlessimages"
|
13
|
+
def tmpimagedir_suffix
|
14
|
+
"_headlessimages"
|
16
15
|
end
|
17
16
|
|
18
17
|
def convert(filename, file = nil, debug = false)
|
@@ -24,7 +23,7 @@ module IsoDoc
|
|
24
23
|
postprocess(result, filename + ".tmp", dir)
|
25
24
|
FileUtils.rm_rf dir
|
26
25
|
strip_head(filename + ".tmp.html", outname_html + ".headless.html")
|
27
|
-
FileUtils.
|
26
|
+
FileUtils.rm_rf ["#{filename}.tmp.html", tmpimagedir]
|
28
27
|
end
|
29
28
|
|
30
29
|
def strip_head(input, output)
|
data/lib/isodoc/html_convert.rb
CHANGED
@@ -9,6 +9,15 @@ module IsoDoc
|
|
9
9
|
include HtmlFunction::Footnotes
|
10
10
|
include HtmlFunction::Html
|
11
11
|
|
12
|
-
|
12
|
+
def tmpimagedir_suffix
|
13
|
+
"_htmlimages"
|
14
|
+
end
|
15
|
+
|
16
|
+
def convert(filename, file = nil, debug = false)
|
17
|
+
ret = super
|
18
|
+
Dir.exists?(tmpimagedir) and Dir["#{tmpimagedir}/*"].empty? and
|
19
|
+
FileUtils.rm_r tmpimagedir
|
20
|
+
ret
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
@@ -58,7 +58,7 @@ module IsoDoc::HtmlFunction
|
|
58
58
|
end
|
59
59
|
|
60
60
|
MATHJAX_ADDR =
|
61
|
-
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.
|
61
|
+
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js".freeze
|
62
62
|
MATHJAX = <<~"MATHJAX".freeze
|
63
63
|
<script type="text/x-mathjax-config">
|
64
64
|
MathJax.Hub.Config({
|
@@ -67,7 +67,7 @@ module IsoDoc::HtmlFunction
|
|
67
67
|
}
|
68
68
|
});
|
69
69
|
</script>
|
70
|
-
<script src="#{MATHJAX_ADDR}?config=AM_HTMLorMML"></script>
|
70
|
+
<script src="#{MATHJAX_ADDR}?config=AM_HTMLorMML" async="async"></script>
|
71
71
|
MATHJAX
|
72
72
|
|
73
73
|
def mathjax(open, close)
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -14,11 +14,14 @@ module IsoDoc
|
|
14
14
|
@standardstylesheet = nil
|
15
15
|
super
|
16
16
|
@scripts = @scripts_pdf if @scripts_pdf
|
17
|
-
@tmpimagedir = "_pdfimages"
|
18
17
|
@maxwidth = 500
|
19
18
|
@maxheight = 800
|
20
19
|
end
|
21
20
|
|
21
|
+
def tmpimagedir_suffix
|
22
|
+
"_pdfimages"
|
23
|
+
end
|
24
|
+
|
22
25
|
def convert(filename, file = nil, debug = false)
|
23
26
|
file = File.read(filename, encoding: "utf-8") if file.nil?
|
24
27
|
@openmathdelim, @closemathdelim = extract_delims(file)
|
@@ -28,7 +31,7 @@ module IsoDoc
|
|
28
31
|
postprocess(result, filename, dir)
|
29
32
|
FileUtils.rm_rf dir
|
30
33
|
::Metanorma::Output::Pdf.new.convert("#{filename}.html", outname_html + ".pdf")
|
31
|
-
FileUtils.
|
34
|
+
FileUtils.rm_rf ["#{filename}.html", tmpimagedir]
|
32
35
|
end
|
33
36
|
|
34
37
|
def xref_parse(node, out)
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/word_convert.rb
CHANGED
@@ -152,7 +152,7 @@ RSpec.describe IsoDoc do
|
|
152
152
|
}
|
153
153
|
});
|
154
154
|
</script>
|
155
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.
|
155
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=AM_HTMLorMML" async="async"></script>
|
156
156
|
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
|
157
157
|
</body>
|
158
158
|
OUTPUT
|
@@ -21,7 +21,7 @@ RSpec.describe IsoDoc do
|
|
21
21
|
html = File.read("test.html")
|
22
22
|
expect(html).to match(%r{<title>test</title>})
|
23
23
|
expect(html).to match(/another empty stylesheet/)
|
24
|
-
expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/
|
24
|
+
expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
|
25
25
|
expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
|
26
26
|
end
|
27
27
|
|
@@ -41,7 +41,7 @@ RSpec.describe IsoDoc do
|
|
41
41
|
html = File.read("test.html")
|
42
42
|
expect(html).not_to match(%r{<title>test</title>})
|
43
43
|
expect(html).not_to match(/another empty stylesheet/)
|
44
|
-
expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/
|
44
|
+
expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
|
45
45
|
expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
|
46
46
|
end
|
47
47
|
|
@@ -468,7 +468,7 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
|
|
468
468
|
|
469
469
|
it "moves images in HTML" do
|
470
470
|
FileUtils.rm_f "test.html"
|
471
|
-
FileUtils.rm_rf "
|
471
|
+
FileUtils.rm_rf "test_htmlimages"
|
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 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
|
|
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_htmlimages`).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_htmlimages/_.png" height="776" width="922" />
|
494
|
+
<img src="test_htmlimages/_.png" height="800" width="53" />
|
495
|
+
<img src="test_htmlimages/_.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>
|
@@ -503,7 +503,7 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
|
|
503
503
|
|
504
504
|
it "moves images in HTML, using relative file location" do
|
505
505
|
FileUtils.rm_f "spec/test.html"
|
506
|
-
FileUtils.rm_rf "spec/
|
506
|
+
FileUtils.rm_rf "spec/test_htmlimages"
|
507
507
|
IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/test", <<~"INPUT", false)
|
508
508
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
509
509
|
<preface><foreword>
|
@@ -518,16 +518,16 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
|
|
518
518
|
INPUT
|
519
519
|
html = File.read("spec/test.html").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
|
520
520
|
sub(%r{</main>.*$}m, "</main>")
|
521
|
-
expect(`ls
|
521
|
+
expect(`ls test_htmlimages`).to match(/\.png$/)
|
522
522
|
expect(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")).to be_equivalent_to <<~"OUTPUT"
|
523
523
|
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
524
524
|
<br />
|
525
525
|
<div>
|
526
526
|
<h1 class="ForewordTitle">Foreword</h1>
|
527
527
|
<div id="_" class="figure">
|
528
|
-
<img src="
|
529
|
-
<img src="
|
530
|
-
<img src="
|
528
|
+
<img src="test_htmlimages/_.png" height="776" width="922" />
|
529
|
+
<img src="test_htmlimages/_.png" height="800" width="53" />
|
530
|
+
<img src="test_htmlimages/_.png" height="83" width="99" />
|
531
531
|
<p class="FigureTitle" align="center">Figure 1 — Split-it-right sample divider</p></div>
|
532
532
|
</div>
|
533
533
|
<p class="zzSTDTitle1"></p>
|
@@ -538,7 +538,7 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
|
|
538
538
|
|
539
539
|
it "encodes images in HTML as data URIs" do
|
540
540
|
FileUtils.rm_f "test.html"
|
541
|
-
FileUtils.rm_rf "
|
541
|
+
FileUtils.rm_rf "test_htmlimages"
|
542
542
|
IsoDoc::HtmlConvert.new({htmlstylesheet: "spec/assets/html.css", datauriimage: true}).convert("test", <<~"INPUT", false)
|
543
543
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
544
544
|
<preface><foreword>
|
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.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -327,6 +327,7 @@ files:
|
|
327
327
|
- LICENSE
|
328
328
|
- README.adoc
|
329
329
|
- Rakefile
|
330
|
+
- appveyor.yml
|
330
331
|
- bin/rspec
|
331
332
|
- isodoc.gemspec
|
332
333
|
- lib/isodoc-yaml/i18n-en.yaml
|
@@ -391,7 +392,7 @@ files:
|
|
391
392
|
- spec/isodoc/terms_spec.rb
|
392
393
|
- spec/isodoc/xref_spec.rb
|
393
394
|
- spec/spec_helper.rb
|
394
|
-
homepage: https://github.com/
|
395
|
+
homepage: https://github.com/metanorma/isodoc
|
395
396
|
licenses:
|
396
397
|
- BSD-2-Clause
|
397
398
|
metadata: {}
|