metanorma-m3d 1.3.16 → 1.3.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,71 +1,30 @@
1
- require "isodoc"
2
1
  require_relative "base_convert"
2
+ require "isodoc"
3
3
 
4
4
  module IsoDoc
5
5
  module M3d
6
- # A {Converter} implementation that generates CSAND output, and a document
6
+
7
+ # A {Converter} implementation that generates HTML output, and a document
7
8
  # schema encapsulation of the document for validation
8
- class PdfConvert < IsoDoc::PdfConvert
9
+ #
10
+ class PdfConvert < IsoDoc::XslfoPdfConvert
9
11
  def initialize(options)
10
12
  @libdir = File.dirname(__FILE__)
11
13
  super
12
14
  end
13
15
 
14
- #def convert1(docxml, filename, dir)
15
- #add_image(%w(logo.jpg m3-logo.png))
16
- #super
17
- #end
18
-
19
- def default_fonts(options)
20
- {
21
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
22
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
23
- monospacefont: '"Space Mono",monospace'
24
- }
25
- end
26
-
27
- def default_file_locations(_options)
28
- {
29
- htmlstylesheet: html_doc_path("htmlstyle.scss"),
30
- htmlcoverpage: html_doc_path("html_m3d_titlepage.html"),
31
- htmlintropage: html_doc_path("html_m3d_intro.html"),
32
- standardstylesheet: nil,
33
- scripts_pdf: html_doc_path("scripts.pdf.html"),
34
- }
35
- end
36
-
37
- def colophon(body, docxml)
38
- body.div **{ class: "colophon" } do |div|
39
- div << <<~"COLOPHON"
40
- <p>As with all M3AAWG documents that we publish, please check the M3AAWG website
41
- (<a href="http://www.m3aawg.org">www.m3aawg.org</a>) for updates to this paper.</p>
42
- <p>&copy; {{ docyear }} copyright by the Messaging, Malware and Mobile Anti-Abuse Working Group (M3AAWG)</p>
43
- COLOPHON
16
+ def convert(filename, file = nil, debug = false)
17
+ file = File.read(filename, encoding: "utf-8") if file.nil?
18
+ docxml, outname_html, dir = convert_init(file, filename, debug)
19
+ /\.xml$/.match(filename) or
20
+ filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
21
+ f.write file
22
+ f.path
44
23
  end
24
+ FileUtils.rm_rf dir
25
+ ::Metanorma::Output::XslfoPdf.new.convert(
26
+ filename, outname_html + ".pdf", File.join(@libdir, "m3d.report.xsl"))
45
27
  end
46
-
47
- def googlefonts()
48
- <<~HEAD.freeze
49
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
50
- <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
51
- HEAD
52
- end
53
-
54
- def make_body(xml, docxml)
55
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
56
- xml.body **body_attr do |body|
57
- make_body1(body, docxml)
58
- make_body2(body, docxml)
59
- make_body3(body, docxml)
60
- colophon(body, docxml)
61
- end
62
- end
63
-
64
- def html_toc(docxml)
65
- docxml
66
- end
67
-
68
- include BaseRender
69
28
  end
70
29
  end
71
30
  end
@@ -1,8 +1,8 @@
1
1
  require "asciidoctor" unless defined? Asciidoctor::Converter
2
2
  require_relative "asciidoctor/m3d/converter"
3
3
  require_relative "isodoc/m3d/html_convert"
4
- require_relative "isodoc/m3d/pdf_convert"
5
4
  require_relative "isodoc/m3d/word_convert"
5
+ require_relative "isodoc/m3d/pdf_convert"
6
6
  require_relative "metanorma/m3d/version"
7
7
 
8
8
  if defined? Metanorma
@@ -2,6 +2,14 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module M3d
5
+ def self.fonts_used
6
+ {
7
+ html: ["Overpass", "Space Mono"],
8
+ doc: ["Garamond", "Courier New"],
9
+ doc: ["Garamond", "Courier New"]
10
+ }
11
+ end
12
+
5
13
  class Processor < Metanorma::Processor
6
14
 
7
15
  def initialize
@@ -30,10 +38,10 @@ module Metanorma
30
38
  case format
31
39
  when :html
32
40
  IsoDoc::M3d::HtmlConvert.new(options).convert(outname, isodoc_node)
33
- when :pdf
34
- IsoDoc::M3d::PdfConvert.new(options).convert(outname, isodoc_node)
35
41
  when :doc
36
42
  IsoDoc::M3d::WordConvert.new(options).convert(outname, isodoc_node)
43
+ when :pdf
44
+ IsoDoc::M3d::WordConvert.new(options).convert(outname, isodoc_node)
37
45
  else
38
46
  super
39
47
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module M3d
3
- VERSION = "1.3.16"
3
+ VERSION = "1.3.21"
4
4
  end
5
5
  end
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "thread_safe"
38
38
  spec.add_dependency "uuidtools"
39
39
 
40
- spec.add_dependency "metanorma-standoc", "~> 1.3.0"
40
+ spec.add_dependency "metanorma-standoc", "~> 1.4.0"
41
41
  spec.add_dependency "isodoc", "~> 1.0.0"
42
42
 
43
43
  spec.add_development_dependency "byebug", "~> 9.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-m3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.16
4
+ version: 1.3.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.3.0
117
+ version: 1.4.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.3.0
124
+ version: 1.4.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: isodoc
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -308,11 +308,11 @@ files:
308
308
  - lib/isodoc/m3d/html/m3-logo.png
309
309
  - lib/isodoc/m3d/html/m3d.scss
310
310
  - lib/isodoc/m3d/html/scripts.html
311
- - lib/isodoc/m3d/html/scripts.pdf.html
312
311
  - lib/isodoc/m3d/html/word_m3d_intro.html
313
312
  - lib/isodoc/m3d/html/word_m3d_titlepage.html
314
313
  - lib/isodoc/m3d/html/wordstyle.scss
315
314
  - lib/isodoc/m3d/html_convert.rb
315
+ - lib/isodoc/m3d/m3d.report.xsl
316
316
  - lib/isodoc/m3d/metadata.rb
317
317
  - lib/isodoc/m3d/pdf_convert.rb
318
318
  - lib/isodoc/m3d/word_convert.rb
@@ -1,72 +0,0 @@
1
- <script>
2
- //TOC generation
3
- $('#toc').toc({
4
- 'selectors': toclevel(), //elements to use as headings
5
- 'container': 'main', //element to find all selectors in
6
- 'smoothScrolling': true, //enable or disable smooth scrolling on click
7
- 'prefix': 'toc', //prefix for anchor tags and class names
8
- 'onHighlight': function(el) {}, //called when a new section is highlighted
9
- 'highlightOnScroll': false, //add class to heading that is currently in focus
10
- 'highlightOffset': 100, //offset to trigger the next headline
11
- 'anchorName': function(i, heading, prefix) { //custom function for anchor name
12
- return prefix+i;
13
- },
14
- 'headerText': function(i, heading, $heading) { //custom function building the header-item text
15
- return $heading.text();
16
- },
17
- 'itemClass': function(i, heading, $heading, prefix) { // custom function for item class
18
- return $heading[0].tagName.toLowerCase();
19
- }
20
- });
21
-
22
- </script>
23
-
24
- <script>
25
- //TOC toggle animation
26
- $('#toggle').on('click', function(){
27
- if( $('nav').is(':visible') ) {
28
- $('nav').animate({ 'left': '-353px' }, 'slow', function(){
29
- $('nav').hide();
30
- });
31
- $('.container').animate({ 'padding-left': '31px' }, 'slow');
32
- }
33
- else {
34
- $('nav').show();
35
- $('nav').animate({ 'left': '0px' }, 'slow');
36
- $('.container').animate({ 'padding-left': '360px' }, 'slow');
37
- }
38
- });
39
- </script>
40
-
41
- <script>
42
- // Scroll to top button
43
- window.onscroll = function() {scrollFunction()};
44
-
45
- function scrollFunction() {
46
- if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
47
- document.getElementById("myBtn").style.display = "block";
48
- } else {
49
- document.getElementById("myBtn").style.display = "none";
50
- }
51
- }
52
-
53
- // When the user clicks on the button, scroll to the top of the document
54
- function topFunction() {
55
- document.body.scrollTop = 0;
56
- document.documentElement.scrollTop = 0;
57
- }
58
- </script>
59
-
60
- <script>
61
- /*
62
- $(document).ready(function() {
63
- $('[id^=toc]').each(function ()
64
- {
65
- var currentToc = $(this);
66
- var url = window.location.href;
67
- currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
68
- });
69
- });
70
- */
71
- </script>
72
-