metanorma-ieee 0.0.6.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ require "isodoc"
2
+ require "mnconvert"
3
+
4
+ module IsoDoc
5
+ module IEEE
6
+ class IEEEXMLConvert < IsoDoc::XslfoPdfConvert
7
+ def initialize(options) # rubocop:disable Lint/MissingSuper
8
+ @libdir = File.dirname(__FILE__)
9
+ @format = :ieee
10
+ @suffix = "ieee.xml"
11
+ @ieeedtd = options[:ieeedtd]
12
+ end
13
+
14
+ def inputfile(in_fname, filename)
15
+ /\.xml$/.match?(in_fname) or
16
+ in_fname = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
17
+ f.write file
18
+ f.path
19
+ end
20
+ in_fname
21
+ end
22
+
23
+ def convert(in_fname, file = nil, debug = false, out_fname = nil)
24
+ file = File.read(in_fname, encoding: "utf-8") if file.nil?
25
+ _docxml, filename, dir = convert_init(file, in_fname, debug)
26
+ in_fname = inputfile(in_fname, filename)
27
+ FileUtils.rm_rf dir
28
+ opt = { input_format: MnConvert::InputFormat::MN,
29
+ output_file: out_fname || "#{filename}.#{@suffix}",
30
+ output_format: :ieee }
31
+ @ieeedtd and opt.merge!(validation_against: @ieeedtd)
32
+ MnConvert.convert(in_fname, opt)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -6,8 +6,8 @@ require_relative "i18n"
6
6
  module IsoDoc
7
7
  module IEEE
8
8
  module Init
9
- def metadata_init(lang, script, i18n)
10
- @meta = Metadata.new(lang, script, i18n)
9
+ def metadata_init(lang, script, locale, i18n)
10
+ @meta = Metadata.new(lang, script, locale, i18n)
11
11
  end
12
12
 
13
13
  def xref_init(lang, script, _klass, i18n, options)
@@ -16,8 +16,9 @@ module IsoDoc
16
16
  @xrefs = Xref.new(lang, script, html, i18n, options)
17
17
  end
18
18
 
19
- def i18n_init(lang, script, i18nyaml = nil)
20
- @i18n = I18n.new(lang, script, i18nyaml: i18nyaml || @i18nyaml)
19
+ def i18n_init(lang, script, locale, i18nyaml = nil)
20
+ @i18n = I18n.new(lang, script, locale: locale,
21
+ i18nyaml: i18nyaml || @i18nyaml)
21
22
  end
22
23
 
23
24
  def fileloc(loc)
@@ -114,7 +114,7 @@ module IsoDoc
114
114
  para = i % 2 == 1 && i != ret.size - 2 ? "<p>&#xa0;</p>" : ""
115
115
  "<div class='WordSection'>#{para}#{d}</div>"
116
116
  end.join(SECTIONBREAK)
117
- div.document.at("//div[@class = 'WordSection11']")
117
+ div.document.at("//div[@class = 'WordSectionIntro']")
118
118
  .previous_element.previous = SECTIONBREAK + out
119
119
  end
120
120
 
@@ -88,7 +88,7 @@ module IsoDoc
88
88
  d.replace(d.children)
89
89
  i = 0
90
90
  docxml.xpath("//div[@class]").each do |div|
91
- next unless /^WordSection/.match?(div["class"])
91
+ next unless /^WordSection\d*$/.match?(div["class"])
92
92
 
93
93
  i += 1
94
94
  div["class"] = "WordSection#{i}"
@@ -57,11 +57,11 @@ module IsoDoc
57
57
  end
58
58
 
59
59
  def make_body3(body, docxml)
60
- body.div **{ class: "WordSection13" } do |_div3|
60
+ body.div **{ class: "WordSectionMiddleTitle" } do |_div3|
61
61
  middle_title_ieee(docxml, body)
62
62
  end
63
63
  section_break(body, continuous: true)
64
- body.div **{ class: "WordSection14" } do |div3|
64
+ body.div **{ class: "WordSectionMain" } do |div3|
65
65
  middle docxml, div3
66
66
  footnotes div3
67
67
  comments div3
@@ -34,11 +34,6 @@ module IsoDoc
34
34
  n = section_names(doc.at(ns("//sections/definitions")), n, 1)
35
35
  clause_names(doc, n)
36
36
  end
37
- if @parse_settings.empty?
38
- middle_section_asset_names(doc)
39
- termnote_anchor_names(doc)
40
- termexample_anchor_names(doc)
41
- end
42
37
  end
43
38
 
44
39
  def middle_sections
data/lib/isodoc/ieee.rb CHANGED
@@ -4,6 +4,7 @@ require "isodoc/ieee/html_convert"
4
4
  require "isodoc/ieee/pdf_convert"
5
5
  require "isodoc/ieee/word_convert"
6
6
  require "isodoc/ieee/presentation_xml_convert"
7
+ require "isodoc/ieee/ieee_xml_convert"
7
8
 
8
9
  module IsoDoc
9
10
  module IEEE
@@ -73,8 +73,14 @@
73
73
  <text/>
74
74
  </element>
75
75
  </define>
76
- <define name="script">
76
+ <define name="locale">
77
77
  <a:documentation>ISO-639</a:documentation>
78
+ <element name="locale">
79
+ <text/>
80
+ </element>
81
+ </define>
82
+ <define name="script">
83
+ <a:documentation>ISO-3166</a:documentation>
78
84
  <element name="script">
79
85
  <text/>
80
86
  </element>
@@ -93,6 +99,9 @@
93
99
  <!-- multiple languages and scripts possible: comma delimit them if so -->
94
100
  <attribute name="language"/>
95
101
  </optional>
102
+ <optional>
103
+ <attribute name="locale"/>
104
+ </optional>
96
105
  <optional>
97
106
  <attribute name="script"/>
98
107
  </optional>
@@ -136,6 +145,9 @@
136
145
  <!-- multiple languages and scripts possible: comma delimit them if so -->
137
146
  <attribute name="language"/>
138
147
  </optional>
148
+ <optional>
149
+ <attribute name="locale"/>
150
+ </optional>
139
151
  <optional>
140
152
  <attribute name="script"/>
141
153
  </optional>
@@ -650,6 +662,9 @@
650
662
  <zeroOrMore>
651
663
  <ref name="language"/>
652
664
  </zeroOrMore>
665
+ <zeroOrMore>
666
+ <ref name="locale"/>
667
+ </zeroOrMore>
653
668
  <zeroOrMore>
654
669
  <ref name="script"/>
655
670
  </zeroOrMore>
@@ -741,6 +756,9 @@
741
756
  <zeroOrMore>
742
757
  <ref name="language"/>
743
758
  </zeroOrMore>
759
+ <zeroOrMore>
760
+ <ref name="locale"/>
761
+ </zeroOrMore>
744
762
  <zeroOrMore>
745
763
  <ref name="script"/>
746
764
  </zeroOrMore>
@@ -854,6 +872,15 @@
854
872
  <optional>
855
873
  <attribute name="type"/>
856
874
  </optional>
875
+ <optional>
876
+ <attribute name="language"/>
877
+ </optional>
878
+ <optional>
879
+ <attribute name="locale"/>
880
+ </optional>
881
+ <optional>
882
+ <attribute name="script"/>
883
+ </optional>
857
884
  <data type="anyURI"/>
858
885
  </define>
859
886
  <define name="DateType">
@@ -882,6 +909,7 @@
882
909
  <value>vote-started</value>
883
910
  <value>vote-ended</value>
884
911
  <value>announced</value>
912
+ <value>stable-until</value>
885
913
  </choice>
886
914
  </define>
887
915
  <define name="bdate">
@@ -930,6 +958,9 @@
930
958
  <optional>
931
959
  <attribute name="language"/>
932
960
  </optional>
961
+ <optional>
962
+ <attribute name="locale"/>
963
+ </optional>
933
964
  <optional>
934
965
  <attribute name="script"/>
935
966
  </optional>
@@ -117,7 +117,7 @@ module Metanorma
117
117
  x = xmldoc.dup
118
118
  x.root.add_namespace(nil, self.class::XML_NAMESPACE)
119
119
  xml = Nokogiri::XML(x.to_xml)
120
- i = isodoc(@lang, @script)
120
+ i = isodoc(@lang, @script, @locale)
121
121
  i.bibdata_i18n(xml.at("//xmlns:bibdata"))
122
122
  i.info(xml, nil)
123
123
  i
@@ -47,9 +47,9 @@ module Metanorma
47
47
  else
48
48
  bib1 = bib.dup
49
49
  bib1.add_namespace(nil, self.class::XML_NAMESPACE)
50
- i = IsoDoc::IEEE::PresentationXMLConvert.new({ lang: @lang,
51
- script: @script })
52
- i.i18n_init(@lang, @script)
50
+ i = IsoDoc::IEEE::PresentationXMLConvert
51
+ .new({ lang: @lang, script: @script, locale: @locale })
52
+ i.i18n_init(@lang, @script, @locale)
53
53
  i.creatornames(bib1)
54
54
  end
55
55
  end
@@ -60,7 +60,8 @@ module Metanorma
60
60
 
61
61
  def html_extract_attributes(node)
62
62
  super.merge(hierarchical_assets:
63
- node.attr("hierarchical-object-numbering"))
63
+ node.attr("hierarchical-object-numbering"),
64
+ ieeedtd: node.attr("ieee-dtd"))
64
65
  end
65
66
 
66
67
  def doc_extract_attributes(node)
@@ -78,12 +79,20 @@ module Metanorma
78
79
  end
79
80
 
80
81
  def pdf_converter(node)
82
+ return nil if node.attr("no-pdf")
83
+
81
84
  IsoDoc::IEEE::PdfConvert.new(pdf_extract_attributes(node))
82
85
  end
83
86
 
84
87
  def doc_converter(node)
85
88
  IsoDoc::IEEE::WordConvert.new(doc_extract_attributes(node))
86
89
  end
90
+
91
+ def ieee_xml_converter(node)
92
+ return nil if node.attr("no-pdf")
93
+
94
+ IsoDoc::Iso::IEEEXMLConvert.new(html_extract_attributes(node))
95
+ end
87
96
  end
88
97
  end
89
98
  end
@@ -205,6 +205,15 @@
205
205
  <data type="boolean"/>
206
206
  </attribute>
207
207
  </optional>
208
+ <optional>
209
+ <attribute name="style">
210
+ <choice>
211
+ <value>basic</value>
212
+ <value>full</value>
213
+ <value>short</value>
214
+ </choice>
215
+ </attribute>
216
+ </optional>
208
217
  <ref name="XrefBody"/>
209
218
  </element>
210
219
  </define>
@@ -14,6 +14,7 @@ module Metanorma
14
14
  html: "html",
15
15
  doc: "doc",
16
16
  pdf: "pdf",
17
+ ieee: "ieee.xml",
17
18
  )
18
19
  end
19
20
 
@@ -47,6 +48,9 @@ module Metanorma
47
48
  IsoDoc::IEEE::PresentationXMLConvert.new(options).convert(
48
49
  inname, isodoc_node, nil, outname
49
50
  )
51
+ when :ieee
52
+ IsoDoc::IEEE::IEEEXMLConvert.new(options)
53
+ .convert(inname, isodoc_node, nil, outname)
50
54
  else
51
55
  super
52
56
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "0.0.6.1".freeze
3
+ VERSION = "0.1.0".freeze
4
4
  end
5
5
  end
@@ -2,6 +2,7 @@ require "metanorma/ieee"
2
2
  require "asciidoctor"
3
3
  require "isodoc/ieee"
4
4
  require "html2doc/ieee"
5
+ require "metanorma"
5
6
 
6
7
  if defined? Metanorma::Registry
7
8
  Metanorma::Registry.instance.register(Metanorma::IEEE::Processor)
@@ -5,7 +5,7 @@ nametemplate:
5
5
  extenttemplate:
6
6
  misc: "{{ volume }}, {{issue}}, {{ page }}, {{ duration }}"
7
7
  template:
8
- # skip standardidentifier, it is inserted in front of formattedref within metanorma
8
+ # skip authoritative_identifier, it is inserted in front of formattedref within metanorma
9
9
  standard: "{{ title }}."
10
10
  techreport: standard
11
11
  article: "{{creatornames}}, “{{title}},” <em>{{ series }}</em>, {{ extent }}, {{ date }}, {{ labels['viewed'] }}_{{date_accessed}}, {{ uri }} ."
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
26
26
 
27
- spec.add_dependency "metanorma-standoc", "~> 2.2.0"
27
+ spec.add_dependency "metanorma-standoc", "~> 2.2.4"
28
+ spec.add_dependency "mnconvert", "~> 1.20"
28
29
 
29
30
  spec.add_development_dependency "debug"
30
31
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-07 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.0
19
+ version: 2.2.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.0
26
+ version: 2.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: mnconvert
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.20'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.20'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: debug
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -207,6 +221,7 @@ files:
207
221
  - ".rubocop.yml"
208
222
  - CODE_OF_CONDUCT.md
209
223
  - Gemfile
224
+ - Gemfile.devel
210
225
  - LICENSE
211
226
  - README.adoc
212
227
  - Rakefile
@@ -237,6 +252,7 @@ files:
237
252
  - lib/isodoc/ieee/ieee.amendment.xsl
238
253
  - lib/isodoc/ieee/ieee.rb
239
254
  - lib/isodoc/ieee/ieee.standard.xsl
255
+ - lib/isodoc/ieee/ieee_xml_convert.rb
240
256
  - lib/isodoc/ieee/init.rb
241
257
  - lib/isodoc/ieee/metadata.rb
242
258
  - lib/isodoc/ieee/pdf_convert.rb