metanorma-iso 3.5.44 → 3.5.45
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.
- checksums.yaml +4 -4
- data/TODO.docx/P0-005-word-unreadable-content.md +3 -1
- data/TODO.docx/P3-007-verify-word-opens.md +4 -1
- data/lib/isodoc/iso/docx/adapter.rb +7 -0
- data/lib/isodoc/iso/docx/core_properties_builder.rb +6 -9
- data/lib/isodoc/iso/docx/custom_xml_items.rb +129 -0
- data/lib/metanorma/iso/log.rb +0 -2
- data/lib/metanorma/iso/validation/rules/base.rb +22 -9
- data/lib/metanorma/iso/validation/rules/style_a_or_an_rule.rb +5 -4
- data/lib/metanorma/iso/validation/rules/style_rule.rb +16 -2
- data/lib/metanorma/iso/validation/rules.rb +0 -2
- data/lib/metanorma/iso/validation_policy/metanorma.yml +0 -2
- data/lib/metanorma/iso/version.rb +1 -1
- metadata +2 -2
- data/lib/metanorma/iso/validation/rules/style_abbrev_articles_rule.rb +0 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68d4d7985745cdc876ef1ab8da1d0bc2e3e391a4f9f77715addb58b62ecf2a5e
|
|
4
|
+
data.tar.gz: 8cd58295fc5834b7a2c614c0a4b8503d65a215733b6d75de4c8c3ef28a76ceab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e007c1d7110b5d1fc609793d09dfaba60f769bed723f6ce8a5a78e37b87280a038567ba904ce0371f1fe98922f3b4c2ff70003d91394e7151025166b9ac9c1c0
|
|
7
|
+
data.tar.gz: 2619cc1eafae85dd5d3149d90a46ffe6f0dff2ae37421cfce1cb720fdde62ca2f97b1b085248de48f701dd2c3f7840cc17717c5cf2dd730e19cd25322b071519
|
|
@@ -49,7 +49,9 @@ the documented one-process render (metanorma-iso v3.5.42 worktree, deps in
|
|
|
49
49
|
other files … update the fields?" yes/no prompt on open. It is the
|
|
50
50
|
deliberate `w:updateFields` set by the ToC builder so Word refreshes
|
|
51
51
|
cached ToC page numbers; answering Yes refreshes, No keeps them. It is
|
|
52
|
-
not the corrupt-file dialog.
|
|
52
|
+
not the corrupt-file dialog. (Superseded in 3.5.44: `w:updateFields` is
|
|
53
|
+
dropped outright — c2f4e88e — Word auto-evaluates the ToC's PAGEREF
|
|
54
|
+
fields during on-open pagination either way, so the prompt is gone.)
|
|
53
55
|
|
|
54
56
|
### Strict OOXML (transitional schema) findings — none Word-blocking
|
|
55
57
|
|
|
@@ -44,7 +44,10 @@ Generated: `data/rice_fixed9.docx`
|
|
|
44
44
|
may refer to other files. Do you want to update the fields in this
|
|
45
45
|
document?" — driven by the deliberate `w:updateFields` from the ToC
|
|
46
46
|
builder so Word refreshes cached ToC page numbers. Not a corruption
|
|
47
|
-
warning; answering either way opens the document.
|
|
47
|
+
warning; answering either way opens the document. (Superseded in
|
|
48
|
+
3.5.44: `w:updateFields` is dropped outright — c2f4e88e — because Word
|
|
49
|
+
auto-evaluates the ToC's PAGEREF fields during on-open pagination with
|
|
50
|
+
or without the flag, so the prompt no longer appears at all.)
|
|
48
51
|
- Test-placement caveat for future manual runs: do not open test
|
|
49
52
|
artifacts from `/tmp` — after answering Yes, macOS asks Word to grant
|
|
50
53
|
access to /tmp, which Word cannot. Use a user folder (the baselines
|
|
@@ -5,6 +5,7 @@ require "metanorma/document"
|
|
|
5
5
|
# Resolves to the canonical copy in lib/metanorma/iso/document.rb (this gem's
|
|
6
6
|
# lib precedes metanorma-document's lib in $LOAD_PATH).
|
|
7
7
|
require "metanorma/iso/document"
|
|
8
|
+
require_relative "custom_xml_items"
|
|
8
9
|
|
|
9
10
|
module IsoDoc
|
|
10
11
|
module Iso
|
|
@@ -116,6 +117,7 @@ module IsoDoc
|
|
|
116
117
|
visit_root(doc_model, doc)
|
|
117
118
|
apply_custom_properties(doc_model, doc)
|
|
118
119
|
apply_core_properties(doc_model, doc)
|
|
120
|
+
apply_custom_xml(doc) unless mhtml_output?(output_path)
|
|
119
121
|
save_document(doc.model, output_path)
|
|
120
122
|
end
|
|
121
123
|
|
|
@@ -126,6 +128,7 @@ module IsoDoc
|
|
|
126
128
|
visit_root(model, doc)
|
|
127
129
|
apply_custom_properties(model, doc)
|
|
128
130
|
apply_core_properties(model, doc)
|
|
131
|
+
apply_custom_xml(doc) unless mhtml_output?(output_path)
|
|
129
132
|
save_document(doc.model, output_path)
|
|
130
133
|
end
|
|
131
134
|
|
|
@@ -648,6 +651,10 @@ module IsoDoc
|
|
|
648
651
|
doc.model.core_properties = CorePropertiesBuilder.new(model).build
|
|
649
652
|
end
|
|
650
653
|
|
|
654
|
+
def apply_custom_xml(doc)
|
|
655
|
+
CustomXmlItems.new.apply(doc.model)
|
|
656
|
+
end
|
|
657
|
+
|
|
651
658
|
# ── Root-level visitors ────────────────────────────────────────
|
|
652
659
|
#
|
|
653
660
|
# The document has three sections with different page numbering:
|
|
@@ -12,7 +12,7 @@ module IsoDoc
|
|
|
12
12
|
#
|
|
13
13
|
# Properties set:
|
|
14
14
|
# dc:title — composed English title (intro/main/part)
|
|
15
|
-
# dc:creator —
|
|
15
|
+
# dc:creator — organization abbreviation or name
|
|
16
16
|
# cp:lastModifiedBy — same as dc:creator
|
|
17
17
|
# cp:revision — version draft number from bibdata (defaults to "1")
|
|
18
18
|
# dcterms:created — first created/published/issued date from bibdata
|
|
@@ -60,7 +60,7 @@ module IsoDoc
|
|
|
60
60
|
org = copyright_owner_organization ||
|
|
61
61
|
contributor_organization_with_role("publisher") ||
|
|
62
62
|
contributor_organization_with_role("author")
|
|
63
|
-
|
|
63
|
+
org_label(org, :abbreviation) || org_label(org, :name) || DEFAULT_CREATOR
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Word refuses to open a package whose cp:revision is not a
|
|
@@ -124,14 +124,11 @@ module IsoDoc
|
|
|
124
124
|
role.to_s == expected
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
def
|
|
128
|
-
return nil unless org
|
|
129
|
-
return nil unless org.class.attributes.key?(:name)
|
|
127
|
+
def org_label(org, attribute)
|
|
128
|
+
return nil unless org && org.class.attributes.key?(attribute)
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
extract_string(names.first)
|
|
130
|
+
value = extract_string(Array(org.public_send(attribute)).first)
|
|
131
|
+
value unless value.to_s.strip.empty?
|
|
135
132
|
end
|
|
136
133
|
|
|
137
134
|
def bibdate_of_type(type_name)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
module IsoDoc
|
|
6
|
+
module Iso
|
|
7
|
+
module Docx
|
|
8
|
+
# The four custom XML stores used by the classic ISO OSD format.
|
|
9
|
+
class CustomXmlItems
|
|
10
|
+
TYPEFI = "http://www.typefi.com"
|
|
11
|
+
METADATA = "http://schemas.microsoft.com/office/2006/metadata"
|
|
12
|
+
PROPERTIES = "#{METADATA}/properties".freeze
|
|
13
|
+
FORMS = "http://schemas.microsoft.com/sharepoint/v3/contenttype/forms"
|
|
14
|
+
CONTENT_TYPE = "#{METADATA}/contentType".freeze
|
|
15
|
+
OFFICE = "http://schemas.openxmlformats.org/officeDocument/2006"
|
|
16
|
+
BIBLIOGRAPHY = "#{OFFICE}/bibliography".freeze
|
|
17
|
+
REL_TYPE = "#{OFFICE}/relationships/customXml".freeze
|
|
18
|
+
XSD = "http://www.w3.org/2001/XMLSchema"
|
|
19
|
+
|
|
20
|
+
class TypefiNamespace < Lutaml::Xml::Namespace
|
|
21
|
+
uri TYPEFI
|
|
22
|
+
prefix_default "t"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class BibliographySources < Uniword::Bibliography::Sources
|
|
26
|
+
xml do
|
|
27
|
+
namespace_scope [{ namespace: TypefiNamespace, declare: :always }]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def apply(document)
|
|
32
|
+
document.custom_xml_items = build
|
|
33
|
+
document.allocator ||= Uniword::Docx::IdAllocator.new
|
|
34
|
+
document.custom_xml_items.each do |item|
|
|
35
|
+
document.allocator.alloc_rid(target: "/#{item.path}", type: REL_TYPE)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def build
|
|
42
|
+
payloads = [
|
|
43
|
+
[document_management, [PROPERTIES]],
|
|
44
|
+
[form_templates, [FORMS]],
|
|
45
|
+
[content_type_schema, [CONTENT_TYPE, XSD, PROPERTIES]],
|
|
46
|
+
[BibliographySources.new.to_xml, [BIBLIOGRAPHY]],
|
|
47
|
+
]
|
|
48
|
+
payloads.map.with_index(1) do |(xml, namespaces), index|
|
|
49
|
+
Uniword::Docx::CustomXmlItem.new(
|
|
50
|
+
index: index, xml_content: xml, props_xml: item_props(namespaces),
|
|
51
|
+
rels_xml: item_relationships(index)
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def document_management
|
|
57
|
+
xml_payload do |xml|
|
|
58
|
+
xml.create_and_add_element("properties", prefix: "m",
|
|
59
|
+
attributes: { "xmlns:m" => PROPERTIES, "xmlns:t" => TYPEFI }) do
|
|
60
|
+
xml.documentManagement do
|
|
61
|
+
xml.create_and_add_element("_Flow_SignoffStatus", prefix: "t")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def form_templates
|
|
68
|
+
xml_payload do |xml|
|
|
69
|
+
xml.FormTemplates("xmlns" => FORMS, "xmlns:t" => TYPEFI) do
|
|
70
|
+
xml.Display
|
|
71
|
+
xml.Edit
|
|
72
|
+
xml.New
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def content_type_schema
|
|
78
|
+
xml_payload do |xml|
|
|
79
|
+
xml.contentTypeSchema("xmlns" => CONTENT_TYPE, "xmlns:t" => TYPEFI) do
|
|
80
|
+
xml.create_and_add_element("schema", prefix: "xs",
|
|
81
|
+
attributes: { "xmlns:xs" => XSD, "targetNamespace" => PROPERTIES }) do
|
|
82
|
+
schema_elements(xml)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def schema_elements(xml)
|
|
89
|
+
schema_element(xml, "element", name: "properties") do
|
|
90
|
+
schema_element(xml, "complexType") do
|
|
91
|
+
schema_element(xml, "sequence") do
|
|
92
|
+
schema_element(xml, "element", name: "documentManagement", type: "xs:anyType")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def schema_element(xml, name, **attributes)
|
|
99
|
+
namespace = xml.current_element.namespace
|
|
100
|
+
xml.create_and_add_element(name, attributes: attributes) do
|
|
101
|
+
# The builder can inherit the enclosing contentTypeSchema's
|
|
102
|
+
# default namespace when attaching a child.
|
|
103
|
+
xml.current_element.namespace = namespace
|
|
104
|
+
yield if block_given?
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def xml_payload(&)
|
|
109
|
+
Lutaml::Xml::Builder::Base.build(engine: :nokogiri, &).to_xml
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def item_props(namespaces)
|
|
113
|
+
refs = (namespaces + [TYPEFI]).map { |uri| Uniword::Customxml::SchemaRef.new(uri: uri) }
|
|
114
|
+
Uniword::Customxml::DataStoreItem.new(
|
|
115
|
+
item_id: "{#{SecureRandom.uuid.upcase}}",
|
|
116
|
+
schema_refs: Uniword::Customxml::SchemaRefs.new(refs: refs),
|
|
117
|
+
).to_xml
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def item_relationships(index)
|
|
121
|
+
relationship = Uniword::Ooxml::Relationships::PackageRelationship.new(
|
|
122
|
+
id: "rId1", type: "#{REL_TYPE}Props", target: "itemProps#{index}.xml",
|
|
123
|
+
)
|
|
124
|
+
Uniword::Ooxml::Relationships::PackageRelationships.new(relationships: [relationship]).to_xml
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
data/lib/metanorma/iso/log.rb
CHANGED
|
@@ -180,8 +180,6 @@ module Metanorma
|
|
|
180
180
|
severity: 2 },
|
|
181
181
|
ISO_62: { category: "Grammar", error: "%s",
|
|
182
182
|
severity: 2 },
|
|
183
|
-
ISO_63: { category: "Grammar", error: "%s",
|
|
184
|
-
severity: 2 },
|
|
185
183
|
ISO_64: { category: "Abbreviated terms", error: "%s",
|
|
186
184
|
severity: 2 },
|
|
187
185
|
ISO_65: { category: "Abbreviations and contractions", error: "%s",
|
|
@@ -243,18 +243,31 @@ module Metanorma
|
|
|
243
243
|
params[0..-2] + ["#{params.last} #{suffix}"]
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
-
# Model-based location string for an Issue
|
|
247
|
-
#
|
|
248
|
-
#
|
|
249
|
-
#
|
|
250
|
-
|
|
246
|
+
# Model-based location string for an Issue: "ClassName#id" from
|
|
247
|
+
# the first id-bearing node among +node+ and then +fallbacks+
|
|
248
|
+
# (nearest first); the bare "ClassName" of +node+ when none of
|
|
249
|
+
# them carries an id; nil for a nil +node+. NEVER produces
|
|
250
|
+
# XPath — locations are diagnostic labels, not XML queries.
|
|
251
|
+
#
|
|
252
|
+
# +fallbacks+ locate nodes that never carry an id of their own.
|
|
253
|
+
# The model keeps no parent pointers, so the caller supplies
|
|
254
|
+
# the next-nearest id-bearing candidates. StyleRule passes the
|
|
255
|
+
# scanned paragraph: standoc mints the stable "_<hash>" id on
|
|
256
|
+
# every <p> and never on the enclosing <li>
|
|
257
|
+
# (metanorma-pdfa#133), so a finding raised against a ListItem
|
|
258
|
+
# is located by that paragraph's id — the node the id really
|
|
259
|
+
# belongs to names the label, keeping "ClassName#id" truthful.
|
|
260
|
+
def model_location(node, *fallbacks)
|
|
251
261
|
return nil if node.nil?
|
|
252
262
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
263
|
+
id_owner = [node, *fallbacks].compact.find { |n| read_id(n) }
|
|
264
|
+
return class_label(node) if id_owner.nil?
|
|
265
|
+
|
|
266
|
+
"#{class_label(id_owner)}##{read_id(id_owner)}"
|
|
267
|
+
end
|
|
256
268
|
|
|
257
|
-
|
|
269
|
+
def class_label(node)
|
|
270
|
+
node.class.name.split("::").last
|
|
258
271
|
end
|
|
259
272
|
|
|
260
273
|
# Read +id+ from a model node if (and only if) the node's class
|
|
@@ -10,10 +10,11 @@ module Metanorma
|
|
|
10
10
|
# "a user", "a university", "a one-hour test".
|
|
11
11
|
#
|
|
12
12
|
# Both directions are closed exception lists covering WORDS
|
|
13
|
-
# only
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
13
|
+
# only, and skip all-caps initialisms (their article follows
|
|
14
|
+
# letter-name sounds, a grammar-model question, not a word
|
|
15
|
+
# list). The ISO_63 initialism rule was withdrawn: its hand
|
|
16
|
+
# list mixed both sound classes; initialism article checks
|
|
17
|
+
# return with the grammar-model integration.
|
|
17
18
|
class StyleAOrAnRule < StyleRule
|
|
18
19
|
code "ISO_62"
|
|
19
20
|
|
|
@@ -32,11 +32,24 @@ module Metanorma
|
|
|
32
32
|
text = cache.text_of(paragraph, strip: prose_exclusions).strip
|
|
33
33
|
next if text.empty?
|
|
34
34
|
|
|
35
|
-
issues.concat(
|
|
35
|
+
issues.concat(scan_paragraph(parent, paragraph, text))
|
|
36
36
|
end
|
|
37
37
|
issues
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Scan one paragraph with +paragraph+ registered as the location
|
|
41
|
+
# fallback for every finding the scan raises (see
|
|
42
|
+
# Base#model_location). +parent+ stays the finding's node — rules
|
|
43
|
+
# classify by container — but an id-less container is located by
|
|
44
|
+
# the paragraph's own id. Cleared after each scan so no finding
|
|
45
|
+
# raised outside a paragraph scan inherits a stale fallback.
|
|
46
|
+
def scan_paragraph(parent, paragraph, text)
|
|
47
|
+
@location_fallback = paragraph
|
|
48
|
+
scan_text(parent, text)
|
|
49
|
+
ensure
|
|
50
|
+
@location_fallback = nil
|
|
51
|
+
end
|
|
52
|
+
|
|
40
53
|
# Model attribute names excluded from the extracted prose text.
|
|
41
54
|
# Mathematical content (<stem>, <fmt-stem>) is technical, not
|
|
42
55
|
# prose: word-list rules must not lint formula source. This
|
|
@@ -81,7 +94,8 @@ module Metanorma
|
|
|
81
94
|
end
|
|
82
95
|
|
|
83
96
|
def build_warning(node, message)
|
|
84
|
-
build_issue(location: model_location(node
|
|
97
|
+
build_issue(location: model_location(node, @location_fallback),
|
|
98
|
+
params: [message])
|
|
85
99
|
end
|
|
86
100
|
end
|
|
87
101
|
end
|
|
@@ -138,8 +138,6 @@ module Metanorma
|
|
|
138
138
|
"metanorma/iso/validation/rules/style_penultimate_list_rule"
|
|
139
139
|
# ISO House Style 2026-08 quick wins, second tranche (issue
|
|
140
140
|
# #1701), in alphabetical order:
|
|
141
|
-
autoload :StyleAbbrevArticlesRule,
|
|
142
|
-
"metanorma/iso/validation/rules/style_abbrev_articles_rule"
|
|
143
141
|
autoload :StyleAbbrevPluralRule,
|
|
144
142
|
"metanorma/iso/validation/rules/style_abbrev_plural_rule"
|
|
145
143
|
autoload :StyleBareSlashRule,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-iso
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.5.
|
|
4
|
+
version: 3.5.45
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -533,6 +533,7 @@ files:
|
|
|
533
533
|
- lib/isodoc/iso/docx/context.rb
|
|
534
534
|
- lib/isodoc/iso/docx/core_properties_builder.rb
|
|
535
535
|
- lib/isodoc/iso/docx/cover_renderer.rb
|
|
536
|
+
- lib/isodoc/iso/docx/custom_xml_items.rb
|
|
536
537
|
- lib/isodoc/iso/docx/definition_list_renderer.rb
|
|
537
538
|
- lib/isodoc/iso/docx/document_properties.rb
|
|
538
539
|
- lib/isodoc/iso/docx/errors.rb
|
|
@@ -899,7 +900,6 @@ files:
|
|
|
899
900
|
- lib/metanorma/iso/validation/rules/see_xrefs_rule.rb
|
|
900
901
|
- lib/metanorma/iso/validation/rules/stem_math.rb
|
|
901
902
|
- lib/metanorma/iso/validation/rules/style_a_or_an_rule.rb
|
|
902
|
-
- lib/metanorma/iso/validation/rules/style_abbrev_articles_rule.rb
|
|
903
903
|
- lib/metanorma/iso/validation/rules/style_abbrev_plural_rule.rb
|
|
904
904
|
- lib/metanorma/iso/validation/rules/style_abbrev_tables_only_rule.rb
|
|
905
905
|
- lib/metanorma/iso/validation/rules/style_abbrev_uppercase_rule.rb
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Iso
|
|
5
|
-
module Validation
|
|
6
|
-
module Rules
|
|
7
|
-
# Style warnings for wrong indefinite articles before
|
|
8
|
-
# initialisms (ISO House Style): initialisms pronounced
|
|
9
|
-
# letter-wise take "an" ("an ISO standard", "an XML file"),
|
|
10
|
-
# not "a".
|
|
11
|
-
#
|
|
12
|
-
# The list below is closed and conservative: only initialisms
|
|
13
|
-
# whose English pronunciation begins with a letter name
|
|
14
|
-
# ("gee", "you", "ess", ...) are flagged, so "a GPS", "a UN",
|
|
15
|
-
# "a SQL" and friends are reported. The reverse direction
|
|
16
|
-
# ("an RFC", "an SAP" read as a word) and acronyms pronounced
|
|
17
|
-
# as words (RAM, NATO) are intentionally out of scope.
|
|
18
|
-
class StyleAbbrevArticlesRule < StyleRule
|
|
19
|
-
code "ISO_63"
|
|
20
|
-
|
|
21
|
-
policy category: "Grammar > A or an",
|
|
22
|
-
rule: "use 'an' before an abbreviated term beginning with a vowel sound ('an ISO standard', 'an XML file')",
|
|
23
|
-
source: :house_style, mn_category: :style
|
|
24
|
-
|
|
25
|
-
# Consonant-letter-name initialisms (PDF "pee", JPG "jay",
|
|
26
|
-
# GPS "jee", UN "you") take "a" and are NOT listed; the list
|
|
27
|
-
# is strictly vowel-letter-name initialisms.
|
|
28
|
-
LETTER_PRONOUNCED = %w[
|
|
29
|
-
GPS UN URN ERP HR SQL API ISO HTML XML RGB RPG SAP
|
|
30
|
-
RPM RSA SLA UML URL
|
|
31
|
-
].freeze
|
|
32
|
-
|
|
33
|
-
A_ARTICLE_REGEX =
|
|
34
|
-
/\ba\s+(?:#{LETTER_PRONOUNCED.join("|")})\b/.freeze
|
|
35
|
-
|
|
36
|
-
def scan_text(node, text)
|
|
37
|
-
findings_for_matches(
|
|
38
|
-
node, text, A_ARTICLE_REGEX,
|
|
39
|
-
"wrong article '%s': this initialism is pronounced " \
|
|
40
|
-
"letter-wise — use 'an'"
|
|
41
|
-
)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|