metanorma-ogc 2.0.4 → 2.0.7

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.
@@ -12,11 +12,16 @@ module IsoDoc
12
12
  super
13
13
  end
14
14
 
15
- def insert_preface_sections(docxml)
16
- insert_executivesummary(docxml)
17
- insert_submitting_orgs(docxml)
18
- insert_security(docxml)
19
- insert_keywords(docxml)
15
+ def insert_preface_sections(doc)
16
+ preface_insert(doc&.at(ns("//preface/clause"\
17
+ "[@type = 'executivesummary']")),
18
+ doc.at(ns("//preface/abstract")), doc)
19
+ preface_insert(doc&.at(ns("//preface//submitters")),
20
+ submit_orgs_append_pt(doc), doc)
21
+ insert_submitting_orgs(doc)
22
+ preface_insert(doc&.at(ns("//preface/clause[@type = 'security']")),
23
+ submit_orgs_append_pt(doc), doc)
24
+ insert_keywords(doc)
20
25
  end
21
26
 
22
27
  def preface_init_insert_pt(docxml)
@@ -25,31 +30,22 @@ module IsoDoc
25
30
  .add_previous_sibling("<preface> </preface>").first
26
31
  end
27
32
 
28
- def submit_orgs_append_pt(docxml)
29
- docxml.at(ns("//introduction")) ||
30
- docxml.at(ns("//foreword")) ||
31
- docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
32
- docxml.at(ns("//preface/abstract"))
33
- end
33
+ def preface_insert(clause, after, docxml)
34
+ return unless clause
34
35
 
35
- def insert_security(docxml)
36
- s = docxml&.at(ns("//preface/clause[@type = 'security']"))&.remove or
37
- return
38
- if a = submit_orgs_append_pt(docxml) then a.next = s
36
+ clause.remove
37
+ if after then after.next = clause
39
38
  else
40
39
  preface_init_insert_pt(docxml)&.children&.first
41
- &.add_previous_sibling(s)
40
+ &.add_previous_sibling(clause)
42
41
  end
43
42
  end
44
43
 
45
- def insert_executivesummary(docxml)
46
- s = docxml&.at(ns("//preface/clause[@type = 'executivesummary']"))
47
- &.remove or return
48
- if a = docxml.at(ns("//preface/abstract")) then a.next = s
49
- else
50
- preface_init_insert_pt(docxml)&.children&.first
51
- &.add_previous_sibling(s)
52
- end
44
+ def submit_orgs_append_pt(docxml)
45
+ docxml.at(ns("//foreword")) ||
46
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
47
+ docxml.at(ns("//preface/clause[@type = 'executivesummary']")) ||
48
+ docxml.at(ns("//preface/abstract"))
53
49
  end
54
50
 
55
51
  def insert_submitting_orgs(docxml)
@@ -64,87 +64,11 @@ module IsoDoc
64
64
  end
65
65
  end
66
66
 
67
- def insert_toc(intro, docxml, level)
68
- toc = ""
69
- toc += make_WordToC(docxml, level)
70
- if docxml.at("//p[@class = 'TableTitle']")
71
- toc += %{<p class="TOCTitle">List of Tables</p>}
72
- toc += make_TableWordToC(docxml)
73
- end
74
- if docxml.at("//p[@class = 'FigureTitle']")
75
- toc += %{<p class="TOCTitle">List of Figures</p>}
76
- toc += make_FigureWordToC(docxml)
77
- end
78
- if docxml.at("//p[@class = 'RecommendationTitle']")
79
- toc += %{<p class="TOCTitle">List of Recommendations</p>}
80
- toc += make_RecommendationWordToC(docxml)
81
- end
82
- intro.sub(/WORDTOC/, toc)
83
- end
84
-
85
- WORD_TOC_RECOMMENDATION_PREFACE1 = <<~TOC.freeze
86
- <span lang="EN-GB"><span
87
- style='mso-element:field-begin'></span><span
88
- style='mso-spacerun:yes'>&#xA0;</span>TOC
89
- \\h \\z \\t &quot;RecommendationTitle,RecommendationTestTitle,recommendationtitle,recommendationtesttitle&quot;#{' '}
90
- <span style='mso-element:field-separator'></span></span>
91
- TOC
92
-
93
- WORD_TOC_TABLE_PREFACE1 = <<~TOC.freeze
94
- <span lang="EN-GB"><span
95
- style='mso-element:field-begin'></span><span
96
- style='mso-spacerun:yes'>&#xA0;</span>TOC
97
- \\h \\z \\t &quot;TableTitle,tabletitle&quot; <span
98
- style='mso-element:field-separator'></span></span>
99
- TOC
100
-
101
- WORD_TOC_FIGURE_PREFACE1 = <<~TOC.freeze
102
- <span lang="EN-GB"><span
103
- style='mso-element:field-begin'></span><span
104
- style='mso-spacerun:yes'>&#xA0;</span>TOC
105
- \\h \\z \\t &quot;FigureTitle,figuretitle&quot; <span
106
- style='mso-element:field-separator'></span></span>
107
- TOC
108
-
109
- def header_strip(h)
110
- h = h.to_s.gsub(/<\/?p[^>]*>/, "")
67
+ def header_strip(hdr)
68
+ hdr = hdr.to_s.gsub(/<\/?p[^>]*>/, "")
111
69
  super
112
70
  end
113
71
 
114
- def make_TableWordToC(docxml)
115
- toc = ""
116
- docxml.xpath("//p[@class = 'TableTitle']").each do |h|
117
- toc += word_toc_entry(1, header_strip(h))
118
- end
119
- toc.sub(/(<p class="MsoToc1">)/,
120
- %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
121
- end
122
-
123
- def make_FigureWordToC(docxml)
124
- toc = ""
125
- docxml.xpath("//p[@class = 'FigureTitle']").each do |h|
126
- toc += word_toc_entry(1, header_strip(h))
127
- end
128
- toc.sub(/(<p class="MsoToc1">)/,
129
- %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
130
- end
131
-
132
- def make_RecommendationWordToC(docxml)
133
- toc = ""
134
- docxml.xpath("//p[@class = 'RecommendationTitle' or @class = 'RecommendationTestTitle']").sort_by do |h|
135
- recommmendation_sort_key(h.text)
136
- end.each do |h|
137
- toc += word_toc_entry(1, header_strip(h))
138
- end
139
- toc.sub(/(<p class="MsoToc1">)/,
140
- %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
141
- end
142
-
143
- def recommmendation_sort_key(header)
144
- m = /^([^0-9]+) (\d+)/.match(header) || /^([^:]+)/.match(header)
145
- "#{recommmendation_sort_key1(m[1])}::#{'%04d' % m[2].to_i}"
146
- end
147
-
148
72
  def recommmendation_sort_key1(type)
149
73
  case type.downcase
150
74
  when "requirements class" then "01"
@@ -150,9 +150,9 @@ module IsoDoc
150
150
  @prefacenum = 0
151
151
  ["//preface/abstract", "//preface/clause[@type = 'executivesummary']",
152
152
  "//preface/clause[@type = 'keywords']",
153
- "//foreword", "//introduction", "//preface/clause[@type = 'security']",
154
- "//preface/clause[@type = 'submitting_orgs']",
155
- "//submitters"].each do |path|
153
+ "//foreword", "//preface/clause[@type = 'security']",
154
+ "//preface/clause[@type = 'submitting_orgs']", "//submitters",
155
+ "//introduction"].each do |path|
156
156
  preface_names_numbered(doc.at(ns(path)))
157
157
  end
158
158
  doc.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
@@ -182,7 +182,7 @@ module IsoDoc
182
182
  @prefacenum += 1
183
183
  pref = preface_number(@prefacenum, 1)
184
184
  @anchors[clause["id"]] =
185
- { label: pref,
185
+ { label: pref,
186
186
  level: 1, xref: preface_clause_name(clause), type: "clause" }
187
187
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
188
188
  preface_names_numbered1(c, "#{pref}.#{preface_number(i + 1, 2)}", 2)
@@ -16,6 +16,13 @@ module Metanorma
16
16
 
17
17
  register_for "ogc"
18
18
 
19
+ def init_toc(node)
20
+ super
21
+ @tocfigures = true
22
+ @toctables = true
23
+ @tocrecommendations = true
24
+ end
25
+
19
26
  # ignore, we generate ToC outside of asciidoctor
20
27
  def toc(value); end
21
28
 
@@ -4,7 +4,7 @@ module Metanorma
4
4
  module Ogc
5
5
  class Processor < Metanorma::Processor
6
6
 
7
- def initialize
7
+ def initialize # rubocop:disable Lint/MissingSuper
8
8
  @short = :ogc
9
9
  @input_format = :asciidoc
10
10
  @asciidoctor_backend = :ogc
@@ -14,7 +14,7 @@ module Metanorma
14
14
  super.merge(
15
15
  html: "html",
16
16
  doc: "doc",
17
- pdf: "pdf"
17
+ pdf: "pdf",
18
18
  )
19
19
  end
20
20
 
@@ -41,14 +41,14 @@ module Metanorma
41
41
 
42
42
  def output(isodoc_node, inname, outname, format, options={})
43
43
  case format
44
- when :html
45
- IsoDoc::Ogc::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
46
- when :doc
47
- IsoDoc::Ogc::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
48
- when :pdf
49
- IsoDoc::Ogc::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
50
- when :presentation
51
- IsoDoc::Ogc::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
44
+ when :html then IsoDoc::Ogc::HtmlConvert.new(options)
45
+ .convert(inname, isodoc_node, nil, outname)
46
+ when :doc then IsoDoc::Ogc::WordConvert.new(options)
47
+ .convert(inname, isodoc_node, nil, outname)
48
+ when :pdf then IsoDoc::Ogc::PdfConvert.new(options)
49
+ .convert(inname, isodoc_node, nil, outname)
50
+ when :presentation then IsoDoc::Ogc::PresentationXMLConvert.new(options)
51
+ .convert(inname, isodoc_node, nil, outname)
52
52
  else
53
53
  super
54
54
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "2.0.4".freeze
3
+ VERSION = "2.0.7".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.7
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-02-21 00:00:00.000000000 Z
11
+ date: 2022-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  requirements: []
288
- rubygems_version: 3.2.32
288
+ rubygems_version: 3.3.9
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: Metanorma for the Open Geospatial Consortium.