metanorma-acme 0.3.3 → 0.3.6

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: f439036427eeadbfc4bf41f65e4c4d8e655fc754708a3f05e8e55a7fd38f576f
4
- data.tar.gz: 066e2fa159203120aa60a98d774e9ce83ab2e4775354b0f6699d9c3d0e779bd2
3
+ metadata.gz: 50076c0a8cec8d60eaec16b8844110b892a462ad28485e4e56b73202da4e8af4
4
+ data.tar.gz: 72134238abb869d305b46246de35bb0523de8753ad717e2ab1bc472f49ac7a65
5
5
  SHA512:
6
- metadata.gz: f714a3a4da7da69ecd037fafb25666dd54d76e945b9813d1f2f1deaed0e44d6329e4f58daf0f7307352a8e643d246e4c086bf72136151e00ed9276a7f600b23b
7
- data.tar.gz: 478b6069bba6f07a30b25760bb67c5b4b9264a393b19d427dba30d6803156159e807feed15f0d96814a9365e1dab3154201132093db0d49452697565203e67f1
6
+ metadata.gz: aa00611552960fa5afeb6a99af13792df6fa25238f47aba6a899d7efca11991e03188c6281b376e1367f10252ac24233be09656be7c96fbe6e00faa8b7c372cb
7
+ data.tar.gz: 872af1e115d6316d43477e78e142493b6a58c38d2be7fdd6265e2909540ddc66c1664ccd292a5d1884fd8e6c1404ca44a31d75a3809078d0513478b6c0f0b456
data/.travis.yml CHANGED
@@ -4,6 +4,7 @@ language: ruby
4
4
  rvm:
5
5
  - 2.5
6
6
  - 2.4
7
+ - 2.3
7
8
  - ruby-head
8
9
  before_install:
9
10
  - gem install bundler
data/Gemfile CHANGED
@@ -1,8 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
  git_source(:github) {|repo| "https://github.com/#{repo}" }
3
3
 
4
- gem "isodoc", github: "riboseinc/isodoc"
5
- gem "asciidoctor-iso", github: "riboseinc/asciidoctor-iso"
6
- gem "html2doc", github: "riboseinc/html2doc"
7
-
8
4
  gemspec
data/README.adoc CHANGED
@@ -1,13 +1,43 @@
1
1
  = metanorma-acme: Sample Asciidoctor processor for Metanorma documents
2
2
 
3
- ////
4
3
  image:https://img.shields.io/gem/v/metanorma-acme.svg["Gem Version", link="https://rubygems.org/gems/metanorma-acme"]
5
4
  image:https://img.shields.io/travis/riboseinc/metanorma-acme/master.svg["Build Status", link="https://travis-ci.org/riboseinc/metanorma-acme"]
6
5
  image:https://codeclimate.com/github/riboseinc/metanorma-acme/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/metanorma-acme"]
7
- ////
8
6
 
9
7
  == Functionality
10
8
 
11
9
  This is an example of a https://github.com/riboseinc/metanorma[Metanorma] gem for processing input formats (Asciidoctor) and generating output formats (Word, HTML, PDF).
12
- It has been created as an exemplar for generating new instances of Metanorma gems, as illustrated in https://github.com/riboseinc/asciidoctor-iso/wiki/Gem-Customisation-Guide
10
+ It has been created as an exemplar for generating new instances of Metanorma gems, as illustrated in https://github.com/riboseinc/metanorma-iso/wiki/Gem-Customisation-Guide
13
11
 
12
+ You can customise output of this gem for your own purposes without needing to customise the gem fully. You can use the
13
+ following asciidoctor document variables to set the stylesheets that are passed as arguments to the `isodoc` gem:
14
+
15
+ ````
16
+ :body-font: (name of the main font to be used)
17
+ :header-font: (name of the header font to be used)
18
+ :monospace-font: (name of the monospace font to be used)
19
+ :htmlstylesheet: (stylesheet for HTML)
20
+ :htmlcoverpage: (cover page for HTML)
21
+ :htmlintropage: (intro page for HTML)
22
+ :scripts: (scripts for HTML)
23
+ :wordstylesheet: (default stylesheet for Word)
24
+ :standardstylesheet: (standard-specific stylesheet for Word)
25
+ :header: (header/footer HTML for Word)
26
+ :wordcoverpage: (cover page for Word)
27
+ :wordintropage: (intro page for Word)
28
+ :ulstyle: (list style selector for unordered lists for Word)
29
+ :olstyle: (list style selector for ordered lists for Word)
30
+ ````
31
+
32
+ You should run the gem through the https://github.com/riboseinc/metanorma-cli[Metanorma CLI]:
33
+
34
+ [source, console]
35
+ ----
36
+ metanorma -r metanorma-acme -t acme test.adoc
37
+ ----
38
+
39
+ The CSS stylesheets are normally expected to be https://sass-lang.com/guide[SCSS], with the font names `$body-font, $header-font, $monospace-font` used as variables; but if you supply the stylesheets, you can bypass that customisation, and give the font names in the stylesheets.
40
+
41
+ The cover page and intro page are still expected to be http://liquidmarkup.org[Liquid Template] files, giving metadata fields from `isodoc/metadata.rb` in curly brackets. See https://github.com/riboseinc/isodoc/blob/master/lib/isodoc/metadata.rb for the default metadata field settings.
42
+
43
+ The use of HTML and CSS for Word is idiosyncratic, and involves some trial and error; consult the documentation above for more information.
@@ -1,5 +1,5 @@
1
1
  require "asciidoctor"
2
- require "asciidoctor/iso/converter"
2
+ require "asciidoctor/standoc/converter"
3
3
 
4
4
  module Asciidoctor
5
5
  module Acme
@@ -7,7 +7,7 @@ module Asciidoctor
7
7
  # A {Converter} implementation that generates RSD output, and a document
8
8
  # schema encapsulation of the document for validation
9
9
  #
10
- class Converter < ISO::Converter
10
+ class Converter < Standoc::Converter
11
11
 
12
12
  register_for "acme"
13
13
 
@@ -154,27 +154,11 @@ module Asciidoctor
154
154
  end
155
155
 
156
156
  def html_converter(node)
157
- IsoDoc::Acme::HtmlConvert.new(
158
- script: node.attr("script"),
159
- bodyfont: node.attr("body-font"),
160
- headerfont: node.attr("header-font"),
161
- monospacefont: node.attr("monospace-font"),
162
- titlefont: node.attr("title-font"),
163
- i18nyaml: node.attr("i18nyaml"),
164
- scope: node.attr("scope"),
165
- )
157
+ IsoDoc::Acme::HtmlConvert.new(html_extract_attributes(node))
166
158
  end
167
159
 
168
160
  def word_converter(node)
169
- IsoDoc::Acme::WordConvert.new(
170
- script: node.attr("script"),
171
- bodyfont: node.attr("body-font"),
172
- headerfont: node.attr("header-font"),
173
- monospacefont: node.attr("monospace-font"),
174
- titlefont: node.attr("title-font"),
175
- i18nyaml: node.attr("i18nyaml"),
176
- scope: node.attr("scope"),
177
- )
161
+ IsoDoc::Acme::WordConvert.new(doc_extract_attributes(node))
178
162
  end
179
163
 
180
164
  def inline_quoted(node)
@@ -1,5 +1,6 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
+ require "fileutils"
3
4
 
4
5
  module IsoDoc
5
6
  module Acme
@@ -8,37 +9,37 @@ module IsoDoc
8
9
  # schema encapsulation of the document for validation
9
10
  #
10
11
  class HtmlConvert < IsoDoc::HtmlConvert
11
- def html_path_acme(file)
12
- File.join(File.dirname(__FILE__), File.join("html", file))
13
- end
14
-
15
12
  def initialize(options)
13
+ @libdir = File.dirname(__FILE__)
16
14
  super
17
- @htmlstylesheet = generate_css(html_path_acme("htmlstyle.scss"), true, default_fonts(options))
18
- @htmlcoverpage = html_path_acme("html_acme_titlepage.html")
19
- @htmlintropage = html_path_acme("html_acme_intro.html")
20
- @scripts = html_path_acme("scripts.html")
21
- system "cp #{html_path_acme('logo.jpg')} logo.jpg"
15
+ #system "cp #{html_doc_path('logo.jpg')} logo.jpg"
16
+ FileUtils.cp html_doc_path('logo.jpg'), "logo.jpg"
22
17
  @files_to_delete << "logo.jpg"
23
18
  end
24
19
 
25
20
  def default_fonts(options)
26
- b = options[:bodyfont] ||
27
- (options[:script] == "Hans" ? '"SimSun",serif' :
28
- '"Overpass",sans-serif')
29
- h = options[:headerfont] ||
30
- (options[:script] == "Hans" ? '"SimHei",sans-serif' :
31
- '"Overpass",sans-serif')
32
- m = options[:monospacefont] || '"Space Mono",monospace'
33
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
21
+ {
22
+ bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
23
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
24
+ monospacefont: '"Space Mono",monospace'
25
+ }
34
26
  end
35
27
 
36
- def metadata_init(lang, script, labels)
37
- @meta = Metadata.new(lang, script, labels)
28
+ def default_file_locations(_options)
29
+ {
30
+ htmlstylesheet: html_doc_path("htmlstyle.scss"),
31
+ htmlcoverpage: html_doc_path("html_acme_titlepage.html"),
32
+ htmlintropage: html_doc_path("html_acme_intro.html"),
33
+ scripts: html_doc_path("scripts.html"),
34
+ }
38
35
  end
39
36
 
40
- def html_head
41
- <<~HEAD.freeze
37
+ def metadata_init(lang, script, labels)
38
+ @meta = Metadata.new(lang, script, labels)
39
+ end
40
+
41
+ def html_head
42
+ <<~HEAD.freeze
42
43
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
43
44
 
44
45
  <!--TOC script import-->
@@ -51,148 +52,148 @@ module IsoDoc
51
52
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
52
53
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
53
54
  <style class="anchorjs"></style>
54
- HEAD
55
- end
56
-
57
- def make_body(xml, docxml)
58
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
59
- xml.body **body_attr do |body|
60
- make_body1(body, docxml)
61
- make_body2(body, docxml)
62
- make_body3(body, docxml)
55
+ HEAD
63
56
  end
64
- end
65
57
 
66
- def html_toc(docxml)
67
- docxml
68
- end
58
+ def make_body(xml, docxml)
59
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
60
+ xml.body **body_attr do |body|
61
+ make_body1(body, docxml)
62
+ make_body2(body, docxml)
63
+ make_body3(body, docxml)
64
+ end
65
+ end
69
66
 
70
- def annex_name(annex, name, div)
71
- div.h1 **{ class: "Annex" } do |t|
72
- t << "#{get_anchors[annex['id']][:label]} "
73
- t << "<b>#{name.text}</b>"
67
+ def html_toc(docxml)
68
+ docxml
74
69
  end
75
- end
76
70
 
77
- def annex_name_lbl(clause, num)
78
- obl = l10n("(#{@inform_annex_lbl})")
79
- obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
80
- l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
81
- end
71
+ def annex_name(annex, name, div)
72
+ div.h1 **{ class: "Annex" } do |t|
73
+ t << "#{get_anchors[annex['id']][:label]} "
74
+ t << "<b>#{name.text}</b>"
75
+ end
76
+ end
82
77
 
83
- def pre_parse(node, out)
84
- out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
85
- end
78
+ def annex_name_lbl(clause, num)
79
+ obl = l10n("(#{@inform_annex_lbl})")
80
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
81
+ l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
82
+ end
86
83
 
87
- def term_defs_boilerplate(div, source, term, preface)
88
- if source.empty? && term.nil?
89
- div << @no_terms_boilerplate
90
- else
91
- div << term_defs_boilerplate_cont(source, term)
84
+ def pre_parse(node, out)
85
+ out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
92
86
  end
93
- end
94
87
 
95
- def i18n_init(lang, script)
96
- super
97
- @annex_lbl = "Appendix"
98
- end
88
+ def term_defs_boilerplate(div, source, term, preface)
89
+ if source.empty? && term.nil?
90
+ div << @no_terms_boilerplate
91
+ else
92
+ div << term_defs_boilerplate_cont(source, term)
93
+ end
94
+ end
99
95
 
100
- def error_parse(node, out)
101
- # catch elements not defined in ISO
102
- case node.name
103
- when "pre"
104
- pre_parse(node, out)
105
- when "keyword"
106
- out.span node.text, **{ class: "keyword" }
107
- else
96
+ def i18n_init(lang, script)
108
97
  super
98
+ @annex_lbl = "Appendix"
109
99
  end
110
- end
111
100
 
112
- def fileloc(loc)
113
- File.join(File.dirname(__FILE__), loc)
114
- end
101
+ def error_parse(node, out)
102
+ # catch elements not defined in ISO
103
+ case node.name
104
+ when "pre"
105
+ pre_parse(node, out)
106
+ when "keyword"
107
+ out.span node.text, **{ class: "keyword" }
108
+ else
109
+ super
110
+ end
111
+ end
115
112
 
116
- def cleanup(docxml)
117
- super
118
- term_cleanup(docxml)
119
- end
113
+ def fileloc(loc)
114
+ File.join(File.dirname(__FILE__), loc)
115
+ end
120
116
 
121
- def term_cleanup(docxml)
122
- docxml.xpath("//p[@class = 'Terms']").each do |d|
123
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
124
- h2.add_child("&nbsp;")
125
- h2.add_child(d.remove)
117
+ def cleanup(docxml)
118
+ super
119
+ term_cleanup(docxml)
126
120
  end
127
- docxml
128
- end
129
121
 
130
- def info(isoxml, out)
131
- @meta.security isoxml, out
132
- super
133
- end
122
+ def term_cleanup(docxml)
123
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
124
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
125
+ h2.add_child("&nbsp;")
126
+ h2.add_child(d.remove)
127
+ end
128
+ docxml
129
+ end
134
130
 
135
- def annex_name(annex, name, div)
136
- div.h1 **{ class: "Annex" } do |t|
137
- t << "#{get_anchors[annex['id']][:label]} "
138
- t << "<b>#{name.text}</b>"
131
+ def info(isoxml, out)
132
+ @meta.security isoxml, out
133
+ super
139
134
  end
140
- end
141
135
 
142
- def annex_name_lbl(clause, num)
143
- obl = l10n("(#{@inform_annex_lbl})")
144
- obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
145
- l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
146
- end
136
+ def annex_name(annex, name, div)
137
+ div.h1 **{ class: "Annex" } do |t|
138
+ t << "#{get_anchors[annex['id']][:label]} "
139
+ t << "<b>#{name.text}</b>"
140
+ end
141
+ end
147
142
 
148
- def pre_parse(node, out)
149
- out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
150
- end
143
+ def annex_name_lbl(clause, num)
144
+ obl = l10n("(#{@inform_annex_lbl})")
145
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
146
+ l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
147
+ end
151
148
 
152
- def term_defs_boilerplate(div, source, term, preface)
153
- if source.empty? && term.nil?
154
- div << @no_terms_boilerplate
155
- else
156
- div << term_defs_boilerplate_cont(source, term)
149
+ def pre_parse(node, out)
150
+ out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
157
151
  end
158
- end
159
152
 
160
- def i18n_init(lang, script)
161
- super
162
- @annex_lbl = "Appendix"
163
- end
153
+ def term_defs_boilerplate(div, source, term, preface)
154
+ if source.empty? && term.nil?
155
+ div << @no_terms_boilerplate
156
+ else
157
+ div << term_defs_boilerplate_cont(source, term)
158
+ end
159
+ end
164
160
 
165
- def error_parse(node, out)
166
- # catch elements not defined in ISO
167
- case node.name
168
- when "pre"
169
- pre_parse(node, out)
170
- when "keyword"
171
- out.span node.text, **{ class: "keyword" }
172
- else
161
+ def i18n_init(lang, script)
173
162
  super
163
+ @annex_lbl = "Appendix"
174
164
  end
175
- end
176
165
 
177
- def fileloc(loc)
178
- File.join(File.dirname(__FILE__), loc)
179
- end
166
+ def error_parse(node, out)
167
+ # catch elements not defined in ISO
168
+ case node.name
169
+ when "pre"
170
+ pre_parse(node, out)
171
+ when "keyword"
172
+ out.span node.text, **{ class: "keyword" }
173
+ else
174
+ super
175
+ end
176
+ end
180
177
 
181
- def cleanup(docxml)
182
- super
183
- term_cleanup(docxml)
184
- end
178
+ def fileloc(loc)
179
+ File.join(File.dirname(__FILE__), loc)
180
+ end
185
181
 
186
- def term_cleanup(docxml)
187
- docxml.xpath("//p[@class = 'Terms']").each do |d|
188
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
189
- h2.add_child("&nbsp;")
190
- h2.add_child(d.remove)
182
+ def cleanup(docxml)
183
+ super
184
+ term_cleanup(docxml)
191
185
  end
192
- docxml
193
- end
194
186
 
187
+ def term_cleanup(docxml)
188
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
189
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
190
+ h2.add_child("&nbsp;")
191
+ h2.add_child(d.remove)
192
+ end
193
+ docxml
194
+ end
195
+
196
+ end
195
197
  end
196
198
  end
197
- end
198
199
 
@@ -1,34 +1,35 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
+ require "fileutils"
3
4
 
4
5
  module IsoDoc
5
6
  module Acme
6
7
  # A {Converter} implementation that generates PDF HTML output, and a
7
8
  # document schema encapsulation of the document for validation
8
9
  class PdfConvert < IsoDoc::PdfConvert
9
- def html_path_acme(file)
10
- File.join(File.dirname(__FILE__), File.join("html", file))
11
- end
12
-
13
10
  def initialize(options)
11
+ @libdir = File.dirname(__FILE__)
14
12
  super
15
- @htmlstylesheet = generate_css(html_path_acme("htmlstyle.scss"), true, default_fonts(options))
16
- @htmlcoverpage = html_path_acme("html_acme_titlepage.html")
17
- @htmlintropage = html_path_acme("html_acme_intro.html")
18
- @scripts = html_path_acme("scripts.html")
19
- system "cp #{html_path_acme('logo.jpg')} logo.jpg"
13
+ #system "cp #{html_doc_path('logo.jpg')} logo.jpg"
14
+ FileUtils.cp html_doc_path('logo.jpg'), "logo.jpg"
20
15
  @files_to_delete << "logo.jpg"
21
16
  end
22
17
 
23
18
  def default_fonts(options)
24
- b = options[:bodyfont] ||
25
- (options[:script] == "Hans" ? '"SimSun",serif' :
26
- '"Overpass",sans-serif')
27
- h = options[:headerfont] ||
28
- (options[:script] == "Hans" ? '"SimHei",sans-serif' :
29
- '"Overpass",sans-serif')
30
- m = options[:monospacefont] || '"Space Mono",monospace'
31
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
19
+ {
20
+ bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
21
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
22
+ monospacefont: '"Space Mono",monospace'
23
+ }
24
+ end
25
+
26
+ def default_file_locations(_options)
27
+ {
28
+ htmlstylesheet: html_doc_path("htmlstyle.scss"),
29
+ htmlcoverpage: html_doc_path("html_acme_titlepage.html"),
30
+ htmlintropage: html_doc_path("html_acme_intro.html"),
31
+ scripts: html_doc_path("scripts.html"),
32
+ }
32
33
  end
33
34
 
34
35
  def metadata_init(lang, script, labels)
@@ -1,5 +1,6 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
+ require "fileutils"
3
4
 
4
5
  module IsoDoc
5
6
  module Acme
@@ -7,33 +8,34 @@ module IsoDoc
7
8
  # schema encapsulation of the document for validation
8
9
 
9
10
  class WordConvert < IsoDoc::WordConvert
10
- def html_path_acme(file)
11
- File.join(File.dirname(__FILE__), File.join("html", file))
12
- end
13
-
14
11
  def initialize(options)
12
+ @libdir = File.dirname(__FILE__)
15
13
  super
16
- @wordstylesheet = generate_css(html_path_acme("wordstyle.scss"), false, default_fonts(options))
17
- @standardstylesheet = generate_css(html_path_acme("acme.scss"), false, default_fonts(options))
18
- @header = html_path_acme("header.html")
19
- @wordcoverpage = html_path_acme("word_acme_titlepage.html")
20
- @wordintropage = html_path_acme("word_acme_intro.html")
21
- @ulstyle = "l3"
22
- @olstyle = "l2"
23
- system "cp #{html_path_acme('logo.jpg')} logo.jpg"
14
+ #system "cp #{html_doc_path('logo.jpg')} logo.jpg"
15
+ FileUtils.cp html_doc_path('logo.jpg'), "logo.jpg"
24
16
  end
25
17
 
26
18
  def default_fonts(options)
27
- b = options[:bodyfont] ||
28
- (options[:script] == "Hans" ? '"SimSun",serif' :
29
- '"Arial",sans-serif')
30
- h = options[:headerfont] ||
31
- (options[:script] == "Hans" ? '"SimHei",sans-serif' :
32
- '"Arial",sans-serif')
33
- m = options[:monospacefont] || '"Courier New",monospace'
34
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
19
+ {
20
+ bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Arial",sans-serif'),
21
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Arial",sans-serif'),
22
+ monospacefont: '"Courier New",monospace'
23
+ }
35
24
  end
36
25
 
26
+ def default_file_locations(options)
27
+ {
28
+ wordstylesheet: html_doc_path("wordstyle.scss"),
29
+ standardstylesheet: html_doc_path("acme.scss"),
30
+ header: html_doc_path("header.html"),
31
+ wordcoverpage: html_doc_path("word_acme_titlepage.html"),
32
+ wordintropage: html_doc_path("word_acme_intro.html"),
33
+ ulstyle: "l3",
34
+ olstyle: "l2",
35
+ }
36
+ end
37
+
38
+
37
39
  def metadata_init(lang, script, labels)
38
40
  @meta = Metadata.new(lang, script, labels)
39
41
  end
@@ -77,7 +79,7 @@ module IsoDoc
77
79
  h1 = to_xhtml_fragment(h.dup)
78
80
  h1.traverse do |x|
79
81
  x.replace(" ") if x.name == "span" &&
80
- /mso-tab-count/.match?(x["style"])
82
+ /mso-tab-count/.match(x["style"])
81
83
  x.remove if x.name == "span" && x["class"] == "MsoCommentReference"
82
84
  x.remove if x.name == "a" && x["epub:type"] == "footnote"
83
85
  x.replace(x.children) if x.name == "a"
@@ -26,6 +26,35 @@ module Metanorma
26
26
  Metanorma::Input::Asciidoc.new.process(file, @asciidoctor_backend)
27
27
  end
28
28
 
29
+ def extract_options(file)
30
+ head = file.sub(/\n\n.*$/m, "\n")
31
+ /\n:htmlstylesheet: (?<htmlstylesheet>[^\n]+)\n/ =~ head
32
+ /\n:htmlcoverpage: (?<htmlcoverpage>[^\n]+)\n/ =~ head
33
+ /\n:htmlintropage: (?<htmlintropage>[^\n]+)\n/ =~ head
34
+ /\n:scripts: (?<scripts>[^\n]+)\n/ =~ head
35
+ /\n:wordstylesheet: (?<wordstylesheet>[^\n]+)\n/ =~ head
36
+ /\n:standardstylesheet: (?<standardstylesheet>[^\n]+)\n/ =~ head
37
+ /\n:header: (?<header>[^\n]+)\n/ =~ head
38
+ /\n:wordcoverpage: (?<wordcoverpage>[^\n]+)\n/ =~ head
39
+ /\n:wordintropage: (?<wordintropage>[^\n]+)\n/ =~ head
40
+ /\n:ulstyle: (?<ulstyle>[^\n]+)\n/ =~ head
41
+ /\n:olstyle: (?<olstyle>[^\n]+)\n/ =~ head
42
+ new_options = {
43
+ htmlstylesheet: defined?(htmlstylesheet) ? htmlstylesheet : nil,
44
+ htmlcoverpage: defined?(htmlcoverpage) ? htmlcoverpage : nil,
45
+ htmlintropage: defined?(htmlintropage) ? htmlintropage : nil,
46
+ scripts: defined?(scripts) ? scripts : nil,
47
+ wordstylesheet: defined?(wordstylesheet) ? wordstylesheet : nil,
48
+ standardstylesheet: defined?(standardstylesheet) ? standardstylesheet : nil,
49
+ header: defined?(header) ? header : nil,
50
+ wordcoverpage: defined?(wordcoverpage) ? wordcoverpage : nil,
51
+ wordintropage: defined?(wordintropage) ? wordintropage : nil,
52
+ ulstyle: defined?(ulstyle) ? ulstyle : nil,
53
+ olstyle: defined?(olstyle) ? olstyle : nil,
54
+ }.reject { |_, val| val.nil? }
55
+ super.merge(new_options)
56
+ end
57
+
29
58
  def output(isodoc_node, outname, format, options={})
30
59
  case format
31
60
  when :html
@@ -34,14 +63,6 @@ module Metanorma
34
63
  IsoDoc::Acme::WordConvert.new(options).convert(outname, isodoc_node)
35
64
  when :pdf
36
65
  IsoDoc::Acme::PdfConvert.new(options).convert(outname, isodoc_node)
37
- =begin
38
- require 'tempfile'
39
- outname_html = outname + ".html"
40
- IsoDoc::Acme::HtmlConvert.new(options).convert(outname_html, isodoc_node)
41
- puts outname_html
42
- system "cat #{outname_html}"
43
- Metanorma::Output::Pdf.new.convert(outname_html, outname)
44
- =end
45
66
  else
46
67
  super
47
68
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Acme
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
30
  spec.add_dependency "ruby-jing"
31
31
 
32
- spec.add_dependency "asciidoctor-iso", "~> 0.9.3"
33
- spec.add_dependency "isodoc", "~> 0.8.1"
32
+ spec.add_dependency "metanorma-standoc", "~> 1.0.0"
33
+ spec.add_dependency "isodoc", "~> 0.8.8"
34
34
 
35
35
  spec.add_development_dependency "bundler", "~> 1.15"
36
36
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -43,4 +43,5 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "simplecov", "~> 0.15"
44
44
  spec.add_development_dependency "timecop", "~> 0.9"
45
45
  spec.add_development_dependency "metanorma", "~> 0.2.5"
46
+ spec.add_development_dependency "metanorma-cli", "~> 0.0.1"
46
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-acme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -53,33 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: asciidoctor-iso
56
+ name: metanorma-standoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.3
61
+ version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.3
68
+ version: 1.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: isodoc
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.8.1
75
+ version: 0.8.8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.8.1
82
+ version: 0.8.8
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: 0.2.5
237
+ - !ruby/object:Gem::Dependency
238
+ name: metanorma-cli
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.0.1
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 0.0.1
237
251
  description: |
238
252
  Metanorma for the (fictitious) Acme Corp.
239
253
 
@@ -301,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
315
  version: '0'
302
316
  requirements: []
303
317
  rubyforge_project:
304
- rubygems_version: 2.7.7
318
+ rubygems_version: 2.7.6
305
319
  signing_key:
306
320
  specification_version: 4
307
321
  summary: Metanorma for the (fictitious) Acme Corp.