metanorma-m3d 1.0.2 → 1.0.3

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: 33357663540823bfd36ac345d42da5814b1d69f3b7b8652434db43a927b8dd3f
4
- data.tar.gz: 15cd653c3ec6952ca03bb33fb989c7eef1670aac3798f322fb8eddbe0b2aca4c
3
+ metadata.gz: 8391270f98c3dc1df190b52dec7641db3b500296b081a36fbcff596b49b7a335
4
+ data.tar.gz: 352a3fecc4687580b3f96c6f549d49faec6107a21eee37f45648e7fdd82c9e1f
5
5
  SHA512:
6
- metadata.gz: 2d21bed6f5986e92fface06808c8096d89bb2d7e363103a282020b65226c2a8ad0680fbcce966b7a39393eb7eb821db3792a1c77406ce2507bb49c0beb534e62
7
- data.tar.gz: 293bf2115c741bfca50a427b1138b3cc1516851114e231d7069aba386c9c9268579574ef2d3448e7676bc10fba25d2f6a3f442bdf0197c2951bec65557f1a15b
6
+ metadata.gz: c6a041e2e7378ba80d6b2fc6b9d76f702a18daab3fc9e980be243cba41e59172e891d979bb5841dc3e40a93b09b12983d432130d5f1483832a6783e27b50ae5a
7
+ data.tar.gz: edbbfa7950cc912283be30f26b0dc0810c0df83462fd710e64df7487119b9ce22bb10ccdf855aabe1f4af7d3dd2d1d9262d6b581b94ac7d240a2ec1e1fdb264c
data/.travis.yml CHANGED
@@ -8,6 +8,8 @@ rvm:
8
8
  - ruby-head
9
9
  before_install:
10
10
  - gem install bundler -v 1.16.1
11
+ - npm install -g puppeteer
12
+ - npm install
11
13
  - unset _JAVA_OPTIONS
12
14
  matrix:
13
15
  allow_failures:
@@ -121,6 +121,7 @@ module Asciidoctor
121
121
  gsub(%r{^.*/}, "")
122
122
  File.open(filename, "w") { |f| f.write(ret) }
123
123
  html_converter(node).convert filename unless node.attr("nodoc")
124
+ pdf_converter(node).convert filename unless node.attr("nodoc")
124
125
  word_converter(node).convert filename unless node.attr("nodoc")
125
126
  end
126
127
  @files_to_delete.each { |f| system "rm #{f}" }
@@ -161,6 +162,10 @@ module Asciidoctor
161
162
  IsoDoc::M3d::WordConvert.new(doc_extract_attributes(node))
162
163
  end
163
164
 
165
+ def pdf_converter(node)
166
+ IsoDoc::M3d::PdfConvert.new(html_extract_attributes(node))
167
+ end
168
+
164
169
  def inline_quoted(node)
165
170
  noko do |xml|
166
171
  case node.type
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module M3d
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
@@ -33,21 +33,23 @@
33
33
  </div>
34
34
 
35
35
  <div class="docinfo">
36
- Updated <span class="date">{{ revdate_monthyear }}</span>,
37
- Version <span class="version">{{ draft }}</span> <br/>
36
+ {% if revdate_monthyear -%}Updated <span class="date">{{ revdate_monthyear }}</span>{%- endif -%}{%- if revdate_monthyear and draft -%},{%- endif -%}{%- if draft -%}Version <span class="version">{{ draft }}</span>{%- endif -%}
37
+ <br/>
38
38
  {% if url %}
39
39
  Shortened URL to this document: <a href="{{ url }}">{{ url }}</a>
40
40
  {% endif %}
41
41
  </div>
42
42
 
43
+ {% if tc %}
43
44
  <div class="coverpage-tc-name">
44
45
  <span>TC {{ tc }}</span>
45
46
  </div>
47
+ {% endif %}
46
48
  </div>
47
49
 
48
50
  <div class="title-section1">
49
51
  <div class="coverpage-stage-block" >
50
- <span class="coverpage-stage" id="{{ doctype | replace: ' ', '-' | downcase }}">Ribose {{ doctype }}</span>
52
+ <span class="coverpage-stage" id="{{ doctype | replace: ' ', '-' | downcase }}">{{ doctype }}</span>
51
53
  </div>
52
54
 
53
55
  <div class="coverpage-stage-block" >
@@ -67,10 +67,10 @@ time, mark, audio, video {
67
67
 
68
68
 
69
69
  html, body, div, span, applet, object, iframe,
70
- p, blockquote, pre,
71
- a, abbr, acronym, address, big, cite, code,
72
- del, dfn, em, img, ins, kbd, q, s, samp,
73
- small, strike, strong, sub, sup, tt, var,
70
+ p, blockquote,
71
+ a, abbr, acronym, address, big, cite,
72
+ del, dfn, em, img, ins, q, s,
73
+ small, strike, strong, sub, sup, var,
74
74
  b, u, i, center,
75
75
  dl, dt, dd, ol, ul, li,
76
76
  fieldset, form, label, legend,
@@ -82,6 +82,10 @@ time, mark, audio, video {
82
82
  font-family: $bodyfont;
83
83
  }
84
84
 
85
+ code, pre, tt, kbd, samp {
86
+ font-family: $monospacefont;
87
+ }
88
+
85
89
  h1, h2, h3, h4, h5, h6, .h2Annex {
86
90
  font-family: $headerfont;
87
91
  }
@@ -154,7 +158,7 @@ table {
154
158
  */
155
159
 
156
160
 
157
- @media (min-width: 768px) {
161
+ @media screen and (min-width: 768px) {
158
162
  nav {
159
163
  position: fixed;
160
164
  top: 0;
@@ -205,7 +209,7 @@ table {
205
209
  }
206
210
  }
207
211
 
208
- @media (max-width: 768px) {
212
+ @media screen and (max-width: 768px) {
209
213
  #toc {
210
214
  padding: 0 1.5em 0 1.5em;
211
215
  overflow: visible;
@@ -447,6 +451,7 @@ p.document-stage {
447
451
  font-size: 1.1em;
448
452
  }
449
453
 
454
+ @media screen {
450
455
  span[id^="toc"]:after {
451
456
  float: left;
452
457
  padding-right: 4px;
@@ -457,6 +462,7 @@ p.document-stage {
457
462
  color: #cfcfcf;
458
463
  content: "\f0c1";
459
464
  }
465
+ }
460
466
 
461
467
  .TermNum, .Terms, .AltTerms {
462
468
  color: black;
@@ -816,6 +822,7 @@ p {
816
822
 
817
823
  .coverpage-logo img {
818
824
  width: 400px;
825
+ height: auto;
819
826
  }
820
827
 
821
828
 
@@ -994,7 +1001,7 @@ a.anchorjs-link:hover {
994
1001
 
995
1002
  @media print {
996
1003
  .section-title {page-break-before: always;}
997
- nav, #toc, #toggle, .document-stage-band,
1004
+ #toggle, .document-stage-band,
998
1005
  .document-type-band {display: none;}
999
1006
  .container {padding-left: 0;}
1000
1007
 
@@ -584,14 +584,6 @@ div.coverpage_warning
584
584
  margin: 0.25em 0;
585
585
  }
586
586
 
587
- .coverpage-doc-identity {
588
- background-color: #485094;
589
- color: white;
590
- font-size: 2em;
591
- line-height: 2em;
592
- margin: 0.5em 0;
593
- }
594
-
595
587
  .coverpage-title {
596
588
  font-weight: 400;
597
589
  }
@@ -668,17 +660,6 @@ aside {
668
660
  font-size:10.0pt;
669
661
  }
670
662
 
671
- /*
672
- div.example {
673
- border:solid black .25pt;
674
- mso-border-alt:solid black .25pt;
675
- padding:10pt;
676
- mso-padding-alt:10.0pt 10.0pt 10.0pt 10.0pt;
677
- margin:10pt;
678
- mso-margin-alt:10.0pt 10.0pt 10.0pt 10.0pt;
679
- }
680
- */
681
-
682
663
  div.example {
683
664
  margin-left:70.9pt;
684
665
  text-indent:-70.9pt;
@@ -1,11 +1,12 @@
1
- <script>//TOC generation
1
+ <script>
2
+ //TOC generation
2
3
  $('#toc').toc({
3
4
  'selectors': 'h1,h2:not(.TermNum)', //elements to use as headings
4
5
  'container': 'main', //element to find all selectors in
5
6
  'smoothScrolling': true, //enable or disable smooth scrolling on click
6
7
  'prefix': 'toc', //prefix for anchor tags and class names
7
8
  'onHighlight': function(el) {}, //called when a new section is highlighted
8
- 'highlightOnScroll': true, //add class to heading that is currently in focus
9
+ 'highlightOnScroll': false, //add class to heading that is currently in focus
9
10
  'highlightOffset': 100, //offset to trigger the next headline
10
11
  'anchorName': function(i, heading, prefix) { //custom function for anchor name
11
12
  return prefix+i;
@@ -56,13 +57,14 @@ $('#toggle').on('click', function(){
56
57
  }
57
58
  </script>
58
59
 
59
- <script>
60
+ <script>
60
61
  $(document).ready(function() {
61
- $('[id^=toc]').each(function ()
62
- {
63
- var currentToc = $(this);
62
+ $('[id^=toc]').each(function ()
63
+ {
64
+ var currentToc = $(this);
64
65
  var url = window.location.href;
65
- currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
66
- });
66
+ currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
67
+ });
67
68
  });
68
69
  </script>
70
+
@@ -35,6 +35,7 @@ module IsoDoc
35
35
  htmlstylesheet: html_doc_path("htmlstyle.scss"),
36
36
  htmlcoverpage: html_doc_path("html_m3d_titlepage.html"),
37
37
  htmlintropage: html_doc_path("html_m3d_intro.html"),
38
+ standardstylesheet: nil,
38
39
  scripts: html_doc_path("scripts.html"),
39
40
  }
40
41
  end
@@ -48,7 +49,7 @@ module IsoDoc
48
49
  div << <<~"COLOPHON"
49
50
  <p>As with all M3AAWG documents that we publish, please check the M3AAWG website
50
51
  (<a href="http://www.m3aawg.org">www.m3aawg.org</a>) for updates to this paper.</p>
51
- <p>&copy; 2017 copyright by the Messaging, Malware and Mobile Anti-Abuse Working Group (M3AAWG)</p>
52
+ <p>&copy; {{ docyear }} copyright by the Messaging, Malware and Mobile Anti-Abuse Working Group (M3AAWG)</p>
52
53
  COLOPHON
53
54
  end
54
55
  end
@@ -0,0 +1,155 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+ require_relative "m3dpdfrender"
4
+ require "fileutils"
5
+
6
+ module IsoDoc
7
+ module M3d
8
+ # A {Converter} implementation that generates CSAND output, and a document
9
+ # schema encapsulation of the document for validation
10
+ class PdfConvert < IsoDoc::PdfConvert
11
+ def add_image(filenames)
12
+ filenames.each do |filename|
13
+ FileUtils.cp html_doc_path(filename), filename
14
+ @files_to_delete << filename
15
+ end
16
+ end
17
+
18
+ def initialize(options)
19
+ @libdir = File.dirname(__FILE__)
20
+ super
21
+ add_image(%w(logo.jpg m3-logo.png))
22
+ end
23
+
24
+ def default_fonts(options)
25
+ {
26
+ bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
27
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
28
+ monospacefont: '"Space Mono",monospace'
29
+ }
30
+ end
31
+
32
+ def default_file_locations(_options)
33
+ {
34
+ htmlstylesheet: html_doc_path("htmlstyle.scss"),
35
+ htmlcoverpage: html_doc_path("html_m3d_titlepage.html"),
36
+ htmlintropage: html_doc_path("html_m3d_intro.html"),
37
+ standardstylesheet: nil,
38
+ scripts_pdf: html_doc_path("scripts.pdf.html"),
39
+ }
40
+ end
41
+
42
+ def metadata_init(lang, script, labels)
43
+ @meta = Metadata.new(lang, script, labels)
44
+ end
45
+
46
+ def colophon(body, docxml)
47
+ body.div **{ class: "colophon" } do |div|
48
+ div << <<~"COLOPHON"
49
+ <p>As with all M3AAWG documents that we publish, please check the M3AAWG website
50
+ (<a href="http://www.m3aawg.org">www.m3aawg.org</a>) for updates to this paper.</p>
51
+ <p>&copy; {{ docyear }} copyright by the Messaging, Malware and Mobile Anti-Abuse Working Group (M3AAWG)</p>
52
+ COLOPHON
53
+ end
54
+ end
55
+
56
+ def html_head()
57
+ <<~HEAD.freeze
58
+ <title>{{ doctitle }}</title>
59
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
60
+
61
+ <!--TOC script import-->
62
+ <script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
63
+
64
+ <!--Google fonts-->
65
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
66
+ <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
67
+ <!--Font awesome import for the link icon-->
68
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
69
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
70
+ <style class="anchorjs"></style>
71
+ HEAD
72
+ end
73
+
74
+ def make_body(xml, docxml)
75
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
76
+ xml.body **body_attr do |body|
77
+ make_body1(body, docxml)
78
+ make_body2(body, docxml)
79
+ make_body3(body, docxml)
80
+ colophon(body, docxml)
81
+ end
82
+ end
83
+
84
+ def html_toc(docxml)
85
+ docxml
86
+ end
87
+
88
+ def annex_name(annex, name, div)
89
+ div.h1 **{ class: "Annex" } do |t|
90
+ t << "#{get_anchors[annex['id']][:label]} "
91
+ t << "<b>#{name.text}</b>"
92
+ end
93
+ end
94
+
95
+ def annex_name_lbl(clause, num)
96
+ obl = l10n("(#{@inform_annex_lbl})")
97
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
98
+ l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
99
+ end
100
+
101
+ def pre_parse(node, out)
102
+ out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
103
+ end
104
+
105
+ def term_defs_boilerplate(div, source, term, preface)
106
+ if source.empty? && term.nil?
107
+ div << @no_terms_boilerplate
108
+ else
109
+ div << term_defs_boilerplate_cont(source, term)
110
+ end
111
+ end
112
+
113
+ def i18n_init(lang, script)
114
+ super
115
+ @annex_lbl = "Appendix"
116
+ end
117
+
118
+ def error_parse(node, out)
119
+ # catch elements not defined in ISO
120
+ case node.name
121
+ when "pre"
122
+ pre_parse(node, out)
123
+ when "keyword"
124
+ out.span node.text, **{ class: "keyword" }
125
+ else
126
+ super
127
+ end
128
+ end
129
+
130
+ def fileloc(loc)
131
+ File.join(File.dirname(__FILE__), loc)
132
+ end
133
+
134
+ def cleanup(docxml)
135
+ super
136
+ term_cleanup(docxml)
137
+ end
138
+
139
+ def term_cleanup(docxml)
140
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
141
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
142
+ h2.add_child("&nbsp;")
143
+ h2.add_child(d.remove)
144
+ end
145
+ docxml
146
+ end
147
+
148
+ def info(isoxml, out)
149
+ @meta.url isoxml, out
150
+ super
151
+ end
152
+ end
153
+ end
154
+ end
155
+
@@ -0,0 +1,68 @@
1
+ module IsoDoc
2
+ module M3d
3
+ # A {Converter} implementation that generates CSAND output, and a document
4
+ # schema encapsulation of the document for validation
5
+ class PdfConvert < IsoDoc::PdfConvert
6
+ def annex_name(annex, name, div)
7
+ div.h1 **{ class: "Annex" } do |t|
8
+ t << "#{get_anchors[annex['id']][:label]} "
9
+ t << "<b>#{name.text}</b>"
10
+ end
11
+ end
12
+
13
+ def annex_name_lbl(clause, num)
14
+ obl = l10n("(#{@inform_annex_lbl})")
15
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
16
+ l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
17
+ end
18
+
19
+ def pre_parse(node, out)
20
+ out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
21
+ end
22
+
23
+ def term_defs_boilerplate(div, source, term, preface)
24
+ if source.empty? && term.nil?
25
+ div << @no_terms_boilerplate
26
+ else
27
+ div << term_defs_boilerplate_cont(source, term)
28
+ end
29
+ end
30
+
31
+ def i18n_init(lang, script)
32
+ super
33
+ @annex_lbl = "Appendix"
34
+ end
35
+
36
+ def error_parse(node, out)
37
+ # catch elements not defined in ISO
38
+ case node.name
39
+ when "pre"
40
+ pre_parse(node, out)
41
+ when "keyword"
42
+ out.span node.text, **{ class: "keyword" }
43
+ else
44
+ super
45
+ end
46
+ end
47
+
48
+ def fileloc(loc)
49
+ File.join(File.dirname(__FILE__), loc)
50
+ end
51
+
52
+ def cleanup(docxml)
53
+ super
54
+ term_cleanup(docxml)
55
+ end
56
+
57
+ def term_cleanup(docxml)
58
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
59
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
60
+ h2.add_child("&nbsp;")
61
+ h2.add_child(d.remove)
62
+ end
63
+ docxml
64
+ end
65
+ end
66
+ end
67
+ end
68
+