isodoc 1.1.1 → 1.1.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: 0fe7dc7a4c361573ce166000c4b747853185889ed1385f6219da5ecd9bf33b73
4
- data.tar.gz: 2da4bf7a5c8a282bdfee95b96b99322c246712405b429404d5accf3385f9b360
3
+ metadata.gz: 51829acf741b07dd3c2ab2be2d56ca10aa26f32cd45830c53fe53a0ac26c8ad5
4
+ data.tar.gz: f7e70d7ca7b40958a35799f564c05b0a3d5342efdf3c6e3dd5e41536a7bb9825
5
5
  SHA512:
6
- metadata.gz: 62e7510c6f20ac7d8773d112bc25957c543097164e3b794dcc05d9b241be70317ea37295e9da8d3fcf61aec5597471091af2912277977db1fa266dd3f5351cae
7
- data.tar.gz: 6c09ae0a60b767cd4d3dd4ce22a6df2609ea8d1a21f29863a5c5ca27283ebe5897f0d530bf89212dc7b8cd4788641f66d04d646a04189f9c3c379e058d3c50c7
6
+ metadata.gz: e2ff423a107d6b06cc723c943ac2311513c78a46d8b63f4ded2e8b7ebf94794d00796ef2b52ad2921dc1efd97cbba8bc43b29b0e8091b2c9430627db67a75f4f
7
+ data.tar.gz: ec09dbbcf25e13bb08352f49d77c1565473f768af554a3d2b1b7311b0862f63e730fee0f69b7af82f99ce8f3a020b3088b429ed253a9852708138867dd848519
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require 'isodoc/gem_tasks'
3
4
 
5
+ IsoDoc::GemTasks.install
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task default: :spec
8
+ task default: :spec
@@ -36,11 +36,11 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "html2doc", "~> 1.0.0"
37
37
  spec.add_dependency "liquid"
38
38
  spec.add_dependency "roman-numerals"
39
- spec.add_dependency "sassc", "~> 2.4.0"
40
39
  spec.add_dependency "metanorma", "~> 1.1.0"
41
- spec.add_dependency "rake", "~> 12.0"
42
40
 
41
+ spec.add_development_dependency "rake", "~> 13.0"
43
42
  spec.add_development_dependency "byebug", "~> 9.1"
43
+ spec.add_development_dependency "sassc", "~> 2.4.0"
44
44
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
45
45
  spec.add_development_dependency "guard", "~> 2.14"
46
46
  spec.add_development_dependency "guard-rspec", "~> 4.7"
@@ -0,0 +1,207 @@
1
+ html, body, div, span, applet, object, iframe,
2
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3
+ a, abbr, acronym, address, big, cite, code,
4
+ del, dfn, em, img, ins, kbd, q, s, samp,
5
+ small, strike, strong, sub, sup, tt, var,
6
+ b, u, i, center,
7
+ ol, ul, li,
8
+ fieldset, form, label, legend,
9
+ table, caption, tbody, tfoot, thead, tr, th, td,
10
+ article, aside, canvas, details, embed,
11
+ figure, figcaption, footer, header, hgroup,
12
+ menu, nav, output, ruby, section, summary,
13
+ time, mark, audio, video {
14
+ margin: 0;
15
+ padding: 0; }
16
+
17
+ html, body, div, span, applet, object, iframe,
18
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
19
+ a, abbr, acronym, address, big, cite, code,
20
+ del, dfn, em, img, ins, kbd, q, s, samp,
21
+ small, strike, strong, sub, sup, tt, var,
22
+ b, u, i, center,
23
+ dl, dt, dd, ol, ul, li,
24
+ fieldset, form, label, legend,
25
+ table, caption, tbody, tfoot, thead, tr, th, td,
26
+ article, aside, canvas, details, embed,
27
+ figure, figcaption, footer, header, hgroup,
28
+ menu, nav, output, ruby, section, summary,
29
+ time, mark, audio, video {
30
+ border: 0;
31
+ font-size: 100%; }
32
+
33
+ html, body, div, span, applet, object, iframe,
34
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
35
+ a, abbr, acronym, address, big, cite, code,
36
+ del, dfn, em, img, ins, kbd, q, s, samp,
37
+ small, strike, strong, tt, var,
38
+ b, u, i, center,
39
+ dl, dd, ol, ul, li,
40
+ fieldset, form, label, legend,
41
+ table, caption, tbody, tfoot, thead, tr, th, td,
42
+ article, aside, canvas, details, embed,
43
+ figure, figcaption, footer, header, hgroup,
44
+ menu, nav, output, ruby, section, summary,
45
+ time, mark, audio, video {
46
+ vertical-align: baseline; }
47
+
48
+ html, body, div, span, applet, object, iframe,
49
+ p, blockquote,
50
+ a, abbr, acronym, address, big, cite,
51
+ del, dfn, em, img, ins, q, s,
52
+ small, strike, strong, sub, sup, var,
53
+ b, u, i, center,
54
+ dl, dt, dd, ol, ul, li,
55
+ fieldset, form, label, legend,
56
+ table, caption, tbody, tfoot, thead, tr, th, td,
57
+ article, aside, canvas, details, embed,
58
+ figure, figcaption, footer, header, hgroup,
59
+ menu, nav, output, ruby, section, summary,
60
+ time, mark, audio, video {
61
+ font-family: {{bodyfont}}; }
62
+
63
+ code, pre, tt, kbd, samp {
64
+ font-family: {{monospacefont}};
65
+ font-variant-ligatures: none; }
66
+
67
+ code *, pre *, tt *, kbd *, samp * {
68
+ font-family: {{monospacefont}} !important;
69
+ font-variant-ligatures: none; }
70
+
71
+ article, aside, details, figcaption, figure,
72
+ footer, header, hgroup, menu, nav, section {
73
+ display: block; }
74
+
75
+ table {
76
+ border-collapse: collapse;
77
+ border-spacing: 0; }
78
+
79
+ h1, h2, h3, h4, h5, h6 {
80
+ font-family: {{headerfont}}; }
81
+
82
+ blockquote, q {
83
+ quotes: none; }
84
+ blockquote:before, blockquote:after, q:before, q:after {
85
+ content: '';
86
+ content: none; }
87
+
88
+ .h2Annex {
89
+ font-family: {{headerfont}}; }
90
+
91
+ dl {
92
+ display: grid;
93
+ grid-template-columns: max-content auto; }
94
+ dl dt p, dl dd p {
95
+ margin-top: 0; }
96
+ dl dt {
97
+ grid-column-start: 1; }
98
+ dl dd {
99
+ grid-column-start: 2; }
100
+
101
+ b, strong {
102
+ font-weight: bold; }
103
+
104
+ div.document-stage-band, div.document-type-band {
105
+ background-color: #333333; }
106
+
107
+ #standard-band {
108
+ background-color: #0AC442; }
109
+
110
+ #standard {
111
+ border-bottom: solid 3px #0AC442; }
112
+
113
+ #directive-band {
114
+ background-color: #540D6E; }
115
+
116
+ #directive {
117
+ border-bottom: solid 3px #540D6E; }
118
+
119
+ #guide-band {
120
+ background-color: #D183C9; }
121
+
122
+ #guide {
123
+ border-bottom: solid 3px #D183C9; }
124
+
125
+ #specification-band {
126
+ background-color: #65AFFF; }
127
+
128
+ #specification {
129
+ border-bottom: solid 3px #65AFFF; }
130
+
131
+ #report-band {
132
+ background-color: #3A405A; }
133
+
134
+ #report {
135
+ border-bottom: solid 3px #3A405A; }
136
+
137
+ #amendment-band {
138
+ background-color: #F26430; }
139
+
140
+ #amendment {
141
+ border-bottom: solid 3px #F26430; }
142
+
143
+ #corrigendum-band {
144
+ background-color: #C84630; }
145
+
146
+ #corrigendum {
147
+ border-bottom: solid 3px #C84630; }
148
+
149
+ #administrative-band {
150
+ background-color: #BFAE48; }
151
+
152
+ #administrative {
153
+ border-bottom: solid 3px #BFAE48; }
154
+
155
+ #advisory-band {
156
+ background-color: #BD9391; }
157
+
158
+ #advisory {
159
+ border-bottom: solid 3px #BD9391; }
160
+
161
+ #proposal-band {
162
+ background-color: #39A0ED; }
163
+
164
+ #proposal {
165
+ border-bottom: solid 3px #39A0ED; }
166
+
167
+ #working-draft-band {
168
+ background-color: #2D7393; }
169
+
170
+ #working-draft {
171
+ border-bottom: solid 3px #2D7393; }
172
+
173
+ #committee-draft-band {
174
+ background-color: #2A6B7C; }
175
+
176
+ #committee-draft {
177
+ border-bottom: solid 3px #2A6B7C; }
178
+
179
+ #draft-standard-band {
180
+ background-color: #1C7F7A; }
181
+
182
+ #draft-standard {
183
+ border-bottom: solid 3px #1C7F7A; }
184
+
185
+ #final-draft-band {
186
+ background-color: #53C170; }
187
+
188
+ #final-draft {
189
+ border-bottom: solid 3px #53C170; }
190
+
191
+ #published-band {
192
+ background-color: #069E2D; }
193
+
194
+ #published {
195
+ border-bottom: solid 3px #069E2D; }
196
+
197
+ #withdrawn-band {
198
+ background-color: #004E64; }
199
+
200
+ #withdrawn {
201
+ border-bottom: solid 3px #004E64; }
202
+
203
+ #cancelled-band {
204
+ background-color: #2E382E; }
205
+
206
+ #cancelled {
207
+ border-bottom: solid 3px #2E382E; }
File without changes
File without changes
File without changes
@@ -0,0 +1,34 @@
1
+ div.table_container {
2
+ margin-bottom: 14pt; }
3
+
4
+ ol {
5
+ margin-bottom: 0cm; }
6
+
7
+ ul {
8
+ margin-bottom: 0cm; }
9
+
10
+ table.MsoISOTable tr {
11
+ page-break-inside: avoid; }
12
+
13
+ td {
14
+ page-break-inside: avoid; }
15
+
16
+ tr {
17
+ page-break-after: avoid; }
18
+
19
+ span.stem {
20
+ font-family: "Cambria Math",serif;
21
+ mso-ascii-font-family: "Cambria Math";
22
+ font-style: italic; }
23
+
24
+ dt {
25
+ page-break-inside: avoid;
26
+ page-break-after: avoid; }
27
+
28
+ br.section {
29
+ page-break-before: always;
30
+ mso-break-type: section-break; }
31
+
32
+ br.pagebreak {
33
+ page-break-before: always;
34
+ mso-special-character: line-break; }
@@ -28,4 +28,3 @@ br.section
28
28
  br.pagebreak
29
29
  {page-break-before:always;
30
30
  mso-special-character:line-break;}
31
-
File without changes
@@ -0,0 +1,105 @@
1
+ html, body, div, span, applet, object, iframe,
2
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3
+ a, abbr, acronym, address, big, cite, code,
4
+ del, dfn, em, img, ins, kbd, q, s, samp,
5
+ small, strike, strong, sub, sup, tt, var,
6
+ b, u, i, center,
7
+ ol, ul, li,
8
+ fieldset, form, label, legend,
9
+ table, caption, tbody, tfoot, thead, tr, th, td,
10
+ article, aside, canvas, details, embed,
11
+ figure, figcaption, footer, header, hgroup,
12
+ menu, nav, output, ruby, section, summary,
13
+ time, mark, audio, video {
14
+ margin: 0;
15
+ padding: 0; }
16
+
17
+ html, body, div, span, applet, object, iframe,
18
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
19
+ a, abbr, acronym, address, big, cite, code,
20
+ del, dfn, em, img, ins, kbd, q, s, samp,
21
+ small, strike, strong, sub, sup, tt, var,
22
+ b, u, i, center,
23
+ dl, dt, dd, ol, ul, li,
24
+ fieldset, form, label, legend,
25
+ table, caption, tbody, tfoot, thead, tr, th, td,
26
+ article, aside, canvas, details, embed,
27
+ figure, figcaption, footer, header, hgroup,
28
+ menu, nav, output, ruby, section, summary,
29
+ time, mark, audio, video {
30
+ border: 0;
31
+ font-size: 100%; }
32
+
33
+ html, body, div, span, applet, object, iframe,
34
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
35
+ a, abbr, acronym, address, big, cite, code,
36
+ del, dfn, em, img, ins, kbd, q, s, samp,
37
+ small, strike, strong, tt, var,
38
+ b, u, i, center,
39
+ dl, dd, ol, ul, li,
40
+ fieldset, form, label, legend,
41
+ table, caption, tbody, tfoot, thead, tr, th, td,
42
+ article, aside, canvas, details, embed,
43
+ figure, figcaption, footer, header, hgroup,
44
+ menu, nav, output, ruby, section, summary,
45
+ time, mark, audio, video {
46
+ vertical-align: baseline; }
47
+
48
+ html, body, div, span, applet, object, iframe,
49
+ p, blockquote,
50
+ a, abbr, acronym, address, big, cite,
51
+ del, dfn, em, img, ins, q, s,
52
+ small, strike, strong, sub, sup, var,
53
+ b, u, i, center,
54
+ dl, dt, dd, ol, ul, li,
55
+ fieldset, form, label, legend,
56
+ table, caption, tbody, tfoot, thead, tr, th, td,
57
+ article, aside, canvas, details, embed,
58
+ figure, figcaption, footer, header, hgroup,
59
+ menu, nav, output, ruby, section, summary,
60
+ time, mark, audio, video {
61
+ font-family: {{bodyfont}}; }
62
+
63
+ code, pre, tt, kbd, samp {
64
+ font-family: {{monospacefont}};
65
+ font-variant-ligatures: none; }
66
+
67
+ code *, pre *, tt *, kbd *, samp * {
68
+ font-family: {{monospacefont}} !important;
69
+ font-variant-ligatures: none; }
70
+
71
+ article, aside, details, figcaption, figure,
72
+ footer, header, hgroup, menu, nav, section {
73
+ display: block; }
74
+
75
+ table {
76
+ border-collapse: collapse;
77
+ border-spacing: 0; }
78
+
79
+ h1, h2, h3, h4, h5, h6 {
80
+ font-family: {{headerfont}}; }
81
+
82
+ blockquote, q {
83
+ quotes: none; }
84
+ blockquote:before, blockquote:after, q:before, q:after {
85
+ content: '';
86
+ content: none; }
87
+
88
+ .h2Annex {
89
+ font-family: {{headerfont}}; }
90
+
91
+ dl {
92
+ display: grid;
93
+ grid-template-columns: max-content auto; }
94
+ dl dt p, dl dd p {
95
+ margin-top: 0; }
96
+ dl dt {
97
+ grid-column-start: 1; }
98
+ dl dd {
99
+ grid-column-start: 2; }
100
+
101
+ b, strong {
102
+ font-weight: bold; }
103
+
104
+ div.document-stage-band, div.document-type-band {
105
+ background-color: #333333; }
@@ -49,9 +49,9 @@ time, mark, audio, video {
49
49
  }
50
50
 
51
51
  html, body, div, span, applet, object, iframe,
52
- p, blockquote,
53
- a, abbr, acronym, address, big, cite,
54
- del, dfn, em, img, ins, q, s,
52
+ p, blockquote,
53
+ a, abbr, acronym, address, big, cite,
54
+ del, dfn, em, img, ins, q, s,
55
55
  small, strike, strong, sub, sup, var,
56
56
  b, u, i, center,
57
57
  dl, dt, dd, ol, ul, li,
File without changes
@@ -1,7 +1,8 @@
1
- require "isodoc/common"
2
- require "sassc"
3
- require "fileutils"
4
- require "tempfile"
1
+ # frozen_string_literal: true
2
+
3
+ require 'isodoc/common'
4
+ require 'fileutils'
5
+ require 'tempfile'
5
6
 
6
7
  module IsoDoc
7
8
  class Convert < ::IsoDoc::Common
@@ -27,15 +28,25 @@ module IsoDoc
27
28
  # scripts_pdf: Scripts file for PDF
28
29
  # datauriimage: Encode images in HTML output as data URIs
29
30
  def initialize(options)
30
- @libdir = File.dirname(__FILE__) unless @libdir
31
- options.merge!(default_fonts(options)) { |_, old, new| old || new }.
32
- merge!(default_file_locations(options)) { |_, old, new| old || new }
31
+ @libdir ||= File.dirname(__FILE__)
32
+ options.merge!(default_fonts(options)) do |_, old, new|
33
+ old || new
34
+ end
35
+ .merge!(default_file_locations(options)) do |_, old, new|
36
+ old || new
37
+ end
33
38
  @options = options
34
39
  @files_to_delete = []
35
40
  @tempfile_cache = []
36
- @htmlstylesheet_name = options[:htmlstylesheet]
37
- @wordstylesheet_name = options[:wordstylesheet]
38
- @standardstylesheet_name = options[:standardstylesheet]
41
+ @htmlstylesheet_name = precompiled_style_or_original(
42
+ options[:htmlstylesheet]
43
+ )
44
+ @wordstylesheet_name = precompiled_style_or_original(
45
+ options[:wordstylesheet]
46
+ )
47
+ @standardstylesheet_name = precompiled_style_or_original(
48
+ options[:standardstylesheet]
49
+ )
39
50
  @header = options[:header]
40
51
  @htmlcoverpage = options[:htmlcoverpage]
41
52
  @wordcoverpage = options[:wordcoverpage]
@@ -48,8 +59,8 @@ module IsoDoc
48
59
  @olstyle = options[:olstyle]
49
60
  @datauriimage = options[:datauriimage]
50
61
  @suppressheadingnumbers = options[:suppressheadingnumbers]
51
- @break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
52
- @termdomain = ""
62
+ @break_up_urls_in_tables = options[:break_up_urls_in_tables] == 'true'
63
+ @termdomain = ''
53
64
  @termexample = false
54
65
  @note = false
55
66
  @sourcecode = false
@@ -61,40 +72,57 @@ module IsoDoc
61
72
  @in_figure = false
62
73
  @seen_footnote = Set.new
63
74
  @c = HTMLEntities.new
64
- @openmathdelim = "`"
65
- @closemathdelim = "`"
66
- @lang = "en"
67
- @script = "Latn"
75
+ @openmathdelim = '`'
76
+ @closemathdelim = '`'
77
+ @lang = 'en'
78
+ @script = 'Latn'
68
79
  @maxwidth = 1200
69
80
  @maxheight = 800
70
81
  @wordToClevels = options[:doctoclevels].to_i
71
- @wordToClevels = 2 if @wordToClevels == 0
82
+ @wordToClevels = 2 if @wordToClevels.zero?
72
83
  @htmlToClevels = options[:htmltoclevels].to_i
73
- @htmlToClevels = 2 if @htmlToClevels == 0
74
- @bookmarks_allocated = {"X" => true}
84
+ @htmlToClevels = 2 if @htmlToClevels.zero?
85
+ @bookmarks_allocated = { 'X' => true }
75
86
  @fn_bookmarks = {}
76
87
  end
77
88
 
89
+ # Check if already compiled version(.css) exists,
90
+ # if not, return original scss file. During release
91
+ # we compile scss into css files in order to not depend on scss
92
+ def precompiled_style_or_original(stylesheet_path)
93
+ # Already have compiled stylesheet, use it
94
+ return stylesheet_path if stylesheet_path.nil? ||
95
+ File.extname(stylesheet_path) == '.css'
96
+
97
+ basename = File.basename(stylesheet_path, '.*')
98
+ compiled_path = File.join(File.dirname(stylesheet_path),
99
+ "#{basename}.css")
100
+ return stylesheet_path unless File.file?(compiled_path)
101
+
102
+ compiled_path
103
+ end
104
+
78
105
  # run this after @meta is populated
79
106
  def populate_css
80
- @htmlstylesheet = generate_css(@htmlstylesheet_name, true, extract_fonts(options))
81
- @wordstylesheet = generate_css(@wordstylesheet_name, false, extract_fonts(options))
82
- @standardstylesheet = generate_css(@standardstylesheet_name, false, extract_fonts(options))
107
+ @htmlstylesheet = generate_css(@htmlstylesheet_name, true)
108
+ @wordstylesheet = generate_css(@wordstylesheet_name, false)
109
+ @standardstylesheet = generate_css(@standardstylesheet_name, false)
83
110
  end
84
111
 
85
112
  def tmpimagedir_suffix
86
- "_images"
113
+ '_images'
87
114
  end
88
115
 
89
116
  def default_fonts(_options)
90
117
  {
91
- bodyfont: "Arial",
92
- headerfont: "Arial",
93
- monospacefont: "Courier",
118
+ bodyfont: 'Arial',
119
+ headerfont: 'Arial',
120
+ monospacefont: 'Courier'
94
121
  }
95
122
  end
96
123
 
97
- # none for this parent gem, but will be populated in child gems which have access to stylesheets &c; e.g.
124
+ # none for this parent gem, but will be populated in child
125
+ # gems which have access to stylesheets &c; e.g.
98
126
  # {
99
127
  # htmlstylesheet: html_doc_path("htmlstyle.scss"),
100
128
  # htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
@@ -112,30 +140,55 @@ module IsoDoc
112
140
  {}
113
141
  end
114
142
 
115
- # extract fonts for use in generate_css
116
- def extract_fonts(options)
117
- b = options[:bodyfont] || "Arial"
118
- h = options[:headerfont] || "Arial"
119
- m = options[:monospacefont] || "Courier"
143
+ def fonts_options
144
+ {
145
+ 'bodyfont' => options[:bodyfont] || 'Arial',
146
+ 'headerfont' => options[:headerfont] || 'Arial',
147
+ 'monospacefont' => options[:monospacefont] || 'Courier'
148
+ }
149
+ end
150
+
151
+ def scss_fontheader
152
+ b = options[:bodyfont] || 'Arial'
153
+ h = options[:headerfont] || 'Arial'
154
+ m = options[:monospacefont] || 'Courier'
120
155
  "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
121
156
  end
122
157
 
123
- def html_doc_path(file)
124
- File.join(@libdir, File.join("html", file))
158
+ def html_doc_path(*file)
159
+ file.each do |f|
160
+ ret = File.join(@libdir, File.join('html', f))
161
+ File.exist?(ret) and return ret
162
+ end
163
+ nil
164
+ end
165
+
166
+ def convert_scss(filename, stylesheet)
167
+ require 'sassc'
168
+ require 'isodoc/sassc_importer'
169
+
170
+ [File.join(Gem.loaded_specs['isodoc'].full_gem_path,
171
+ 'lib', 'isodoc'),
172
+ File.dirname(filename)].each do |name|
173
+ SassC.load_paths << name
174
+ end
175
+ SassC::Engine.new(scss_fontheader + stylesheet, syntax: :scss,
176
+ importer: SasscImporter)
177
+ .render
125
178
  end
126
179
 
127
- def generate_css(filename, stripwordcss, fontheader)
128
- return nil unless filename
129
- stylesheet = File.read(filename, encoding: "UTF-8")
180
+ def generate_css(filename, stripwordcss)
181
+ return nil if filename.nil?
182
+
183
+ stylesheet = File.read(filename, encoding: 'UTF-8')
130
184
  stylesheet = populate_template(stylesheet, :word)
131
- stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, "\\1") if stripwordcss
132
- SassC.load_paths << File.join(Gem.loaded_specs['isodoc'].full_gem_path,
133
- "lib", "isodoc")
134
- SassC.load_paths << File.dirname(filename)
135
- engine = SassC::Engine.new(fontheader + stylesheet, syntax: :scss)
136
- Tempfile.open([File.basename(filename, ".*"), "css"],
137
- :encoding => "utf-8") do |f|
138
- f.write(engine.render)
185
+ stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
186
+ if File.extname(filename) == '.scss'
187
+ stylesheet = convert_scss(filename, stylesheet)
188
+ end
189
+ Tempfile.open([File.basename(filename, '.*'), 'css'],
190
+ encoding: 'utf-8') do |f|
191
+ f.write(stylesheet)
139
192
  f
140
193
  end
141
194
  end
@@ -143,10 +196,10 @@ module IsoDoc
143
196
  def convert1(docxml, filename, dir)
144
197
  @xrefs.parse docxml
145
198
  noko do |xml|
146
- xml.html **{ lang: "#{@lang}" } do |html|
147
- html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
199
+ xml.html **{ lang: @lang.to_s } do |html|
200
+ html.parent.add_namespace('epub', 'http://www.idpf.org/2007/ops')
148
201
  info docxml, nil
149
- populate_css()
202
+ populate_css
150
203
  html.head { |head| define_head head, filename, dir }
151
204
  make_body(html, docxml)
152
205
  end
@@ -164,17 +217,21 @@ module IsoDoc
164
217
  def convert_init(file, input_filename, debug)
165
218
  docxml = Nokogiri::XML(file)
166
219
  filename, dir = init_file(input_filename, debug)
167
- docxml.root.default_namespace = ""
168
- lang = docxml&.at(ns("//bibdata/language"))&.text || @lang
169
- script = docxml&.at(ns("//bibdata/script"))&.text || @script
220
+ docxml.root.default_namespace = ''
221
+ lang = docxml&.at(ns('//bibdata/language'))&.text || @lang
222
+ script = docxml&.at(ns('//bibdata/script'))&.text || @script
170
223
  i18n_init(lang, script)
171
224
  metadata_init(lang, script, @labels)
225
+ @meta.fonts_options = fonts_options
172
226
  xref_init(lang, script, self, @labels, {})
173
227
  [docxml, filename, dir]
174
228
  end
175
229
 
176
- def convert(input_filename, file = nil, debug = false, output_filename = nil)
177
- file = File.read(input_filename, encoding: "utf-8") if file.nil?
230
+ def convert(input_filename,
231
+ file = nil,
232
+ debug = false,
233
+ output_filename = nil)
234
+ file = File.read(input_filename, encoding: 'utf-8') if file.nil?
178
235
  @openmathdelim, @closemathdelim = extract_delims(file)
179
236
  docxml, filename, dir = convert_init(file, input_filename, debug)
180
237
  result = convert1(docxml, filename, dir)
@@ -186,7 +243,7 @@ module IsoDoc
186
243
 
187
244
  def middle_clause
188
245
  "//clause[parent::sections][not(xmlns:title = 'Scope')]"\
189
- "[not(descendant::terms)]".freeze
246
+ '[not(descendant::terms)]'
190
247
  end
191
248
  end
192
249
  end