isodoc 0.8.7 → 0.8.8

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: f01104dabca281577926307a587e9999a2731d2d297550f1bab164e06b3edccf
4
- data.tar.gz: 64cdd14aff259cf0146693a10a012e02857534a2f7a45b3051b42f8af972df85
3
+ metadata.gz: 175371d554a61e1c0a3c2c7c2b3d549b632278d5cd7cc440dd60f2f6f8460757
4
+ data.tar.gz: e94494f0e00b97dc7f23154b47c331b08d3b5c53d3f2ac1846b5a7b1cf6b6ff3
5
5
  SHA512:
6
- metadata.gz: ef626e3f0b6842329ff5ca7ab9b91508c6578898735b3712b1e7b4e1943d3bf7f0775fa6430b8946f4d192343ce2d436bc7144bfb0150e3c68a5b3eada530b73
7
- data.tar.gz: 51a3531c9264f52b4da6fdd1e63f40f0429c04ebf265ce84968be93a642e592bad9f2a6d963a252de91c1b2b2538759311413dea403698f53dbfbad70717008a
6
+ metadata.gz: ebf2dd5678bbd1b727fd1c70a41047c19bfc462fd38614508e5b234618a4c505413a6fb616adc0ced45db6328a01363467c00b20a4ee8f7ee9f096dea2f4b578
7
+ data.tar.gz: dcfcd9e5dec8df4179cba4dbfca9d41f0749060e739f894919e9650ad57d0bed0f31ab0ef3cc8847f4fe2365829171207cac42954e1fc579cf57427bc6eddedb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isodoc (0.8.7)
4
+ isodoc (0.8.8)
5
5
  asciimath
6
6
  html2doc (~> 0.8.1)
7
7
  htmlentities (~> 4.3.4)
data/README.adoc CHANGED
@@ -10,7 +10,7 @@ This Gem converts documents in the https://github.com/riboseinc/isodoc-models[IS
10
10
 
11
11
  == Usage
12
12
 
13
- The Gem contains two classes, `IsoDoc::Convert` (for HTML output) and `IsoDoc::WordConvert` (for Word output). They are initialised with the following rendering parameters:
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
15
  i18nyaml:: YAML file giving internationalisation equivalents for keywords in rendering output; see https://github.com/riboseinc/asciidoctor-iso#document-attributes for further documentation
16
16
  bodyfont:: Font for body text
@@ -19,6 +19,18 @@ monospacefont:: Font for monospace text
19
19
  titlefont:: Font for document title text (currently used only in GB)
20
20
  script:: The ISO 15924 code for the main script that the standard document is in; used to pick the default fonts for the document
21
21
  alt:: Generate alternate rendering (currently used only in ISO)
22
+ compliance:: Generate alternate rendering (currently used only in GB)
23
+ htmlstylesheet:: Stylesheet for HTML output
24
+ htmlcoverpage:: Cover page for HTML output
25
+ htmlintropage:: Introductory page for HTML output
26
+ scripts:: Scripts page for HTML output
27
+ wordstylesheet:: Stylesheet for Word output
28
+ standardstylesheet:: Secondary stylesheet for Word output
29
+ header:: Header file for Word output
30
+ wordcoverpage:: Cover page for Word output
31
+ wordintropage:: Introductory page for Word output
32
+ ulstyle:: Style identifier in Word stylesheet for unordered lists
33
+ olstyle:: Style identifier in Word stylesheet for ordered list
22
34
 
23
35
  The IsoDoc gem classes themselves are abstract (though their current implementation contains rendering specific to the ISO standard.) Subclasses of the Isodoc gem classes are specific to different standards, and are associated with templates and stylesheets speciific to the rendering of those standards. Subclasses also provide the default values for the rendering parameters above; they should be used only as overrides.
24
36
 
@@ -16,11 +16,18 @@ module IsoDoc
16
16
  # i18nyaml: YAML file for internationalisation of text
17
17
  # ulstyle: list style in Word CSS for unordered lists
18
18
  # olstyle: list style in Word CSS for ordered lists
19
+ # bodyfont: font to use for body text
20
+ # headerfont: font to use for header text
21
+ # monospace: font to use for monospace text
19
22
  def initialize(options)
23
+ @libdir = File.dirname(__FILE__) unless @libdir
24
+ options.merge!(default_fonts(options)) { |_, old, new| old || new }.
25
+ merge!(default_file_locations(options)) { |_, old, new| old || new }
20
26
  @options = options
21
- @htmlstylesheet = options[:htmlstylesheet]
22
- @wordstylesheet = options[:wordstylesheet]
23
- @standardstylesheet = options[:standardstylesheet]
27
+ @files_to_delete = []
28
+ @htmlstylesheet = generate_css(options[:htmlstylesheet], true, extract_fonts(options))
29
+ @wordstylesheet = generate_css(options[:wordstylesheet], false, extract_fonts(options))
30
+ @standardstylesheet = generate_css(options[:standardstylesheet], false, extract_fonts(options))
24
31
  @header = options[:header]
25
32
  @htmlcoverpage = options[:htmlcoverpage]
26
33
  @wordcoverpage = options[:wordcoverpage]
@@ -47,17 +54,51 @@ module IsoDoc
47
54
  @closemathdelim = "`"
48
55
  @lang = "en"
49
56
  @script = "Latn"
50
- @files_to_delete = []
51
57
  @tmpimagedir = "_images"
52
58
  @maxwidth = 1200
53
59
  @maxheight = 800
54
60
  end
55
61
 
62
+ def default_fonts(_options)
63
+ {
64
+ bodyfont: "Arial",
65
+ headerfont: "Arial",
66
+ monospacefont: "Courier",
67
+ }
68
+ end
69
+
70
+ # none for this parent gem, but will be populated in child gems which have access to stylesheets &c; e.g.
71
+ # {
72
+ # htmlstylesheet: html_doc_path("htmlstyle.scss"),
73
+ # htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
74
+ # htmlintropage: html_doc_path("html_rsd_intro.html"),
75
+ # scripts: html_doc_path("scripts.html"),
76
+ # wordstylesheet: html_doc_path("wordstyle.scss"),
77
+ # standardstylesheet: html_doc_path("rsd.scss"),
78
+ # header: html_doc_path("header.html"),
79
+ # wordcoverpage: html_doc_path("word_rsd_titlepage.html"),
80
+ # wordintropage: html_doc_path("word_rsd_intro.html"),
81
+ # ulstyle: l3
82
+ # olstyle: l2
83
+ # }
84
+ def default_file_locations(_options)
85
+ {}
86
+ end
87
+
88
+ # extract fonts for use in generate_css
89
+ def extract_fonts(options)
90
+ b = options[:bodyfont] || "Arial"
91
+ h = options[:headerfont] || "Arial"
92
+ m = options[:monospacefont] || "Courier"
93
+ "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
94
+ end
95
+
56
96
  def html_doc_path(file)
57
- File.join(File.dirname(__FILE__), File.join("html", file))
97
+ File.join(@libdir, File.join("html", file))
58
98
  end
59
99
 
60
100
  def generate_css(filename, stripwordcss, fontheader)
101
+ return nil unless filename
61
102
  stylesheet = File.read(filename, encoding: "UTF-8")
62
103
  stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, "\\1") if stripwordcss
63
104
  engine = Sass::Engine.new(fontheader + stylesheet, syntax: :scss)
@@ -140,6 +140,7 @@ module IsoDoc::HtmlFunction
140
140
  end
141
141
 
142
142
  def htmlstyle(docxml)
143
+ return docxml unless @htmlstylesheet
143
144
  title = docxml.at("//*[local-name() = 'head']/*[local-name() = 'title']")
144
145
  head = docxml.at("//*[local-name() = 'head']")
145
146
  css = htmlstylesheet
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "0.8.7".freeze
2
+ VERSION = "0.8.8".freeze
3
3
  end
@@ -24,7 +24,7 @@ RSpec.describe IsoDoc do
24
24
  it "generates HTML output docs with null configuration" do
25
25
  system "rm -f test.doc"
26
26
  system "rm -f test.html"
27
- IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
27
+ IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css"}).convert("test", <<~"INPUT", false)
28
28
  <iso-standard xmlns="http://riboseinc.com/isoxml">
29
29
  <preface><foreword>
30
30
  <note>
@@ -35,8 +35,8 @@ RSpec.describe IsoDoc do
35
35
  INPUT
36
36
  expect(File.exist?("test.html")).to be true
37
37
  html = File.read("test.html")
38
- expect(html).to match(%r{<title>test</title><style>})
39
- expect(html).to match(/another empty stylesheet/)
38
+ expect(html).not_to match(%r{<title>test</title><style>})
39
+ expect(html).not_to match(/another empty stylesheet/)
40
40
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/2\.7\.1/MathJax\.js})
41
41
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
42
42
  end
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.8.7
4
+ version: 0.8.8
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-08-08 00:00:00.000000000 Z
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath