metanorma-csd 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/csd/biblio.rng +7 -3
- data/lib/asciidoctor/csd/converter.rb +7 -2
- data/lib/asciidoctor/csd/csd.rng +3 -0
- data/lib/asciidoctor/csd/isodoc.rng +8 -1
- data/lib/asciidoctor/csd/isostandard.rng +63 -15
- data/lib/asciidoctor/csd/version.rb +1 -1
- data/lib/isodoc/csd/html/csd.scss +28 -12
- data/lib/isodoc/csd/html/html_csd_titlepage.html +4 -4
- data/lib/isodoc/csd/html/htmlstyle.scss +5 -2
- data/lib/isodoc/csd/html/word_csd_intro.html +17 -0
- data/lib/isodoc/csd/html/word_csd_titlepage.html +69 -0
- data/lib/isodoc/csd/html/wordstyle.scss +1096 -0
- data/lib/isodoc/csd/{csdconvert.rb → html_convert.rb} +1 -0
- data/lib/isodoc/csd/word_convert.rb +96 -0
- data/lib/metanorma-csd.rb +2 -1
- data/lib/metanorma/csd/processor.rb +5 -2
- metadata +7 -3
@@ -0,0 +1,96 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require_relative "metadata"
|
3
|
+
|
4
|
+
module IsoDoc
|
5
|
+
module Csd
|
6
|
+
# A {Converter} implementation that generates CSD output, and a document
|
7
|
+
# schema encapsulation of the document for validation
|
8
|
+
class WordConvert < IsoDoc::WordConvert
|
9
|
+
def initialize(options)
|
10
|
+
@libdir = File.dirname(__FILE__)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_fonts(options)
|
15
|
+
{
|
16
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Arial",sans-serif'),
|
17
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Arial",sans-serif'),
|
18
|
+
monospacefont: '"Courier New",monospace'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def default_file_locations(options)
|
23
|
+
{
|
24
|
+
wordstylesheet: html_doc_path("wordstyle.scss"),
|
25
|
+
standardstylesheet: html_doc_path("csd.scss"),
|
26
|
+
header: html_doc_path("header.html"),
|
27
|
+
wordcoverpage: html_doc_path("word_csd_titlepage.html"),
|
28
|
+
wordintropage: html_doc_path("word_csd_intro.html"),
|
29
|
+
ulstyle: "l3",
|
30
|
+
olstyle: "l2",
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def metadata_init(lang, script, labels)
|
35
|
+
@meta = Metadata.new(lang, script, labels)
|
36
|
+
end
|
37
|
+
|
38
|
+
def annex_name(annex, name, div)
|
39
|
+
div.h1 **{ class: "Annex" } do |t|
|
40
|
+
t << "#{get_anchors[annex['id']][:label]} "
|
41
|
+
t << "<b>#{name.text}</b>"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def annex_name_lbl(clause, num)
|
46
|
+
obl = l10n("(#{@inform_annex_lbl})")
|
47
|
+
obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
|
48
|
+
l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
|
49
|
+
end
|
50
|
+
|
51
|
+
def pre_parse(node, out)
|
52
|
+
out.pre node.text # content.gsub(/</, "<").gsub(/>/, ">")
|
53
|
+
end
|
54
|
+
|
55
|
+
def term_defs_boilerplate(div, source, term, preface)
|
56
|
+
if source.empty? && term.nil?
|
57
|
+
div << @no_terms_boilerplate
|
58
|
+
else
|
59
|
+
div << term_defs_boilerplate_cont(source, term)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def i18n_init(lang, script)
|
64
|
+
super
|
65
|
+
@annex_lbl = "Appendix"
|
66
|
+
end
|
67
|
+
|
68
|
+
def error_parse(node, out)
|
69
|
+
# catch elements not defined in ISO
|
70
|
+
case node.name
|
71
|
+
when "pre"
|
72
|
+
pre_parse(node, out)
|
73
|
+
when "keyword"
|
74
|
+
out.span node.text, **{ class: "keyword" }
|
75
|
+
else
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def cleanup(docxml)
|
81
|
+
super
|
82
|
+
term_cleanup(docxml)
|
83
|
+
end
|
84
|
+
|
85
|
+
def term_cleanup(docxml)
|
86
|
+
docxml.xpath("//p[@class = 'Terms']").each do |d|
|
87
|
+
h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
|
88
|
+
h2.add_child(" ")
|
89
|
+
h2.add_child(d.remove)
|
90
|
+
end
|
91
|
+
docxml
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
data/lib/metanorma-csd.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "asciidoctor" unless defined? Asciidoctor::Converter
|
2
2
|
require_relative "asciidoctor/csd/converter"
|
3
|
-
require_relative "isodoc/csd/
|
3
|
+
require_relative "isodoc/csd/html_convert"
|
4
|
+
require_relative "isodoc/csd/word_convert"
|
4
5
|
require_relative "asciidoctor/csd/version"
|
5
6
|
|
6
7
|
if defined? Metanorma
|
@@ -13,7 +13,8 @@ module Metanorma
|
|
13
13
|
def output_formats
|
14
14
|
super.merge(
|
15
15
|
html: "html",
|
16
|
-
pdf: "pdf"
|
16
|
+
pdf: "pdf",
|
17
|
+
doc: "doc"
|
17
18
|
)
|
18
19
|
end
|
19
20
|
|
@@ -29,13 +30,15 @@ module Metanorma
|
|
29
30
|
case format
|
30
31
|
when :html
|
31
32
|
IsoDoc::Csd::HtmlConvert.new(options).convert(outname, isodoc_node)
|
33
|
+
when :doc
|
34
|
+
IsoDoc::Csd::WordConvert.new(options).convert(outname, isodoc_node)
|
32
35
|
when :pdf
|
33
36
|
#require 'tempfile'
|
34
37
|
# Tempfile.open("#{outname}.html") do |tmp|
|
35
38
|
outname_html = outname + ".html"
|
36
39
|
IsoDoc::Csd::HtmlConvert.new(options).convert(outname_html, isodoc_node)
|
37
40
|
puts outname_html
|
38
|
-
system "cat #{outname_html}"
|
41
|
+
#system "cat #{outname_html}"
|
39
42
|
Metanorma::Output::Pdf.new.convert(outname_html, outname)
|
40
43
|
else
|
41
44
|
super
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-csd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
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-
|
11
|
+
date: 2018-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-standoc
|
@@ -224,7 +224,6 @@ files:
|
|
224
224
|
- lib/asciidoctor/csd/isostandard.rng
|
225
225
|
- lib/asciidoctor/csd/pdf.js
|
226
226
|
- lib/asciidoctor/csd/version.rb
|
227
|
-
- lib/isodoc/csd/csdconvert.rb
|
228
227
|
- lib/isodoc/csd/html/csd.scss
|
229
228
|
- lib/isodoc/csd/html/dots-w@2x.png
|
230
229
|
- lib/isodoc/csd/html/dots@2x.png
|
@@ -233,7 +232,12 @@ files:
|
|
233
232
|
- lib/isodoc/csd/html/html_csd_titlepage.html
|
234
233
|
- lib/isodoc/csd/html/htmlstyle.scss
|
235
234
|
- lib/isodoc/csd/html/scripts.html
|
235
|
+
- lib/isodoc/csd/html/word_csd_intro.html
|
236
|
+
- lib/isodoc/csd/html/word_csd_titlepage.html
|
237
|
+
- lib/isodoc/csd/html/wordstyle.scss
|
238
|
+
- lib/isodoc/csd/html_convert.rb
|
236
239
|
- lib/isodoc/csd/metadata.rb
|
240
|
+
- lib/isodoc/csd/word_convert.rb
|
237
241
|
- lib/metanorma-csd.rb
|
238
242
|
- lib/metanorma/csd.rb
|
239
243
|
- lib/metanorma/csd/processor.rb
|