metanorma-mpfd 0.3.21 → 0.3.23

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -0
  3. data/Gemfile +1 -8
  4. data/README.adoc +1 -96
  5. data/lib/asciidoctor/mpfd/biblio.rng +166 -567
  6. data/lib/asciidoctor/mpfd/converter.rb +84 -7
  7. data/lib/asciidoctor/mpfd/isodoc.rng +727 -763
  8. data/lib/asciidoctor/mpfd/isostandard.rng +1054 -0
  9. data/lib/asciidoctor/mpfd/mpfd.rng +145 -11
  10. data/lib/asciidoctor/mpfd/pdf.js +31 -0
  11. data/lib/asciidoctor/mpfd/section.rb +51 -23
  12. data/lib/asciidoctor/mpfd.rb +1 -0
  13. data/lib/isodoc/mpfd/html/header.html +6 -64
  14. data/lib/isodoc/mpfd/html/html_rsd_titlepage.html +4 -4
  15. data/lib/isodoc/mpfd/html/htmlstyle.scss +505 -200
  16. data/lib/isodoc/mpfd/html/rsd.scss +30 -149
  17. data/lib/isodoc/mpfd/html/scripts.html +27 -25
  18. data/lib/isodoc/mpfd/html/scripts.pdf.html +70 -0
  19. data/lib/isodoc/mpfd/html/word_rsd_titlepage.html +2 -2
  20. data/lib/isodoc/mpfd/html/wordstyle.scss +9 -61
  21. data/lib/isodoc/mpfd/html_convert.rb +258 -4
  22. data/lib/isodoc/mpfd/i18n-en.yaml +0 -1
  23. data/lib/isodoc/mpfd/metadata.rb +32 -8
  24. data/lib/isodoc/mpfd/{base_convert.rb → pdf_convert.rb} +137 -40
  25. data/lib/isodoc/mpfd/word_convert.rb +292 -4
  26. data/lib/metanorma/mpfd/processor.rb +4 -8
  27. data/lib/metanorma/mpfd/version.rb +1 -1
  28. data/lib/metanorma-mpfd.rb +1 -0
  29. data/metanorma-mpfd.gemspec +8 -7
  30. metadata +66 -33
  31. data/.github/workflows/macos.yml +0 -39
  32. data/.github/workflows/ubuntu.yml +0 -53
  33. data/.github/workflows/windows.yml +0 -41
  34. data/.hound.yml +0 -3
  35. data/.rubocop.yml +0 -10
  36. data/lib/asciidoctor/mpfd/basicdoc.rng +0 -1059
  37. data/lib/asciidoctor/mpfd/reqt.rng +0 -171
  38. data/lib/asciidoctor/mpfd/validate.rb +0 -30
  39. data/lib/isodoc/mpfd/i18n-zh-Hans.yaml +0 -2
@@ -5,7 +5,6 @@ require "isodoc/mpfd/html_convert"
5
5
  require "isodoc/mpfd/word_convert"
6
6
  require_relative "section"
7
7
  require "fileutils"
8
- require_relative "./validate"
9
8
 
10
9
  module Asciidoctor
11
10
  module Mpfd
@@ -14,8 +13,6 @@ module Asciidoctor
14
13
  # schema encapsulation of the document for validation
15
14
  #
16
15
  class Converter < Standoc::Converter
17
- XML_ROOT_TAG = "mpfd-standard".freeze
18
- XML_NAMESPACE = "https://www.metanorma.org/ns/mpfd".freeze
19
16
 
20
17
  register_for "mpfd"
21
18
 
@@ -40,7 +37,6 @@ module Asciidoctor
40
37
  end
41
38
 
42
39
  def metadata_committee(node, xml)
43
- return unless node.attr("committee")
44
40
  xml.editorialgroup do |a|
45
41
  a.committee node.attr("committee"),
46
42
  **attr_code(type: node.attr("committee-type"))
@@ -53,9 +49,20 @@ module Asciidoctor
53
49
  end
54
50
  end
55
51
 
52
+ def title(node, xml)
53
+ ["en"].each do |lang|
54
+ xml.title **{ language: lang, format: "plain" } do |t|
55
+ t << asciidoc_sub(node.attr("title"))
56
+ end
57
+ end
58
+ end
59
+
60
+ def metadata_status(node, xml)
61
+ xml.status(**{ format: "plain" }) { |s| s << node.attr("status") }
62
+ end
63
+
56
64
  def metadata_id(node, xml)
57
65
  xml.docidentifier { |i| i << node.attr("docnumber") }
58
- xml.docnumber { |i| i << node.attr("docnumber") }
59
66
  end
60
67
 
61
68
  def metadata_copyright(node, xml)
@@ -76,8 +83,34 @@ module Asciidoctor
76
83
  end
77
84
 
78
85
  def makexml(node)
86
+ result = ["<?xml version='1.0' encoding='UTF-8'?>\n<mpfd-standard>"]
79
87
  @draft = node.attributes.has_key?("draft")
80
- super
88
+ result << noko { |ixml| front node, ixml }
89
+ result << noko { |ixml| middle node, ixml }
90
+ result << "</mpfd-standard>"
91
+ result = textcleanup(result.flatten * "\n")
92
+ ret1 = cleanup(Nokogiri::XML(result))
93
+ validate(ret1)
94
+ ret1.root.add_namespace(nil, MPFD_NAMESPACE)
95
+ ret1
96
+ end
97
+
98
+ def doctype(node)
99
+ d = node.attr("doctype")
100
+ =begin
101
+ unless %w{policy-and-procedures best-practices circular supporting-document report legal directives proposal standard}.include? d
102
+ warn "#{d} is not a legal document type: reverting to 'standard'"
103
+ d = "standard"
104
+ end
105
+ =end
106
+ d
107
+ end
108
+
109
+ def pdf_convert(filename)
110
+ url = "#{Dir.pwd}/#{filename}.html"
111
+ pdfjs = File.join(File.dirname(__FILE__), 'pdf.js')
112
+ system "export NODE_PATH=$(npm root --quiet -g);
113
+ node #{pdfjs} file://#{url} #{filename}.pdf"
81
114
  end
82
115
 
83
116
  def document(node)
@@ -90,8 +123,8 @@ module Asciidoctor
90
123
  File.open(filename, "w") { |f| f.write(ret) }
91
124
  html_converter(node).convert filename unless node.attr("nodoc")
92
125
  word_converter(node).convert filename unless node.attr("nodoc")
126
+ pdf_convert(filename.sub(/\.xml$/, "")) unless node.attr("nodoc")
93
127
  end
94
- @log.write(@localdir + @filename + ".err") unless @novalid
95
128
  @files_to_delete.each { |f| FileUtils.rm f }
96
129
  ret
97
130
  end
@@ -102,6 +135,26 @@ module Asciidoctor
102
135
  File.join(File.dirname(__FILE__), "mpfd.rng"))
103
136
  end
104
137
 
138
+ def rsd_html_path(file)
139
+ File.join(File.dirname(__FILE__), File.join("html", file))
140
+ end
141
+
142
+ def literal(node)
143
+ noko do |xml|
144
+ xml.figure **id_attr(node) do |f|
145
+ figure_title(node, f)
146
+ f.pre node.lines.join("\n")
147
+ end
148
+ end
149
+ end
150
+
151
+ def sections_cleanup(x)
152
+ super
153
+ x.xpath("//*[@inline-header]").each do |h|
154
+ h.delete("inline-header")
155
+ end
156
+ end
157
+
105
158
  def style(n, t)
106
159
  return
107
160
  end
@@ -113,6 +166,30 @@ module Asciidoctor
113
166
  def word_converter(node)
114
167
  IsoDoc::Mpfd::WordConvert.new(doc_extract_attributes(node))
115
168
  end
169
+
170
+ def inline_quoted(node)
171
+ noko do |xml|
172
+ case node.type
173
+ when :emphasis then xml.em node.text
174
+ when :strong then xml.strong node.text
175
+ when :monospaced then xml.tt node.text
176
+ when :double then xml << "\"#{node.text}\""
177
+ when :single then xml << "'#{node.text}'"
178
+ when :superscript then xml.sup node.text
179
+ when :subscript then xml.sub node.text
180
+ when :asciimath then stem_parse(node.text, xml)
181
+ else
182
+ case node.role
183
+ when "strike" then xml.strike node.text
184
+ when "smallcap" then xml.smallcap node.text
185
+ when "keyword" then xml.keyword node.text
186
+ else
187
+ xml << node.text
188
+ end
189
+ end
190
+ end.join
191
+ end
192
+
116
193
  end
117
194
  end
118
195
  end