metanorma-ieee 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -106,6 +106,59 @@ module Metanorma
106
106
  end
107
107
  end
108
108
  ret.map { |x| x.is_a?(Array) ? x : [] }
109
+ end
110
+
111
+ def title_validate(xml)
112
+ title_validate_type(xml)
113
+ title_validate_capitalisation(xml)
114
+ end
115
+
116
+ # Style Manual 11.3
117
+ def title_validate_type(xml)
118
+ title = xml.at("//bibdata/title") or return
119
+ draft = xml.at("//bibdata//draft")
120
+ type = xml.at("//bibdata/ext/doctype")
121
+ subtype = xml.at("//bibdata/ext/subdoctype")
122
+ subtype = "" if subtype == "document"
123
+ trial = xml.at("//bibdata/ext/trial-use[text() = 'true']")
124
+ target = draft ? "Draft " : ""
125
+ target += trial ? "Trial-Use " : ""
126
+ target += type ? "#{strict_capitalize_phrase(type.text)} " : ""
127
+ /^#{target}/.match?(title.text) or
128
+ @log.add("Style", title,
129
+ "Expected title to start as: #{target}")
130
+ end
131
+
132
+ def strict_capitalize_phrase(str)
133
+ ret = str.split(/[ -]/).map do |w|
134
+ letters = w.chars
135
+ letters.first.upcase! unless /^[ -]/.match?(w)
136
+ letters.join
137
+ end.join(" ")
138
+ ret = "Trial-Use" if ret == "Trial Use"
139
+ ret
140
+ end
141
+
142
+ # Style Manual 11.3
143
+ def title_validate_capitalisation(xml)
144
+ title = xml.at("//bibdata/title") or return
145
+ found = false
146
+ title.text.split(/[ -]/).each do |w|
147
+ /^[[:upper:]]/.match?(w) or preposition?(w) or
148
+ found = true
149
+ end
150
+ found and @log.add("Style", title,
151
+ "Title contains uncapitalised word other than preposition")
152
+ end
153
+
154
+ def preposition?(word)
155
+ %w(aboard about above across after against along amid among anti around
156
+ as at before behind below beneath beside besides between beyond but
157
+ by concerning considering despite down during except excepting
158
+ excluding following for from in inside into like minus near of off
159
+ on onto opposite outside over past per plus regarding round save
160
+ since than through to toward towards under underneath unlike until
161
+ up upon versus via with within without a an the).include?(word)
109
162
  end
110
163
  end
111
164
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "0.0.2".freeze
3
+ VERSION = "0.0.3".freeze
4
4
  end
5
5
  end
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.2
4
+ version: 0.0.3
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-07-04 00:00:00.000000000 Z
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -217,6 +217,7 @@ files:
217
217
  - lib/isodoc/ieee.rb
218
218
  - lib/isodoc/ieee/base_convert.rb
219
219
  - lib/isodoc/ieee/html/header.html
220
+ - lib/isodoc/ieee/html/header_amd.html
220
221
  - lib/isodoc/ieee/html/html_ieee_intro.html
221
222
  - lib/isodoc/ieee/html/html_ieee_titlepage.html
222
223
  - lib/isodoc/ieee/html/htmlstyle.css
@@ -237,6 +238,7 @@ files:
237
238
  - lib/isodoc/ieee/init.rb
238
239
  - lib/isodoc/ieee/metadata.rb
239
240
  - lib/isodoc/ieee/pdf_convert.rb
241
+ - lib/isodoc/ieee/presentation_ref.rb
240
242
  - lib/isodoc/ieee/presentation_terms.rb
241
243
  - lib/isodoc/ieee/presentation_xml_convert.rb
242
244
  - lib/isodoc/ieee/word_authority.rb
@@ -257,6 +259,7 @@ files:
257
259
  - lib/metanorma/ieee/isodoc.rng
258
260
  - lib/metanorma/ieee/processor.rb
259
261
  - lib/metanorma/ieee/reqt.rng
262
+ - lib/metanorma/ieee/term_lookup_cleanup.rb
260
263
  - lib/metanorma/ieee/validate.rb
261
264
  - lib/metanorma/ieee/validate_section.rb
262
265
  - lib/metanorma/ieee/validate_style.rb