metanorma-itu 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.hound.yml +3 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +17 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.adoc +72 -0
- data/Rakefile +6 -0
- data/appveyor.yml +29 -0
- data/lib/asciidoctor/itu.rb +7 -0
- data/lib/asciidoctor/itu/biblio.rng +949 -0
- data/lib/asciidoctor/itu/converter.rb +164 -0
- data/lib/asciidoctor/itu/front.rb +182 -0
- data/lib/asciidoctor/itu/isodoc.rng +1132 -0
- data/lib/asciidoctor/itu/isostandard.rng +801 -0
- data/lib/asciidoctor/itu/itu.rng +223 -0
- data/lib/asciidoctor/itu/reqt.rng +162 -0
- data/lib/asciidoctor/itu/validate.rb +55 -0
- data/lib/isodoc/itu.rb +11 -0
- data/lib/isodoc/itu/base_convert.rb +210 -0
- data/lib/isodoc/itu/html/Logo_ITU.jpg +0 -0
- data/lib/isodoc/itu/html/header.html +162 -0
- data/lib/isodoc/itu/html/html_itu_intro.html +42 -0
- data/lib/isodoc/itu/html/html_itu_titlepage.html +144 -0
- data/lib/isodoc/itu/html/htmlstyle.scss +1167 -0
- data/lib/isodoc/itu/html/itu-document-comb.png +0 -0
- data/lib/isodoc/itu/html/itu.scss +707 -0
- data/lib/isodoc/itu/html/logo.png +0 -0
- data/lib/isodoc/itu/html/scripts.html +82 -0
- data/lib/isodoc/itu/html/scripts.pdf.html +70 -0
- data/lib/isodoc/itu/html/word_itu_intro.html +246 -0
- data/lib/isodoc/itu/html/word_itu_titlepage.html +283 -0
- data/lib/isodoc/itu/html/wordstyle.scss +1237 -0
- data/lib/isodoc/itu/html_convert.rb +72 -0
- data/lib/isodoc/itu/i18n-en.yaml +2 -0
- data/lib/isodoc/itu/metadata.rb +100 -0
- data/lib/isodoc/itu/pdf_convert.rb +70 -0
- data/lib/isodoc/itu/word_convert.rb +115 -0
- data/lib/metanorma-itu.rb +8 -0
- data/lib/metanorma/itu.rb +11 -0
- data/lib/metanorma/itu/processor.rb +43 -0
- data/lib/metanorma/itu/version.rb +5 -0
- data/metanorma-itu.gemspec +44 -0
- metadata +327 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require_relative "metadata"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
module ITU
|
7
|
+
|
8
|
+
# A {Converter} implementation that generates HTML output, and a document
|
9
|
+
# schema encapsulation of the document for validation
|
10
|
+
#
|
11
|
+
class HtmlConvert < IsoDoc::HtmlConvert
|
12
|
+
def initialize(options)
|
13
|
+
@libdir = File.dirname(__FILE__)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def convert1(docxml, filename, dir)
|
18
|
+
FileUtils.cp html_doc_path('Logo_ITU.jpg'), "#{@localdir}/Logo_ITU.jpg"
|
19
|
+
@files_to_delete << "#{@localdir}/Logo_ITU.jpg"
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def html_toc(docxml)
|
24
|
+
docxml
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_fonts(options)
|
28
|
+
{
|
29
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Open Sans",sans-serif'),
|
30
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Open Sans",sans-serif'),
|
31
|
+
monospacefont: '"Space Mono",monospace'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_file_locations(_options)
|
36
|
+
{
|
37
|
+
htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
38
|
+
htmlcoverpage: html_doc_path("html_itu_titlepage.html"),
|
39
|
+
htmlintropage: html_doc_path("html_itu_intro.html"),
|
40
|
+
scripts: html_doc_path("scripts.html"),
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def googlefonts
|
45
|
+
<<~HEAD.freeze
|
46
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,800|Space+Mono:400,700" rel="stylesheet">
|
47
|
+
HEAD
|
48
|
+
end
|
49
|
+
|
50
|
+
def make_body(xml, docxml)
|
51
|
+
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
|
52
|
+
xml.body **body_attr do |body|
|
53
|
+
make_body1(body, docxml)
|
54
|
+
make_body2(body, docxml)
|
55
|
+
make_body3(body, docxml)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def make_body3(body, docxml)
|
60
|
+
body.div **{ class: "main-section" } do |div3|
|
61
|
+
abstract docxml, div3
|
62
|
+
preface docxml, div3
|
63
|
+
middle docxml, div3
|
64
|
+
footnotes div3
|
65
|
+
comments div3
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
include BaseConvert
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
module ITU
|
5
|
+
|
6
|
+
class Metadata < IsoDoc::Metadata
|
7
|
+
def initialize(lang, script, labels)
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def title(isoxml, _out)
|
12
|
+
main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text
|
13
|
+
set(:doctitle, main)
|
14
|
+
series = isoxml&.at(ns("//bibdata/series[@type='main']/title"))&.text
|
15
|
+
set(:series, series)
|
16
|
+
series1 = isoxml&.at(ns("//bibdata/series[@type='secondary']/title"))&.text
|
17
|
+
set(:series1, series1)
|
18
|
+
series2 = isoxml&.at(ns("//bibdata/series[@type='tertiary']/title"))&.text
|
19
|
+
set(:series2, series2)
|
20
|
+
end
|
21
|
+
|
22
|
+
def subtitle(_isoxml, _out)
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def author(isoxml, _out)
|
27
|
+
bureau = isoxml.at(ns("//bibdata/ext/editorialgroup/bureau"))
|
28
|
+
set(:bureau, bureau.text) if bureau
|
29
|
+
tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
|
30
|
+
set(:tc, tc.text) if tc
|
31
|
+
end
|
32
|
+
|
33
|
+
def docid(isoxml, _out)
|
34
|
+
dn = isoxml.at(ns("//bibdata/docnumber"))
|
35
|
+
set(:docnumber, dn&.text)
|
36
|
+
dn = isoxml.at(ns("//bibdata/docidentifier"))
|
37
|
+
set(:docidentifier, dn&.text)
|
38
|
+
end
|
39
|
+
|
40
|
+
def status_abbr(status)
|
41
|
+
case status
|
42
|
+
when "working-draft" then "wd"
|
43
|
+
when "committee-draft" then "cd"
|
44
|
+
when "draft-standard" then "d"
|
45
|
+
else
|
46
|
+
""
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def unpublished(status)
|
51
|
+
%w(in-force-prepublished).include? status.downcase
|
52
|
+
end
|
53
|
+
|
54
|
+
def version(isoxml, _out)
|
55
|
+
super
|
56
|
+
revdate = get[:revdate]
|
57
|
+
set(:revdate_monthyear, monthyr(revdate))
|
58
|
+
end
|
59
|
+
|
60
|
+
MONTHS = {
|
61
|
+
"01": "January",
|
62
|
+
"02": "February",
|
63
|
+
"03": "March",
|
64
|
+
"04": "April",
|
65
|
+
"05": "May",
|
66
|
+
"06": "June",
|
67
|
+
"07": "July",
|
68
|
+
"08": "August",
|
69
|
+
"09": "September",
|
70
|
+
"10": "October",
|
71
|
+
"11": "November",
|
72
|
+
"12": "December",
|
73
|
+
}.freeze
|
74
|
+
|
75
|
+
def bibdate(isoxml, _out)
|
76
|
+
pubdate = isoxml.xpath(ns("//bibdata/date[@type = 'published']"))
|
77
|
+
pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
|
78
|
+
end
|
79
|
+
|
80
|
+
def monthyr(isodate)
|
81
|
+
m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
|
82
|
+
return isodate unless m && m[:yr] && m[:mo]
|
83
|
+
return "#{m[:mo]}/#{m[:yr]}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def keywords(isoxml, _out)
|
87
|
+
keywords = []
|
88
|
+
isoxml.xpath(ns("//bibdata/ext/keyword")).each do |kw|
|
89
|
+
keywords << kw.text
|
90
|
+
end
|
91
|
+
set(:keywords, keywords)
|
92
|
+
end
|
93
|
+
|
94
|
+
def ip_notice_received(isoxml, _out)
|
95
|
+
received = isoxml.at(ns("//bibdata/ext/ip-notice-received"))&.text || "false"
|
96
|
+
set(:ip_notice_received, received)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require_relative "metadata"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
module ITU
|
7
|
+
# A {Converter} implementation that generates PDF HTML output, and a
|
8
|
+
# document schema encapsulation of the document for validation
|
9
|
+
class PdfConvert < IsoDoc::PdfConvert
|
10
|
+
def initialize(options)
|
11
|
+
@libdir = File.dirname(__FILE__)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def convert1(docxml, filename, dir)
|
16
|
+
FileUtils.cp html_doc_path('Logo_ITU.jpg'), File.join(@localdir, "Logo_ITU.jpg")
|
17
|
+
@files_to_delete << File.join(@localdir, "Logo_ITU.jpg")
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def html_toc(docxml)
|
22
|
+
docxml
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_fonts(options)
|
26
|
+
{
|
27
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Open Sans",sans-serif'),
|
28
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Open Sans",sans-serif'),
|
29
|
+
monospacefont: '"Space Mono",monospace'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_file_locations(_options)
|
34
|
+
{
|
35
|
+
htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
36
|
+
htmlcoverpage: html_doc_path("html_itu_titlepage.html"),
|
37
|
+
htmlintropage: html_doc_path("html_itu_intro.html"),
|
38
|
+
scripts_pdf: html_doc_path("scripts.pdf.html"),
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def googlefonts()
|
43
|
+
<<~HEAD.freeze
|
44
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,800|Space+Mono:400,700" rel="stylesheet">
|
45
|
+
HEAD
|
46
|
+
end
|
47
|
+
|
48
|
+
def make_body(xml, docxml)
|
49
|
+
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
|
50
|
+
xml.body **body_attr do |body|
|
51
|
+
make_body1(body, docxml)
|
52
|
+
make_body2(body, docxml)
|
53
|
+
make_body3(body, docxml)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def make_body3(body, docxml)
|
58
|
+
body.div **{ class: "main-section" } do |div3|
|
59
|
+
abstract docxml, div3
|
60
|
+
preface docxml, div3
|
61
|
+
middle docxml, div3
|
62
|
+
footnotes div3
|
63
|
+
comments div3
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
include BaseConvert
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require_relative "metadata"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
module ITU
|
7
|
+
# A {Converter} implementation that generates Word output, and a document
|
8
|
+
# schema encapsulation of the document for validation
|
9
|
+
|
10
|
+
class WordConvert < IsoDoc::WordConvert
|
11
|
+
def initialize(options)
|
12
|
+
@libdir = File.dirname(__FILE__)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def make_body(xml, docxml)
|
17
|
+
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
|
18
|
+
xml.body **body_attr do |body|
|
19
|
+
make_body1(body, docxml)
|
20
|
+
make_body2(body, docxml)
|
21
|
+
make_body3(body, docxml)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def make_body2(body, docxml)
|
26
|
+
body.div **{ class: "WordSection2" } do |div2|
|
27
|
+
info docxml, div2
|
28
|
+
abstract docxml, div2
|
29
|
+
keywords docxml, div2
|
30
|
+
preface docxml, div2
|
31
|
+
div2.p { |p| p << " " } # placeholder
|
32
|
+
end
|
33
|
+
section_break(body)
|
34
|
+
end
|
35
|
+
|
36
|
+
def abstract(isoxml, out)
|
37
|
+
f = isoxml.at(ns("//preface/abstract")) || return
|
38
|
+
out.div **attr_code(id: f["id"]) do |s|
|
39
|
+
clause_name(nil, "Summary", s, class: "AbstractTitle")
|
40
|
+
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def keywords(_docxml, out)
|
45
|
+
kw = @meta.get[:keywords]
|
46
|
+
kw.nil? || kw.empty? and return
|
47
|
+
out.div do |div|
|
48
|
+
clause_name(nil, "Keywords", div, class: "IntroTitle")
|
49
|
+
div.p kw.sort.join(", ") + "."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def word_preface_cleanup(docxml)
|
54
|
+
docxml.xpath("//h1[@class = 'AbstractTitle'] | "\
|
55
|
+
"//h1[@class = 'IntroTitle']").each do |h2|
|
56
|
+
h2.name = "p"
|
57
|
+
h2["class"] = "h1Preface"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def word_cleanup(docxml)
|
62
|
+
word_preface_cleanup(docxml)
|
63
|
+
super
|
64
|
+
docxml
|
65
|
+
end
|
66
|
+
|
67
|
+
def middle_title(out)
|
68
|
+
out.p(**{ class: "zzSTDTitle1" }) { |p| p << "Recommendation " + @meta.get[:docidentifier] }
|
69
|
+
out.p(**{ class: "zzSTDTitle2" }) { |p| p << @meta.get[:doctitle] }
|
70
|
+
end
|
71
|
+
|
72
|
+
def word_preface(docxml)
|
73
|
+
super
|
74
|
+
abstractbox = docxml.at("//div[@id='abstractbox']")
|
75
|
+
historybox = docxml.at("//div[@id='historybox']")
|
76
|
+
keywordsbox = docxml.at("//div[@id='keywordsbox']")
|
77
|
+
abstract = docxml.at("//p[@class = 'h1Preface' and text() = 'Summary']/..")
|
78
|
+
history = docxml.at("//p[@class = 'h1Preface' and text() = 'History']/..")
|
79
|
+
keywords = docxml.at("//p[@class = 'h1Preface' and text() = 'Keywords']/..")
|
80
|
+
abstract.parent = abstractbox if abstract && abstractbox
|
81
|
+
history.parent = historybox if history && historybox
|
82
|
+
keywords.parent = keywordsbox if keywords && keywordsbox
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def convert1(docxml, filename, dir)
|
87
|
+
FileUtils.cp html_doc_path('itu-document-comb.png'), File.join(@localdir, "itu-document-comb.png")
|
88
|
+
FileUtils.cp html_doc_path('logo.png'), File.join(@localdir, "logo.png")
|
89
|
+
super
|
90
|
+
end
|
91
|
+
|
92
|
+
def default_fonts(options)
|
93
|
+
{
|
94
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Times New Roman",serif'),
|
95
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Times New Roman",serif'),
|
96
|
+
monospacefont: '"Courier New",monospace'
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def default_file_locations(options)
|
101
|
+
{
|
102
|
+
wordstylesheet: html_doc_path("wordstyle.scss"),
|
103
|
+
standardstylesheet: html_doc_path("itu.scss"),
|
104
|
+
header: html_doc_path("header.html"),
|
105
|
+
wordcoverpage: html_doc_path("word_itu_titlepage.html"),
|
106
|
+
wordintropage: html_doc_path("word_itu_intro.html"),
|
107
|
+
ulstyle: "l3",
|
108
|
+
olstyle: "l2",
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
include BaseConvert
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "metanorma/processor"
|
2
|
+
|
3
|
+
module Metanorma
|
4
|
+
module ITU
|
5
|
+
class Processor < Metanorma::Processor
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@short = :itu
|
9
|
+
@input_format = :asciidoc
|
10
|
+
@asciidoctor_backend = :itu
|
11
|
+
end
|
12
|
+
|
13
|
+
def output_formats
|
14
|
+
super.merge(
|
15
|
+
html: "html",
|
16
|
+
doc: "doc",
|
17
|
+
pdf: "pdf"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def version
|
22
|
+
"Metanorma::Acme #{Metanorma::ITU::VERSION}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def input_to_isodoc(file, filename)
|
26
|
+
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
27
|
+
end
|
28
|
+
|
29
|
+
def output(isodoc_node, outname, format, options={})
|
30
|
+
case format
|
31
|
+
when :html
|
32
|
+
IsoDoc::ITU::HtmlConvert.new(options).convert(outname, isodoc_node)
|
33
|
+
when :doc
|
34
|
+
IsoDoc::ITU::WordConvert.new(options).convert(outname, isodoc_node)
|
35
|
+
when :pdf
|
36
|
+
IsoDoc::ITU::PdfConvert.new(options).convert(outname, isodoc_node)
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "metanorma/itu/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "metanorma-itu"
|
7
|
+
spec.version = Metanorma::ITU::VERSION
|
8
|
+
spec.authors = ["Ribose Inc."]
|
9
|
+
spec.email = ["open.source@ribose.com"]
|
10
|
+
|
11
|
+
spec.summary = "Metanorma for the ITU"
|
12
|
+
spec.description = <<~DESCRIPTION
|
13
|
+
Metanorma for the ITU.
|
14
|
+
DESCRIPTION
|
15
|
+
|
16
|
+
spec.homepage = "https://github.com/metanorma/metanorma-itu"
|
17
|
+
spec.license = "BSD-2-Clause"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "asciidoctor", "~> 1.5.7"
|
27
|
+
spec.add_dependency "htmlentities", "~> 4.3.4"
|
28
|
+
spec.add_dependency "ruby-jing"
|
29
|
+
spec.add_dependency "metanorma-standoc", "~> 1.1.0"
|
30
|
+
spec.add_dependency "isodoc", "~> 0.9.0"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 2.0.1"
|
33
|
+
spec.add_development_dependency "byebug", "~> 9.1"
|
34
|
+
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
35
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
36
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
37
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
38
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
39
|
+
spec.add_development_dependency "rubocop", "= 0.54.0"
|
40
|
+
spec.add_development_dependency "simplecov", "~> 0.15"
|
41
|
+
spec.add_development_dependency "timecop", "~> 0.9"
|
42
|
+
spec.add_development_dependency "metanorma", "~> 0.3.0"
|
43
|
+
spec.add_development_dependency "metanorma-cli", "~> 1.1.2"
|
44
|
+
end
|