isodoc 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +69 -0
  3. data/README.adoc +1 -3
  4. data/isodoc.gemspec +3 -1
  5. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  6. data/lib/isodoc-yaml/i18n-fr.yaml +8 -7
  7. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  8. data/lib/isodoc/base_style/all.css +5 -1
  9. data/lib/isodoc/base_style/blocks.scss +2 -2
  10. data/lib/isodoc/base_style/reset.css +5 -1
  11. data/lib/isodoc/base_style/reset.scss +6 -1
  12. data/lib/isodoc/base_style/typography.scss +1 -1
  13. data/lib/isodoc/convert.rb +12 -97
  14. data/lib/isodoc/css.rb +95 -0
  15. data/lib/isodoc/function/inline.rb +0 -33
  16. data/lib/isodoc/function/lists.rb +2 -1
  17. data/lib/isodoc/function/references.rb +8 -13
  18. data/lib/isodoc/function/to_word_html.rb +2 -2
  19. data/lib/isodoc/html_function/postprocess.rb +12 -3
  20. data/lib/isodoc/i18n.rb +23 -51
  21. data/lib/isodoc/metadata.rb +44 -111
  22. data/lib/isodoc/metadata_contributor.rb +90 -0
  23. data/lib/isodoc/metadata_date.rb +11 -0
  24. data/lib/isodoc/presentation_function/bibdata.rb +96 -0
  25. data/lib/isodoc/presentation_function/block.rb +14 -9
  26. data/lib/isodoc/presentation_function/inline.rb +151 -34
  27. data/lib/isodoc/presentation_xml_convert.rb +6 -0
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_convert.rb +0 -20
  30. data/lib/isodoc/word_function/body.rb +12 -0
  31. data/lib/isodoc/word_function/postprocess.rb +1 -1
  32. data/lib/isodoc/xref/xref_anchor.rb +8 -3
  33. data/lib/isodoc/xref/xref_counter.rb +20 -9
  34. data/lib/isodoc/xref/xref_gen.rb +4 -4
  35. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  36. data/lib/isodoc/xslfo_convert.rb +6 -1
  37. data/spec/assets/html.scss +14 -0
  38. data/spec/assets/i18n.yaml +22 -5
  39. data/spec/isodoc/blocks_spec.rb +100 -221
  40. data/spec/isodoc/footnotes_spec.rb +4 -5
  41. data/spec/isodoc/i18n_spec.rb +89 -16
  42. data/spec/isodoc/inline_spec.rb +185 -163
  43. data/spec/isodoc/lists_spec.rb +1 -1
  44. data/spec/isodoc/metadata_spec.rb +69 -19
  45. data/spec/isodoc/postproc_spec.rb +33 -8
  46. data/spec/isodoc/presentation_xml_spec.rb +584 -1
  47. data/spec/isodoc/ref_spec.rb +328 -10
  48. data/spec/isodoc/section_spec.rb +9 -9
  49. data/spec/isodoc/table_spec.rb +1 -1
  50. data/spec/isodoc/terms_spec.rb +1 -1
  51. data/spec/isodoc/xref_spec.rb +35 -35
  52. data/spec/spec_helper.rb +6 -0
  53. metadata +36 -7
  54. data/.github/workflows/macos.yml +0 -42
  55. data/.github/workflows/ubuntu.yml +0 -62
  56. data/.github/workflows/windows.yml +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cd5c7cab435113879315a8de5d3219df7577d057df5adee3a87f7431b9d17f7
4
- data.tar.gz: 22f07d9de5b5b8a26c57ca5321a53fafd591e6703615921d9a79d939c0276295
3
+ metadata.gz: f1edc88536663d06a4d23249a6ec1909148185456f84a427fe2299da8e138ab4
4
+ data.tar.gz: fd6099657296706882b03eb557f59b242c733415b9d49fe8bf4e3aa73bd67eb8
5
5
  SHA512:
6
- metadata.gz: 1ca2bd4cf9b70ea4eb12d118c26e66e90340070453e132db89e7b6748a1a02f8a10f62c5944e2b1ffe6e18d4a69504b08f7b687ec6b8a573983f58d03de12b48
7
- data.tar.gz: 1b6702e74e5041ad95509cf1b8655e044f36f27a0fa3cbd12e6ac82684e6b535ed1c3ad9ea6ad938ab2cb42a3880f2e0153ddb0424bf322d4238806616582a54
6
+ metadata.gz: 4112c5b84d25a09e9d701b9735d80e01e9f4bf294288c097524c83e31689dc90c1dd9168e9f70061868d41c032d2b864a96b76b19f0926584a2549a1f5309a63
7
+ data.tar.gz: b002124056e50a37732ad78fa9e959658b0f07c9f5af9d248f69c0d282cc74804471124fc4b7f150ba19935e3aa904df0d54222fb201e279d6325ebfffe9def8
@@ -0,0 +1,69 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '2.7'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '2.7'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '2.7'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@master
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+
39
+ - uses: actions/cache@v2
40
+ with:
41
+ path: vendor/bundle
42
+ key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
43
+ restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
44
+
45
+ - run: bundle config set path 'vendor/bundle'
46
+
47
+ - run: bundle install --jobs 4 --retry 3
48
+
49
+ - name: Install Inkscape macOS
50
+ if: matrix.os == 'macos-latest'
51
+ run: |
52
+ brew cask install inkscape
53
+ inkscape --version
54
+
55
+ - name: Install Inkscape Ubuntu
56
+ if: matrix.os == 'ubuntu-latest'
57
+ run: |
58
+ sudo add-apt-repository ppa:inkscape.dev/stable
59
+ sudo apt update
60
+ sudo apt install inkscape
61
+ inkscape --version
62
+
63
+ - name: Install Inkscape Windows
64
+ if: matrix.os == 'windows-latest'
65
+ run: |
66
+ choco install --no-progress -y inkscape
67
+ inkscape --version
68
+
69
+ - run: bundle exec rake
@@ -1,9 +1,7 @@
1
1
  = isodoc: Processor to generate HTML/Word from Metanorma XML
2
2
 
3
3
  image:https://img.shields.io/gem/v/isodoc.svg["Gem Version", link="https://rubygems.org/gems/isodoc"]
4
- image:https://github.com/metanorma/isodoc/workflows/ubuntu/badge.svg["Ubuntu Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Aubuntu"]
5
- image:https://github.com/metanorma/isodoc/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Amacos"]
6
- image:https://github.com/metanorma/isodoc/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Awindows"]
4
+ image:https://github.com/metanorma/isodoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Arake"]
7
5
  image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/isodoc.svg["Pull Requests", link="https://github.com/metanorma/isodoc/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/isodoc/latest.svg["Commits since latest",link="https://github.com/metanorma/isodoc/releases"]
@@ -35,8 +35,10 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "uuidtools"
36
36
  spec.add_dependency "html2doc", "~> 1.0.0"
37
37
  spec.add_dependency "liquid"
38
+ spec.add_dependency "twitter_cldr"
38
39
  spec.add_dependency "roman-numerals"
39
- spec.add_dependency "metanorma", "~> 1.1.0"
40
+ spec.add_dependency "metanorma", "~> 1.2.0"
41
+ spec.add_dependency "relaton-cli"
40
42
 
41
43
  spec.add_development_dependency "rake", "~> 13.0"
42
44
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -36,6 +36,7 @@ external_terms_boilerplate: |
36
36
  internal_external_terms_boilerplate: |
37
37
  <p>For the purposes of this document, the terms and definitions
38
38
  given in % and the following apply.</p>
39
+ term_defined_in: "[term defined in %]"
39
40
  note: NOTE
40
41
  note_xref: Note
41
42
  termnote: Note % to entry
@@ -1,5 +1,5 @@
1
1
  term_def_boilerplate:
2
- scope: Domaine d'application
2
+ scope: Domaine dapplication
3
3
  symbolsabbrev: Symboles et termes abrégés
4
4
  abbrev: Termes abrégés
5
5
  symbols: Symboles
@@ -18,20 +18,21 @@ clause: Article
18
18
  annex: Annexe
19
19
  appendix: Appendice
20
20
  no_terms_boilerplate: |
21
- <p>Aucun terme n'est defini dans le présent document.</p>
21
+ <p>Aucun terme nest defini dans le présent document.</p>
22
22
  internal_terms_boilerplate: |
23
- <p>Pour les besoins du présent document, les termes et définitions suivants s'appliquent.</p>
23
+ <p>Pour les besoins du présent document, les termes et définitions suivants sappliquent.</p>
24
24
  norm_with_refs_pref:
25
- Les documents suivants cités dans le texte constituent, pour tout ou partie de leur contenu, des exigences du présent document. Pour les références datées, seule l’édition citée s'applique. Pour les références non datées, la dernière édition du document de référence s'applique (y compris les éventuels amendements).
25
+ Les documents suivants cités dans le texte constituent, pour tout ou partie de leur contenu, des exigences du présent document. Pour les références datées, seule l’édition citée sapplique. Pour les références non datées, la dernière édition du document de référence sapplique (y compris les éventuels amendements).
26
26
  norm_empty_pref:
27
27
  Le présent document ne contient aucune référence normative.
28
28
  external_terms_boilerplate: |
29
- <p>Pour les besoins du présent document, les termes et définitions de % s'appliquent.</p>
29
+ <p>Pour les besoins du présent document, les termes et définitions de % sappliquent.</p>
30
30
  internal_external_terms_boilerplate: |
31
- <p>Pour les besoins du présent document, les termes et définitions de % ainsi que les suivants, s'appliquent.</p>
31
+ <p>Pour les besoins du présent document, les termes et définitions de % ainsi que les suivants, sappliquent.</p>
32
+ term_defined_in: "[terme défini dans %]"
32
33
  note: NOTE
33
34
  note_xref: Note
34
- termnote: Note % à l'article
35
+ termnote: Note % à larticle
35
36
  figure: Figure
36
37
  formula: Formule
37
38
  inequality: Formule
@@ -31,6 +31,7 @@ external_terms_boilerplate: |
31
31
  <p>% 界定的术语和定义适用于本文件。</p>
32
32
  internal_external_terms_boilerplate: |
33
33
  <p>% 界定的以及下列术语和定义适用于本文件。</p>
34
+ term_defined_in: "〖术语于%中定义〗"
34
35
  note: 注
35
36
  note_xref: 注
36
37
  termnote: 注%
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0; }
@@ -104,6 +104,10 @@ b, strong {
104
104
  div.document-stage-band, div.document-type-band {
105
105
  background-color: #333333; }
106
106
 
107
+ a.FootnoteRef + a.FootnoteRef:before {
108
+ content: ", ";
109
+ vertical-align: super; }
110
+
107
111
  #standard-band {
108
112
  background-color: #0AC442; }
109
113
 
@@ -50,7 +50,7 @@
50
50
  }
51
51
 
52
52
  background-color: $colorBg;
53
- font-size: 0.8em;
53
+ font-size: $monospacefontsize;
54
54
  line-height: 1.6em;
55
55
  padding: 1.5em;
56
56
  margin: 2em 0 1em 0;
@@ -68,7 +68,7 @@
68
68
  }
69
69
 
70
70
  background-color: $colorBg;
71
- font-size: 0.8em;
71
+ font-size: $monospacefontsize;
72
72
  line-height: 1.6em;
73
73
  padding: 1.5em;
74
74
  margin: 2em 0 1em 0;
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0; }
@@ -103,3 +103,7 @@ b, strong {
103
103
 
104
104
  div.document-stage-band, div.document-type-band {
105
105
  background-color: #333333; }
106
+
107
+ a.FootnoteRef + a.FootnoteRef:before {
108
+ content: ", ";
109
+ vertical-align: super; }
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0;
@@ -127,3 +127,8 @@ b, strong {
127
127
  div.document-stage-band, div.document-type-band {
128
128
  background-color: #333333;
129
129
  }
130
+
131
+ a.FootnoteRef + a.FootnoteRef:before {
132
+ content: ", ";
133
+ vertical-align: super;
134
+ }
@@ -56,7 +56,7 @@
56
56
 
57
57
  &, th, td {
58
58
  border: $border;
59
- font-size: 0.95em;
59
+ font-size: 0.95em; // NN 20201115: ??? normalfontsize - 0.05?
60
60
  }
61
61
  th, td {
62
62
  padding: 1em;
@@ -3,6 +3,7 @@ require "isodoc/common"
3
3
  require "fileutils"
4
4
  require "tempfile"
5
5
  require_relative "i18n"
6
+ require_relative "css"
6
7
 
7
8
  module IsoDoc
8
9
  class Convert < ::IsoDoc::Common
@@ -17,6 +18,10 @@ module IsoDoc
17
18
  # wordcoverpage: Cover page for Word
18
19
  # htmlintropage: Introductory page for HTML
19
20
  # wordintropage: Introductory page for Word
21
+ # normalfontsize: Font size for body text
22
+ # smallerfontsize: Font size for smaller than body text
23
+ # monospacefontsize: Font size for monospace font
24
+ # footnotefontsize: Font size for footnotes
20
25
  # i18nyaml: YAML file for internationalisation of text
21
26
  # ulstyle: list style in Word CSS for unordered lists
22
27
  # olstyle: list style in Word CSS for ordered lists
@@ -25,8 +30,10 @@ module IsoDoc
25
30
  # monospace: font to use for monospace text
26
31
  # suppressheadingnumbers: suppress heading numbers for clauses
27
32
  # scripts: Scripts file for HTML
28
- # scripts_pdf: Scripts file for PDF
33
+ # scripts_pdf: Scripts file for PDF (not used in XSLT PDF)
29
34
  # datauriimage: Encode images in HTML output as data URIs
35
+ # break_up_urls_in_tables: whether to insert spaces in URLs in tables
36
+ # every 40-odd chars
30
37
  def initialize(options)
31
38
  @libdir ||= File.dirname(__FILE__)
32
39
  options.merge!(default_fonts(options)) do |_, old, new|
@@ -46,6 +53,10 @@ module IsoDoc
46
53
  @wordcoverpage = options[:wordcoverpage]
47
54
  @htmlintropage = options[:htmlintropage]
48
55
  @wordintropage = options[:wordintropage]
56
+ @normalfontsize = options[:normalfontsize]
57
+ @smallerfontsize = options[:smallerfontsize]
58
+ @monospacefontsize = options[:monospacefontsize]
59
+ @footnotefontsize = options[:footnotefontsize]
49
60
  @scripts = options[:scripts]
50
61
  @scripts_pdf = options[:scripts_pdf]
51
62
  @i18nyaml = options[:i18nyaml]
@@ -80,75 +91,10 @@ module IsoDoc
80
91
  @fn_bookmarks = {}
81
92
  end
82
93
 
83
- # Check if already compiled version(.css) exists,
84
- # if not, return original scss file. During release
85
- # we compile scss into css files in order to not depend on scss
86
- def precompiled_style_or_original(stylesheet_path)
87
- # Already have compiled stylesheet, use it
88
- return stylesheet_path if stylesheet_path.nil? ||
89
- File.extname(stylesheet_path) == '.css'
90
-
91
- basename = File.basename(stylesheet_path, '.*')
92
- compiled_path = File.join(File.dirname(stylesheet_path),
93
- "#{basename}.css")
94
- return stylesheet_path unless File.file?(compiled_path)
95
-
96
- compiled_path
97
- end
98
-
99
- # run this after @meta is populated
100
- def populate_css
101
- @htmlstylesheet = generate_css(@htmlstylesheet_name, true)
102
- @wordstylesheet = generate_css(@wordstylesheet_name, false)
103
- @standardstylesheet = generate_css(@standardstylesheet_name, false)
104
- end
105
-
106
94
  def tmpimagedir_suffix
107
95
  '_images'
108
96
  end
109
97
 
110
- def default_fonts(_options)
111
- {
112
- bodyfont: 'Arial',
113
- headerfont: 'Arial',
114
- monospacefont: 'Courier'
115
- }
116
- end
117
-
118
- # none for this parent gem, but will be populated in child gems
119
- # which have access to stylesheets &c; e.g.
120
- # {
121
- # htmlstylesheet: html_doc_path("htmlstyle.scss"),
122
- # htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
123
- # htmlintropage: html_doc_path("html_rsd_intro.html"),
124
- # scripts: html_doc_path("scripts.html"),
125
- # wordstylesheet: html_doc_path("wordstyle.scss"),
126
- # standardstylesheet: html_doc_path("rsd.scss"),
127
- # header: html_doc_path("header.html"),
128
- # wordcoverpage: html_doc_path("word_rsd_titlepage.html"),
129
- # wordintropage: html_doc_path("word_rsd_intro.html"),
130
- # ulstyle: l3
131
- # olstyle: l2
132
- # }
133
- def default_file_locations(_options)
134
- {}
135
- end
136
-
137
- def fonts_options
138
- {
139
- 'bodyfont' => options[:bodyfont] || 'Arial',
140
- 'headerfont' => options[:headerfont] || 'Arial',
141
- 'monospacefont' => options[:monospacefont] || 'Courier'
142
- }
143
- end
144
-
145
- def scss_fontheader
146
- b = options[:bodyfont] || 'Arial'
147
- h = options[:headerfont] || 'Arial'
148
- m = options[:monospacefont] || 'Courier'
149
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
150
- end
151
-
152
98
  def html_doc_path(*file)
153
99
  file.each do |f|
154
100
  ret = File.join(@libdir, File.join('html', f))
@@ -157,37 +103,6 @@ module IsoDoc
157
103
  nil
158
104
  end
159
105
 
160
- def convert_scss(filename, stylesheet)
161
- require 'sassc'
162
- require 'isodoc/sassc_importer'
163
-
164
- [File.join(Gem.loaded_specs['isodoc'].full_gem_path,
165
- 'lib', 'isodoc'),
166
- File.dirname(filename)].each do |name|
167
- SassC.load_paths << name
168
- end
169
- SassC::Engine.new(scss_fontheader + stylesheet, syntax: :scss,
170
- importer: SasscImporter)
171
- .render
172
- end
173
-
174
- def generate_css(filename, stripwordcss)
175
- return nil if filename.nil?
176
-
177
- filename = precompiled_style_or_original(filename)
178
- stylesheet = File.read(filename, encoding: 'UTF-8')
179
- stylesheet = populate_template(stylesheet, :word)
180
- stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
181
- if File.extname(filename) == '.scss'
182
- stylesheet = convert_scss(filename, stylesheet)
183
- end
184
- Tempfile.open([File.basename(filename, '.*'), 'css'],
185
- encoding: 'utf-8') do |f|
186
- f.write(stylesheet)
187
- f
188
- end
189
- end
190
-
191
106
  def convert1(docxml, filename, dir)
192
107
  @xrefs.parse docxml
193
108
  noko do |xml|
@@ -0,0 +1,95 @@
1
+ module IsoDoc
2
+ class Convert < ::IsoDoc::Common
3
+ # Check if already compiled version(.css) exists,
4
+ # if not, return original scss file. During release
5
+ # we compile scss into css files in order to not depend on scss
6
+ def precompiled_style_or_original(stylesheet_path)
7
+ # Already have compiled stylesheet, use it
8
+ return stylesheet_path if stylesheet_path.nil? ||
9
+ File.extname(stylesheet_path) == '.css'
10
+ basename = File.basename(stylesheet_path, '.*')
11
+ compiled_path = File.join(File.dirname(stylesheet_path),
12
+ "#{basename}.css")
13
+ return stylesheet_path unless File.file?(compiled_path)
14
+ compiled_path
15
+ end
16
+
17
+ # run this after @meta is populated
18
+ def populate_css
19
+ @htmlstylesheet = generate_css(@htmlstylesheet_name, true)
20
+ @wordstylesheet = generate_css(@wordstylesheet_name, false)
21
+ @standardstylesheet = generate_css(@standardstylesheet_name, false)
22
+ end
23
+
24
+ def default_fonts(_options)
25
+ {
26
+ bodyfont: 'Arial',
27
+ headerfont: 'Arial',
28
+ monospacefont: 'Courier',
29
+ }
30
+ end
31
+
32
+ # none for this parent gem, but will be populated in child gems
33
+ # which have access to stylesheets &c
34
+ def default_file_locations(_options)
35
+ {}
36
+ end
37
+
38
+ def fonts_options
39
+ {
40
+ 'bodyfont' => options[:bodyfont] || 'Arial',
41
+ 'headerfont' => options[:headerfont] || 'Arial',
42
+ 'monospacefont' => options[:monospacefont] || 'Courier',
43
+ "normalfontsize" => options[:normalfontsize],
44
+ "monospacefontsize" => options[:monospacefontsize],
45
+ "smallerfontsize" => options[:smallerfontsize],
46
+ "footnotefontsize" => options[:footnotefontsize]
47
+ }
48
+ end
49
+
50
+ def scss_fontheader(is_html_css)
51
+ b = options[:bodyfont] || 'Arial'
52
+ h = options[:headerfont] || 'Arial'
53
+ m = options[:monospacefont] || 'Courier'
54
+ ns = options[:normalfontsize] || (is_html_css ? "1.0em" : '12.0pt')
55
+ ms = options[:monospacefontsize] || (is_html_css ? "0.8em" : '11.0pt')
56
+ ss = options[:smallerfontsize] || (is_html_css ? "0.9em" : '10.0pt')
57
+ fs = options[:footnotefontsize] || (is_html_css ? "0.9em" : '9.0pt')
58
+ "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"\
59
+ "$normalfontsize: #{ns};\n$monospacefontsize: #{ms};\n"\
60
+ "$smallerfontsize: #{ss};\n$footnotefontsize: #{fs};\n"
61
+ end
62
+
63
+ def convert_scss(filename, stylesheet, stripwordcss)
64
+ require 'sassc'
65
+ require 'isodoc/sassc_importer'
66
+
67
+ [File.join(Gem.loaded_specs['isodoc'].full_gem_path,
68
+ 'lib', 'isodoc'),
69
+ File.dirname(filename)].each do |name|
70
+ SassC.load_paths << name
71
+ end
72
+ SassC::Engine.new(scss_fontheader(stripwordcss) + stylesheet,
73
+ syntax: :scss, importer: SasscImporter)
74
+ .render
75
+ end
76
+
77
+ # stripwordcss if HTML stylesheet, !stripwordcss if DOC stylesheet
78
+ def generate_css(filename, stripwordcss)
79
+ return nil if filename.nil?
80
+
81
+ filename = precompiled_style_or_original(filename)
82
+ stylesheet = File.read(filename, encoding: 'UTF-8')
83
+ stylesheet = populate_template(stylesheet, :word)
84
+ stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
85
+ if File.extname(filename) == '.scss'
86
+ stylesheet = convert_scss(filename, stylesheet, stripwordcss)
87
+ end
88
+ Tempfile.open([File.basename(filename, '.*'), 'css'],
89
+ encoding: 'utf-8') do |f|
90
+ f.write(stylesheet)
91
+ f
92
+ end
93
+ end
94
+ end
95
+ end