isodoc 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -1
  3. data/Gemfile.lock +5 -3
  4. data/isodoc.gemspec +1 -0
  5. data/lib/isodoc.rb +1 -2
  6. data/lib/isodoc/convert.rb +3 -3
  7. data/lib/isodoc/function/i18n.rb +6 -3
  8. data/lib/isodoc/function/inline.rb +3 -4
  9. data/lib/isodoc/function/references.rb +2 -0
  10. data/lib/isodoc/function/section.rb +9 -11
  11. data/lib/isodoc/function/to_word_html.rb +1 -1
  12. data/lib/isodoc/function/xref_sect_gen.rb +22 -18
  13. data/lib/isodoc/headlesshtml_convert.rb +39 -0
  14. data/lib/isodoc/html_function/html.rb +1 -1
  15. data/lib/isodoc/metadata.rb +11 -78
  16. data/lib/isodoc/pdf_convert.rb +3 -2
  17. data/lib/isodoc/version.rb +1 -1
  18. data/lib/isodoc/word_function/postprocess.rb +1 -1
  19. data/spec/isodoc/blocks_spec.rb +2 -2
  20. data/spec/isodoc/i18n_spec.rb +8 -48
  21. data/spec/isodoc/inline_spec.rb +4 -0
  22. data/spec/isodoc/metadata_spec.rb +8 -31
  23. data/spec/isodoc/postproc_spec.rb +27 -13
  24. data/spec/isodoc/section_spec.rb +4 -24
  25. data/spec/isodoc/terms_spec.rb +8 -8
  26. data/spec/isodoc/xref_spec.rb +11 -19
  27. metadata +17 -16
  28. data/lib/isodoc/iso/html/header.html +0 -206
  29. data/lib/isodoc/iso/html/html_iso_intro.html +0 -34
  30. data/lib/isodoc/iso/html/html_iso_titlepage.html +0 -34
  31. data/lib/isodoc/iso/html/htmlstyle.scss +0 -46
  32. data/lib/isodoc/iso/html/isodoc.scss +0 -696
  33. data/lib/isodoc/iso/html/scripts.html +0 -174
  34. data/lib/isodoc/iso/html/style-human.scss +0 -1277
  35. data/lib/isodoc/iso/html/style-iso.scss +0 -1257
  36. data/lib/isodoc/iso/html/word_iso_intro.html +0 -72
  37. data/lib/isodoc/iso/html/word_iso_titlepage.html +0 -62
  38. data/lib/isodoc/iso/html/wordstyle.scss +0 -1175
  39. data/lib/isodoc/iso/html_convert.rb +0 -50
  40. data/lib/isodoc/iso/word_convert.rb +0 -53
  41. data/spec/isodoc/iso_spec.rb +0 -168
@@ -1,50 +0,0 @@
1
- module IsoDoc
2
- module Iso
3
- class HtmlConvert < IsoDoc::HtmlConvert
4
-
5
- def default_fonts(options)
6
- b = options[:bodyfont] ||
7
- (options[:script] == "Hans" ? '"SimSun",serif' :
8
- '"Cambria",serif')
9
- h = options[:headerfont] ||
10
- (options[:script] == "Hans" ? '"SimHei",sans-serif' :
11
- '"Cambria",serif')
12
- m = options[:monospacefont] || '"Courier New",monospace'
13
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
14
- end
15
-
16
- def alt_fonts(options)
17
- b = options[:bodyfont] ||
18
- (options[:script] == "Hans" ? '"SimSun",serif' :
19
- '"Lato",sans-serif')
20
- h = options[:headerfont] ||
21
- (options[:script] == "Hans" ? '"SimHei",sans-serif' :
22
- '"Lato",sans-serif')
23
- m = options[:monospacefont] || '"Space Mono",monospace'
24
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
25
- end
26
-
27
- def html_doc_path(file)
28
- File.join(File.dirname(__FILE__), File.join("html", file))
29
- end
30
-
31
- def initialize(options)
32
- super
33
- if options[:alt]
34
- css = generate_css(html_doc_path("style-human.scss"), true, alt_fonts(options))
35
- else
36
- css = generate_css(html_doc_path("style-iso.scss"), true, default_fonts(options))
37
- end
38
- @htmlstylesheet = css
39
- @htmlcoverpage = html_doc_path("html_iso_titlepage.html")
40
- @htmlintropage = html_doc_path("html_iso_intro.html")
41
- @scripts = html_doc_path("scripts.html")
42
- end
43
-
44
- def implicit_reference(b)
45
- isocode = b.at(ns("./docidentifier")).text
46
- isocode == "IEV"
47
- end
48
- end
49
- end
50
- end
@@ -1,53 +0,0 @@
1
- module IsoDoc
2
- module Iso
3
- class WordConvert < IsoDoc::WordConvert
4
-
5
- def default_fonts(options)
6
- b = options[:bodyfont] ||
7
- (options[:script] == "Hans" ? '"SimSun",serif' :
8
- '"Cambria",serif')
9
- h = options[:headerfont] ||
10
- (options[:script] == "Hans" ? '"SimHei",sans-serif' :
11
- '"Cambria",serif')
12
- m = options[:monospacefont] || '"Courier New",monospace'
13
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
14
- end
15
-
16
- def html_doc_path(file)
17
- File.join(File.dirname(__FILE__), File.join("html", file))
18
- end
19
-
20
- def initialize(options)
21
- super
22
- @wordstylesheet = generate_css(html_doc_path("wordstyle.scss"), false, default_fonts(options))
23
- @standardstylesheet = generate_css(html_doc_path("isodoc.scss"), false, default_fonts(options))
24
- @header = html_doc_path("header.html")
25
- @wordcoverpage = html_doc_path("word_iso_titlepage.html")
26
- @wordintropage = html_doc_path("word_iso_intro.html")
27
- @ulstyle = "l3"
28
- @olstyle = "l2"
29
- end
30
-
31
- def implicit_reference(b)
32
- isocode = b.at(ns("./docidentifier")).text
33
- isocode == "IEV"
34
- end
35
-
36
- def make_body(xml, docxml)
37
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
38
- xml.body **body_attr do |body|
39
- make_body1(body, docxml)
40
- make_body2(body, docxml)
41
- make_body3(body, docxml)
42
- colophon(body, docxml)
43
- end
44
- end
45
-
46
- def colophon(body, docxml)
47
- body.br **{ clear: "all", style: "page-break-before:left;mso-break-type:section-break" }
48
- body.div **{ class: "colophon" } do |div|
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,168 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe IsoDoc do
4
- system "rm -f test.html"
5
- it "processes isodoc as ISO: HTML output" do
6
- IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", false)
7
- <iso-standard xmlns="http://riboseinc.com/isoxml">
8
- <preface><foreword>
9
- <note>
10
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
11
- </note>
12
- </foreword></preface>
13
- </iso-standard>
14
- INPUT
15
- html = File.read("test.html", encoding: "utf-8")
16
- expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
17
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
18
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
19
- end
20
-
21
- it "processes isodoc as ISO: alt HTML output" do
22
- system "rm -f test.html"
23
- IsoDoc::Iso::HtmlConvert.new({alt: true}).convert("test", <<~"INPUT", false)
24
- <iso-standard xmlns="http://riboseinc.com/isoxml">
25
- <preface><foreword>
26
- <note>
27
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
28
- </note>
29
- </foreword></preface>
30
- </iso-standard>
31
- INPUT
32
- html = File.read("test.html", encoding: "utf-8")
33
- expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
34
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
35
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
36
- end
37
-
38
- it "processes isodoc as ISO: Chinese HTML output" do
39
- system "rm -f test.html"
40
- IsoDoc::Iso::HtmlConvert.new({script: "Hans"}).convert("test", <<~"INPUT", false)
41
- <iso-standard xmlns="http://riboseinc.com/isoxml">
42
- <preface><foreword>
43
- <note>
44
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
45
- </note>
46
- </foreword></preface>
47
- </iso-standard>
48
- INPUT
49
- html = File.read("test.html", encoding: "utf-8")
50
- expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
51
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "SimSun", serif;]m)
52
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
53
- end
54
-
55
- it "processes isodoc as ISO: user nominated fonts" do
56
- system "rm -f test.html"
57
- IsoDoc::Iso::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).convert("test", <<~"INPUT", false)
58
- <iso-standard xmlns="http://riboseinc.com/isoxml">
59
- <preface><foreword>
60
- <note>
61
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
62
- </note>
63
- </foreword></preface>
64
- </iso-standard>
65
- INPUT
66
- html = File.read("test.html", encoding: "utf-8")
67
- expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: Andale Mono;]m)
68
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
69
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
70
- end
71
-
72
- it "processes isodoc as ISO: Word output" do
73
- system "rm -f test.doc"
74
- IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", false)
75
- <iso-standard xmlns="http://riboseinc.com/isoxml">
76
- <preface><foreword>
77
- <note>
78
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
79
- </note>
80
- </foreword></preface>
81
- </iso-standard>
82
- INPUT
83
- html = File.read("test.doc", encoding: "utf-8")
84
- expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
85
- expect(html).to match(%r[Quote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
86
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
87
- end
88
-
89
- it "does not include IEV in references" do
90
- expect(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
91
- <iso-standard xmlns="http://riboseinc.com/isoxml">
92
- <preface><foreword>
93
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
94
- <eref bibitemid="IEV"/>
95
- <eref bibitemid="ISO20483"/>
96
- </p>
97
- </foreword></preface>
98
- <bibliography><references id="_normative_references" obligation="informative"><title>Normative References</title>
99
- <bibitem type="international-standard" id="IEV">
100
- <title format="text/plain" language="en" script="Latn">Electropedia:
101
- The World's Online Electrotechnical Vocabulary</title>
102
- <source type="src">http://www.electropedia.org</source>
103
- <docidentifier>IEV</docidentifier>
104
- <date type="published"> <on>2018</on> </date>
105
- <contributor>
106
- <role type="publisher"/>
107
- <organization>
108
- <name>International Electrotechnical Commission</name>
109
- <abbreviation>IEC</abbreviation>
110
- <uri>www.iec.ch</uri>
111
- </organization>
112
- </contributor>
113
- <language>en</language> <language>fr</language>
114
- <script>Latn</script>
115
- <copyright>
116
- <from>2018</from>
117
- <owner>
118
- <organization>
119
- <name>International Electrotechnical Commission</name>
120
- <abbreviation>IEC</abbreviation>
121
- <uri>www.iec.ch</uri>
122
- </organization>
123
- </owner>
124
- </copyright>
125
- <relation type="updates">
126
- <bibitem>
127
- <formattedref>IEC 60050</formattedref>
128
- </bibitem>
129
- </relation>
130
- </bibitem>
131
- <bibitem id="ISO20483" type="standard">
132
- <title format="text/plain">Cereals and pulses</title>
133
- <docidentifier>ISO 20483</docidentifier>
134
- <date type="published"><from>2013</from><to>2014</to></date>
135
- <contributor>
136
- <role type="publisher"/>
137
- <organization>
138
- <name>International Organization for Standardization</name>
139
- </organization>
140
- </contributor>
141
- </bibitem>
142
- </references>
143
- </bibliography>
144
- </iso-standard>
145
- INPUT
146
- #{HTML_HDR}
147
- <br/>
148
- <div>
149
- <h1 class="ForewordTitle">Foreword</h1>
150
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
151
- <a href="#IEV">IEV:2018</a>
152
- <a href="#ISO20483">ISO 20483:2013&#8211;2014</a>
153
- </p>
154
- </div>
155
- <p class="zzSTDTitle1"/>
156
- <div>
157
- <h1>1.&#160; Normative references</h1>
158
- <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
159
- <p id="ISO20483" class="NormRef">ISO 20483:2013&#8211;2014, <i> Cereals and pulses</i></p>
160
- </div>
161
- </div>
162
- </body>
163
- </html>
164
-
165
- OUTPUT
166
- end
167
-
168
- end