asciidoctor-iso 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile.lock +12 -10
  5. data/README.adoc +113 -16
  6. data/bin/rspec +18 -0
  7. data/lib/asciidoctor/iso/base.rb +30 -28
  8. data/lib/asciidoctor/iso/blocks.rb +33 -33
  9. data/lib/asciidoctor/iso/cleanup.rb +79 -33
  10. data/lib/asciidoctor/iso/cleanup_block.rb +71 -18
  11. data/lib/asciidoctor/iso/cleanup_ref.rb +35 -30
  12. data/lib/asciidoctor/iso/converter.rb +0 -3
  13. data/lib/asciidoctor/iso/front.rb +29 -16
  14. data/lib/asciidoctor/iso/html/isodoc.css +34 -0
  15. data/lib/asciidoctor/iso/html/wordstyle.css +138 -6
  16. data/lib/asciidoctor/iso/inline.rb +10 -22
  17. data/lib/asciidoctor/iso/isodoc.rng +66 -16
  18. data/lib/asciidoctor/iso/isostandard.rng +129 -15
  19. data/lib/asciidoctor/iso/lists.rb +49 -42
  20. data/lib/asciidoctor/iso/macros.rb +12 -8
  21. data/lib/asciidoctor/iso/section.rb +53 -37
  22. data/lib/asciidoctor/iso/table.rb +9 -1
  23. data/lib/asciidoctor/iso/utils.rb +18 -13
  24. data/lib/asciidoctor/iso/validate.rb +100 -24
  25. data/lib/asciidoctor/iso/validate_requirements.rb +106 -0
  26. data/lib/asciidoctor/iso/validate_section.rb +85 -65
  27. data/lib/asciidoctor/iso/validate_style.rb +68 -115
  28. data/lib/asciidoctor/iso/version.rb +1 -1
  29. data/spec/asciidoctor-iso/base_spec.rb +193 -0
  30. data/spec/asciidoctor-iso/blocks_spec.rb +426 -0
  31. data/spec/asciidoctor-iso/cleanup_spec.rb +687 -0
  32. data/spec/asciidoctor-iso/inline_spec.rb +159 -0
  33. data/spec/asciidoctor-iso/lists_spec.rb +189 -0
  34. data/spec/asciidoctor-iso/macros_spec.rb +20 -0
  35. data/spec/asciidoctor-iso/refs_spec.rb +194 -0
  36. data/spec/asciidoctor-iso/section_spec.rb +301 -0
  37. data/spec/asciidoctor-iso/table_spec.rb +307 -0
  38. data/spec/asciidoctor-iso/validate_spec.rb +749 -0
  39. data/spec/examples/english.yaml +69 -0
  40. data/spec/examples/rice.adoc +30 -28
  41. data/spec/examples/rice.doc +3035 -2865
  42. data/spec/examples/rice.html +281 -234
  43. data/spec/examples/rice.preview.html +30 -20
  44. data/spec/examples/rice.xml +250 -282
  45. data/spec/spec_helper.rb +87 -0
  46. metadata +17 -2
@@ -5,168 +5,121 @@ require "pp"
5
5
  module Asciidoctor
6
6
  module ISO
7
7
  module Validate
8
- REQUIREMENT_RE_STR = <<~REGEXP.freeze
9
- \\b
10
- ( shall | (is|are)_to |
11
- (is|are)_required_(not_)?to |
12
- has_to |
13
- only\\b[^.,]+\\b(is|are)_permitted |
14
- it_is_necessary |
15
- (needs|need)_to |
16
- (is|are)_not_(allowed | permitted |
17
- acceptable | permissible) |
18
- (is|are)_not_to_be |
19
- (need|needs)_not |
20
- do_not )
21
- \\b
22
- REGEXP
23
- REQUIREMENT_RE =
24
- Regexp.new(REQUIREMENT_RE_STR.gsub(/\s/, "").gsub(/_/, "\\s"),
25
- Regexp::IGNORECASE)
26
-
27
- def requirement(text)
28
- text.split(/\.\s+/).each do |t|
29
- return t if REQUIREMENT_RE.match? t
30
- end
31
- nil
32
- end
33
-
34
- RECOMMENDATION_RE_STR = <<~REGEXP.freeze
35
- \\b
36
- should |
37
- ought_(not_)?to |
38
- it_is_(not_)?recommended_that
39
- \\b
40
- REGEXP
41
- RECOMMENDATION_RE =
42
- Regexp.new(RECOMMENDATION_RE_STR.gsub(/\s/, "").gsub(/_/, "\\s"),
43
- Regexp::IGNORECASE)
44
-
45
- def recommendation(text)
46
- text.split(/\.\s+/).each do |t|
47
- return t if RECOMMENDATION_RE.match? t
48
- end
49
- nil
50
- end
51
-
52
- PERMISSION_RE_STR = <<~REGEXP.freeze
53
- \\b
54
- may |
55
- (is|are)_(permitted | allowed | permissible ) |
56
- it_is_not_required_that |
57
- no\\b[^.,]+\\b(is|are)_required
58
- \\b
59
- REGEXP
60
- PERMISSION_RE =
61
- Regexp.new(PERMISSION_RE_STR.gsub(/\s/, "").gsub(/_/, "\\s"),
62
- Regexp::IGNORECASE)
63
-
64
- def permission(text)
65
- text.split(/\.\s+/).each do |t|
66
- return t if PERMISSION_RE.match? t
67
- end
68
- nil
69
- end
70
-
71
- POSSIBILITY_RE_STR = <<~REGEXP.freeze
72
- \\b
73
- can | cannot | be_able_to |
74
- there_is_a_possibility_of |
75
- it_is_possible_to | be_unable_to |
76
- there_is_no_possibility_of |
77
- it_is_not_possible_to
78
- \\b
79
- REGEXP
80
- POSSIBILITY_RE =
81
- Regexp.new(POSSIBILITY_RE_STR.gsub(/\s/, "").gsub(/_/, "\\s"),
82
- Regexp::IGNORECASE)
83
-
84
- def posssibility(text)
85
- text.split(/\.\s+/).each do |t|
86
- return t if POSSIBILITY_RE.match? t
87
- end
88
- nil
89
- end
90
-
91
- def external_constraint(text)
92
- text.split(/\.\s+/).each do |t|
93
- return t if /\b(must)\b/xi.match? t
94
- end
95
- nil
96
- end
97
-
98
- def style_no_guidance(node, text, docpart)
99
- r = requirement(text)
100
- style_warning(node, "#{docpart} may contain requirement", r) if r
101
- r = permission(text)
102
- style_warning(node, "#{docpart} may contain permission", r) if r
103
- r = recommendation(text)
104
- style_warning(node, "#{docpart} may contain recommendation", r) if r
105
- end
106
-
107
8
  def foreword_style(node, text)
9
+ return if @novalid
108
10
  style_no_guidance(node, text, "Foreword")
109
11
  end
110
12
 
111
13
  def scope_style(node, text)
14
+ return if @novalid
112
15
  style_no_guidance(node, text, "Scope")
113
16
  end
114
17
 
115
18
  def introduction_style(node, text)
19
+ return if @novalid
116
20
  r = requirement(text)
117
21
  style_warning(node, "Introduction may contain requirement", r) if r
118
22
  end
119
23
 
120
24
  def termexample_style(node, text)
25
+ return if @novalid
121
26
  style_no_guidance(node, text, "Term Example")
122
27
  style(node, text)
123
28
  end
124
29
 
125
30
  def note_style(node, text)
31
+ return if @novalid
126
32
  style_no_guidance(node, text, "Note")
127
33
  style(node, text)
128
34
  end
129
35
 
130
36
  def footnote_style(node, text)
37
+ return if @novalid
131
38
  style_no_guidance(node, text, "Footnote")
132
39
  style(node, text)
133
40
  end
134
41
 
135
42
  def style_warning(node, msg, text)
43
+ return if @novalid
136
44
  w = "ISO style: WARNING (#{Utils::current_location(node)}): #{msg}"
137
45
  w += ": #{text}" if text
138
46
  warn w
139
47
  end
140
48
 
141
- # style check with a single regex
142
- def style_single_regex(n, text, re, warning)
143
- m = re.match(text) and style_warning(n, warning, m[:num])
49
+ def style_regex(re, warning, n, text)
50
+ (m = re.match(text)) && style_warning(n, warning, m[:num])
144
51
  end
145
52
 
146
53
  # style check with a regex on a token
147
54
  # and a negative match on its preceding token
148
55
  def style_two_regex_not_prev(n, text, re, re_prev, warning)
149
56
  return if text.nil?
150
- words = text.split(/\W+/).each_index do |i|
151
- next if i.zero?
152
- m = re.match text[i]
153
- m_prev = re_prev.match text[i - 1]
57
+ arr = text.split(/\W+/)
58
+ arr.each_index do |i|
59
+ m = re.match arr[i]
60
+ m_prev = i.zero? ? nil : re_prev.match(arr[i - 1])
154
61
  if !m.nil? && m_prev.nil?
155
62
  style_warning(n, warning, m[:num])
156
63
  end
157
64
  end
158
65
  end
159
66
 
160
- def style(n, text)
161
- style_single_regex(n, text, /\b(?<num>[0-9]+\.[0-9]+)\b/,
162
- "possible decimal point")
163
- style_two_regex_not_prev(n, text, /^(?<num>[0-9]{4,})$/,
164
- %r{(\bISO|\bIEC|\bIEEE|/)$},
67
+ def style(n, t)
68
+ return if @novalid
69
+ style_number(n, t)
70
+ style_percent(n, t)
71
+ style_abbrev(n, t)
72
+ style_units(n, t)
73
+ end
74
+
75
+ def style_number(n, t)
76
+ style_two_regex_not_prev(n, t, /^(?<num>-?[0-9]{4,}[,0-9]*)$/,
77
+ %r{(\bISO|\bIEC|\bIEEE/)$},
165
78
  "number not broken up in threes")
166
- style_single_regex(n, text, /\b(?<num>[0-9.,]+%)/,
167
- "no space before percent sign")
168
- style_single_regex(n, text, /\b(?<num>[0-9.,]+ \u00b1 [0-9,.]+ %)/,
169
- "unbracketed tolerance before percent sign")
79
+ style_regex(/\b(?<num>[0-9]+\.[0-9]+)/i,
80
+ "possible decimal point", n, t)
81
+ style_regex(/\b(?<num>billion[s]?)\b/i,
82
+ "ambiguous number", n, t)
83
+ end
84
+
85
+ def style_percent(n, t)
86
+ style_regex(/\b(?<num>[0-9.,]+%)/,
87
+ "no space before percent sign", n, t)
88
+ style_regex(/\b(?<num>[0-9.,]+ \u00b1 [0-9,.]+ %)/,
89
+ "unbracketed tolerance before percent sign", n, t)
90
+ end
91
+
92
+ def style_abbrev(n, t)
93
+ style_regex(/(^|\s)(?!e\.g\.|i\.e\.)
94
+ (?<num>[a-z]{1,2}\.([a-z]{1,2}|\.))\b/ix,
95
+ "no dots in abbreviations", n, t)
96
+ style_regex(/\b(?<num>ppm)\b/i,
97
+ "language-specific abbreviation", n, t)
98
+ end
99
+
100
+ # leaving out as problematic: N J K C S T H h d B o E
101
+ SI_UNIT = "(m|cm|mm|km|μm|nm|g|kg|mgmol|cd|rad|sr|Hz|Hz|MHz|Pa|hPa|kJ|"\
102
+ "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|"\
103
+ "bit|kB|MB|Hart|nat|Sh|var)".freeze
104
+
105
+ def style_units(n, t)
106
+ style_regex(/\b(?<num>[0-9][0-9,]*\s+[\u00b0\u2032\u2033])/,
107
+ "space between number and degrees/minutes/seconds", n, t)
108
+ style_regex(/\b(?<num>[0-9][0-9,]*#{SI_UNIT})\b/,
109
+ "no space between number and SI unit", n, t)
110
+ style_non_std_units(n, t)
111
+ end
112
+
113
+ NONSTD_UNITS = {
114
+ "sec": "s", "mins": "min", "hrs": "h", "hr": "h", "cc": "cm^3",
115
+ "lit": "l", "amp": "A", "amps": "A", "rpm": "r/min"
116
+ }.freeze
117
+
118
+ def style_non_std_units(n, t)
119
+ NONSTD_UNITS.each do |k, v|
120
+ style_regex(/\b(?<num>[0-9][0-9,]*\s+#{k})\b/,
121
+ "non-standard unit (should be #{v})", n, t)
122
+ end
170
123
  end
171
124
  end
172
125
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module ISO
3
- VERSION = "0.6.1".freeze
3
+ VERSION = "0.7.0".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,193 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::ISO do
4
+ it "has a version number" do
5
+ expect(Asciidoctor::ISO::VERSION).not_to be nil
6
+ end
7
+
8
+ it "generates output for the Rice document" do
9
+ system "cd spec/examples; rm -f rice.doc; rm -f rice.html; asciidoctor --trace -b iso -r 'asciidoctor-iso' rice.adoc; cd ../.."
10
+ expect(File.exist?("spec/examples/rice.doc")).to be true
11
+ expect(File.exist?("spec/examples/rice.html")).to be true
12
+ end
13
+
14
+ it "processes a blank document" do
15
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
16
+ #{ASCIIDOC_BLANK_HDR}
17
+ INPUT
18
+ #{BLANK_HDR}
19
+ <sections/>
20
+ </iso-standard>
21
+ OUTPUT
22
+ end
23
+
24
+ it "converts a blank document" do
25
+ system "rm -f test.doc"
26
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
27
+ = Document title
28
+ Author
29
+ :docfile: test.adoc
30
+ :novalid:
31
+ INPUT
32
+ #{BLANK_HDR}
33
+ <sections/>
34
+ </iso-standard>
35
+ OUTPUT
36
+ expect(File.exist?("test.doc")).to be true
37
+ end
38
+
39
+
40
+ it "processes default metadata" do
41
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
42
+ = Document title
43
+ Author
44
+ :docfile: test.adoc
45
+ :nodoc:
46
+ :novalid:
47
+ :docnumber: 1000
48
+ :partnumber: 1
49
+ :edition: 2
50
+ :revdate: 2000-01-01
51
+ :draft: 3.4
52
+ :technical-committee: TC
53
+ :technical-committee-number: 1
54
+ :technical-committee-type: A
55
+ :subcommittee: SC
56
+ :subcommittee-number: 2
57
+ :subcommittee-type: B
58
+ :workgroup: WG
59
+ :workgroup-number: 3
60
+ :workgroup-type: C
61
+ :secretariat: SECRETARIAT
62
+ :copyright-year: 2001
63
+ :docstage: 10
64
+ :docsubstage: 20
65
+ :language: en
66
+ :title-intro-en: Introduction
67
+ :title-main-en: Main Title
68
+ :title-part-en: Title Part
69
+ :title-intro-fr: Introduction Française
70
+ :title-main-fr: Titre Principal
71
+ :title-part-fr: Part du Titre
72
+ INPUT
73
+ <?xml version="1.0" encoding="UTF-8"?>
74
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
75
+ <bibdata type="article">
76
+ <title>
77
+ <title-intro language="en" format="text/plain">Introduction</title-intro>
78
+ <title-main language="en" format="text/plain">Main Title</title-main>
79
+ <title-part language="en" format="text/plain">Title Part</title-part>
80
+ </title>
81
+ <title>
82
+ <title-intro language="fr" format="text/plain">Introduction Française</title-intro>
83
+ <title-main language="fr" format="text/plain">Titre Principal</title-main>
84
+ <title-part language="fr" format="text/plain">Part du Titre</title-part>
85
+ </title>
86
+ <docidentifier>
87
+ <project-number part="1">1000</project-number>
88
+ </docidentifier>
89
+ <contributor>
90
+ <role type="author"/>
91
+ <organization>
92
+ <name>ISO</name>
93
+ </organization>
94
+ </contributor>
95
+ <contributor>
96
+ <role type="publisher"/>
97
+ <organization>
98
+ <name>ISO</name>
99
+ </organization>
100
+ </contributor>
101
+ <language>en</language>
102
+ <script>Latn</script>
103
+ <status>
104
+ <stage>10</stage>
105
+ <substage>20</substage>
106
+ </status>
107
+ <copyright>
108
+ <from>2001</from>
109
+ <owner>
110
+ <organization>
111
+ <name>ISO</name>
112
+ </organization>
113
+ </owner>
114
+ </copyright>
115
+ <editorialgroup>
116
+ <technical-committee number="1" type="A">TC</technical-committee>
117
+ <subcommittee number="2" type="B">SC</subcommittee>
118
+ <workgroup number="3" type="C">WG</workgroup>
119
+ <secretariat>SECRETARIAT</secretariat>
120
+ </editorialgroup>
121
+ </bibdata><version>
122
+ <edition>2</edition>
123
+ <revision-date>2000-01-01</revision-date>
124
+ <draft>3.4</draft>
125
+ </version>
126
+ <sections/>
127
+ </iso-standard>
128
+ OUTPUT
129
+ end
130
+
131
+
132
+ it "processes complex metadata" do
133
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
134
+ = Document title
135
+ Author
136
+ :docfile: test.adoc
137
+ :nodoc:
138
+ :novalid:
139
+ :docnumber: 1000
140
+ :partnumber: 1-1
141
+ :tc-docnumber: 2000
142
+ :language: el
143
+ :script: Grek
144
+ INPUT
145
+ <?xml version="1.0" encoding="UTF-8"?>
146
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
147
+ <bibdata type="article">
148
+ <title>
149
+ </title>
150
+ <title>
151
+ </title>
152
+ <docidentifier>
153
+ <project-number part="1" subpart="1">1000</project-number>
154
+ <tc-document-number>2000</tc-document-number>
155
+ </docidentifier>
156
+ <contributor>
157
+ <role type="author"/>
158
+ <organization>
159
+ <name>ISO</name>
160
+ </organization>
161
+ </contributor>
162
+ <contributor>
163
+ <role type="publisher"/>
164
+ <organization>
165
+ <name>ISO</name>
166
+ </organization>
167
+ </contributor>
168
+ <language>el</language>
169
+ <script>Grek</script>
170
+ <status>
171
+ <stage>60</stage>
172
+ <substage>60</substage>
173
+ </status>
174
+ <copyright>
175
+ <from>2018</from>
176
+ <owner>
177
+ <organization>
178
+ <name>ISO</name>
179
+ </organization>
180
+ </owner>
181
+ </copyright>
182
+ <editorialgroup>
183
+ <technical-committee/>
184
+ <subcommittee/>
185
+ <workgroup/>
186
+ </editorialgroup>
187
+ </bibdata>
188
+ <sections/>
189
+ </iso-standard>
190
+ OUTPUT
191
+ end
192
+
193
+ end
@@ -0,0 +1,426 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::ISO do
4
+ it "processes open blocks" do
5
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ --
8
+ x
9
+
10
+ y
11
+
12
+ z
13
+ --
14
+ INPUT
15
+ #{BLANK_HDR}
16
+ <sections><p id="_">x</p>
17
+ <p id="_">y</p>
18
+ <p id="_">z</p></sections>
19
+ </iso-standard>
20
+ OUTPUT
21
+ end
22
+
23
+ it "processes stem blocks" do
24
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
25
+ #{ASCIIDOC_BLANK_HDR}
26
+ [stem]
27
+ ++++
28
+ r = 1 %
29
+ r = 1 %
30
+ ++++
31
+ INPUT
32
+ #{BLANK_HDR}
33
+ <sections>
34
+ <formula id="_">
35
+ <stem type="AsciiMath">r = 1 %
36
+ r = 1 %</stem>
37
+ </formula>
38
+ </sections>
39
+ </iso-standard>
40
+ OUTPUT
41
+ end
42
+
43
+ it "ignores review blocks unless document is in draft mode" do
44
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
45
+ #{ASCIIDOC_BLANK_HDR}
46
+ [[foreword]]
47
+ .Foreword
48
+ Foreword
49
+
50
+ [reviewer=ISO,date=20170101,from=foreword,to=foreword]
51
+ ****
52
+ A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.
53
+
54
+ For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
55
+ ****
56
+ INPUT
57
+ #{BLANK_HDR}
58
+ <sections><p id="foreword">Foreword</p>
59
+ </sections>
60
+ </iso-standard>
61
+ OUTPUT
62
+ end
63
+
64
+ it "processes review blocks if document is in draft mode" do
65
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
66
+ = Document title
67
+ Author
68
+ :docfile: test.adoc
69
+ :nodoc:
70
+ :novalid:
71
+ :draft: 1.2
72
+
73
+ [[foreword]]
74
+ .Foreword
75
+ Foreword
76
+
77
+ [reviewer=ISO,date=20170101,from=foreword,to=foreword]
78
+ ****
79
+ A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.
80
+
81
+ For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
82
+ ****
83
+ INPUT
84
+ #{BLANK_HDR}
85
+ <version>
86
+ <draft>1.2</draft>
87
+ </version>
88
+ <sections><p id="foreword">Foreword</p>
89
+ <review reviewer="ISO" id="_" date="20170101T0000" from="foreword" to="foreword"><p id="_">A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.</p>
90
+ <p id="_">For further information on the Foreword, see <strong>ISO/IEC Directives, Part 2, 2016, Clause 12.</strong></p></review></sections>
91
+ </iso-standard>
92
+
93
+ OUTPUT
94
+ end
95
+
96
+ it "processes term notes" do
97
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
98
+ #{ASCIIDOC_BLANK_HDR}
99
+ == Terms and Definitions
100
+
101
+ === Term1
102
+
103
+ NOTE: This is a note
104
+ INPUT
105
+ #{BLANK_HDR}
106
+ <sections>
107
+ <terms id="_" obligation="normative">
108
+ <title>Terms and Definitions</title>
109
+ <term id="_">
110
+ <preferred>Term1</preferred>
111
+ <termnote id="_">
112
+ <p id="_">This is a note</p>
113
+ </termnote>
114
+ </term>
115
+ </terms>
116
+ </sections>
117
+ </iso-standard>
118
+ OUTPUT
119
+ end
120
+
121
+ it "processes notes" do
122
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
123
+ #{ASCIIDOC_BLANK_HDR}
124
+ NOTE: This is a note
125
+ INPUT
126
+ #{BLANK_HDR}
127
+ <sections>
128
+ <note id="_">
129
+ <p id="_">This is a note</p>
130
+ </note>
131
+ </sections>
132
+ </iso-standard>
133
+
134
+ OUTPUT
135
+ end
136
+
137
+ it "processes simple admonitions with Asciidoc names" do
138
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
139
+ #{ASCIIDOC_BLANK_HDR}
140
+ CAUTION: Only use paddy or parboiled rice for the determination of husked rice yield.
141
+ INPUT
142
+ #{BLANK_HDR}
143
+ <sections>
144
+ <admonition id="_" type="caution">
145
+ <p id="_">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
146
+ </admonition>
147
+ </sections>
148
+ </iso-standard>
149
+
150
+ OUTPUT
151
+ end
152
+
153
+
154
+ it "processes complex admonitions with non-Asciidoc names" do
155
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
156
+ #{ASCIIDOC_BLANK_HDR}
157
+ [CAUTION,type=Safety Precautions]
158
+ .Safety Precautions
159
+ ====
160
+ While werewolves are hardy community members, keep in mind the following dietary concerns:
161
+
162
+ . They are allergic to cinnamon.
163
+ . More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens.
164
+ . Celery makes them sad.
165
+ ====
166
+ INPUT
167
+ #{BLANK_HDR}
168
+ <sections>
169
+ <admonition id="_" type="safety precautions"><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
170
+ <ol id="_" type="arabic">
171
+ <li>
172
+ <p id="_">They are allergic to cinnamon.</p>
173
+ </li>
174
+ <li>
175
+ <p id="_">More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens.</p>
176
+ </li>
177
+ <li>
178
+ <p id="_">Celery makes them sad.</p>
179
+ </li>
180
+ </ol></admonition>
181
+ </sections>
182
+ </iso-standard>
183
+
184
+ OUTPUT
185
+ end
186
+
187
+ it "processes term examples" do
188
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
189
+ #{ASCIIDOC_BLANK_HDR}
190
+ == Terms and Definitions
191
+
192
+ === Term1
193
+
194
+ [example]
195
+ This is an example
196
+ INPUT
197
+ #{BLANK_HDR}
198
+ <sections>
199
+ <terms id="_" obligation="normative">
200
+ <title>Terms and Definitions</title>
201
+ <term id="_">
202
+ <preferred>Term1</preferred>
203
+ <termexample id="_">
204
+ <p id="_">This is an example</p>
205
+ </termexample>
206
+ </term>
207
+ </terms>
208
+ </sections>
209
+ </iso-standard>
210
+
211
+ OUTPUT
212
+ end
213
+
214
+ it "processes examples" do
215
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
216
+ #{ASCIIDOC_BLANK_HDR}
217
+ [example]
218
+ ====
219
+ This is an example
220
+
221
+ Amen
222
+ ====
223
+ INPUT
224
+ #{BLANK_HDR}
225
+ <sections>
226
+ <example id="_"><p id="_">This is an example</p>
227
+ <p id="_">Amen</p></example>
228
+ </sections>
229
+ </iso-standard>
230
+ OUTPUT
231
+ end
232
+
233
+ it "processes preambles" do
234
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
235
+ #{ASCIIDOC_BLANK_HDR}
236
+ This is a preamble
237
+
238
+ == Section 1
239
+ INPUT
240
+ #{BLANK_HDR}
241
+ <foreword obligation="informative">
242
+ <title>Foreword</title>
243
+ <p id="_">This is a preamble</p>
244
+ </foreword><sections>
245
+ <clause id="_" inline-header="false" obligation="normative">
246
+ <title>Section 1</title>
247
+ </clause></sections>
248
+ </iso-standard>
249
+ OUTPUT
250
+ end
251
+
252
+ it "processes images" do
253
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
254
+ #{ASCIIDOC_BLANK_HDR}
255
+ .Split-it-right sample divider
256
+ image::spec/examples/rice_images/rice_image1.png[]
257
+
258
+ INPUT
259
+ #{BLANK_HDR}
260
+ <sections>
261
+ <figure id="_">
262
+ <name>Split-it-right sample divider</name>
263
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" imagetype="PNG"/>
264
+ </figure>
265
+ </sections>
266
+ </iso-standard>
267
+ OUTPUT
268
+ end
269
+
270
+ it "accepts width and height attributes on images" do
271
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
272
+ #{ASCIIDOC_BLANK_HDR}
273
+ [height=4,width=3]
274
+ image::spec/examples/rice_images/rice_image1.png[]
275
+
276
+ INPUT
277
+ #{BLANK_HDR}
278
+ <sections>
279
+ <figure id="_">
280
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" imagetype="PNG" height="4" width="3"/>
281
+ </figure>
282
+ </sections>
283
+ </iso-standard>
284
+ OUTPUT
285
+ end
286
+
287
+ it "accepts alignment attribute on paragraphs" do
288
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
289
+ #{ASCIIDOC_BLANK_HDR}
290
+ [align=right]
291
+ This para is right-aligned.
292
+ INPUT
293
+ #{BLANK_HDR}
294
+ <sections>
295
+ <p align="right" id="_">This para is right-aligned.</p>
296
+ </sections>
297
+ </iso-standard>
298
+ OUTPUT
299
+ end
300
+
301
+ it "processes blockquotes" do
302
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
303
+ #{ASCIIDOC_BLANK_HDR}
304
+ [quote, ISO, "ISO7301,section 1"]
305
+ ____
306
+ Block quotation
307
+ ____
308
+ INPUT
309
+ #{BLANK_HDR}
310
+ <sections>
311
+ <quote id="_">
312
+ <source type="inline" bibitemid="ISO7301" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></source>
313
+ <author>ISO</author>
314
+ <p id="_">Block quotation</p>
315
+ </quote>
316
+ </sections>
317
+ </iso-standard>
318
+ OUTPUT
319
+ end
320
+
321
+ it "processes source code" do
322
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
323
+ #{ASCIIDOC_BLANK_HDR}
324
+ [source,ruby]
325
+ --
326
+ puts "Hello, world."
327
+ %w{a b c}.each do |x|
328
+ puts x
329
+ end
330
+ --
331
+ INPUT
332
+ #{BLANK_HDR}
333
+ <sections>
334
+ <sourcecode id="_">puts "Hello, world."
335
+ %w{a b c}.each do |x|
336
+ puts x
337
+ end</sourcecode>
338
+ </sections>
339
+ </iso-standard>
340
+ OUTPUT
341
+ end
342
+
343
+ it "processes callouts" do
344
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
345
+ #{ASCIIDOC_BLANK_HDR}
346
+ [source,ruby]
347
+ --
348
+ puts "Hello, world." <1>
349
+ %w{a b c}.each do |x|
350
+ puts x <2>
351
+ end
352
+ --
353
+ <1> This is one callout
354
+ <2> This is another callout
355
+ INPUT
356
+ #{BLANK_HDR}
357
+ <sections><sourcecode id="_">puts "Hello, world." <callout target="_">1</callout>
358
+ %w{a b c}.each do |x|
359
+ puts x <callout target="_">2</callout>
360
+ end<annotation id="_">
361
+ <p id="_">This is one callout</p>
362
+ </annotation><annotation id="_">
363
+ <p id="_">This is another callout</p>
364
+ </annotation></sourcecode>
365
+ </sections>
366
+ </iso-standard>
367
+ OUTPUT
368
+ end
369
+
370
+ it "processes unmodified term sources" do
371
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
372
+ #{ASCIIDOC_BLANK_HDR}
373
+ == Terms and Definitions
374
+
375
+ === Term1
376
+
377
+ [.source]
378
+ <<ISO2191,section 1>>
379
+ INPUT
380
+ #{BLANK_HDR}
381
+ <sections>
382
+ <terms id="_" obligation="normative">
383
+ <title>Terms and Definitions</title>
384
+ <term id="_">
385
+ <preferred>Term1</preferred>
386
+ <termsource status="identical">
387
+ <origin bibitemid="ISO2191" type="inline" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></origin>
388
+ </termsource>
389
+ </term>
390
+ </terms>
391
+ </sections>
392
+ </iso-standard>
393
+ OUTPUT
394
+ end
395
+
396
+ it "processes modified term sources" do
397
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
398
+ #{ASCIIDOC_BLANK_HDR}
399
+ == Terms and Definitions
400
+
401
+ === Term1
402
+
403
+ [.source]
404
+ <<ISO2191,section 1>>, with adjustments
405
+ INPUT
406
+ #{BLANK_HDR}
407
+ <sections>
408
+ <terms id="_" obligation="normative">
409
+ <title>Terms and Definitions</title>
410
+ <term id="_">
411
+ <preferred>Term1</preferred>
412
+ <termsource status="modified">
413
+ <origin bibitemid="ISO2191" type="inline" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></origin>
414
+ <modification>
415
+ <p id="_">with adjustments</p>
416
+ </modification>
417
+ </termsource>
418
+ </term>
419
+ </terms>
420
+ </sections>
421
+ </iso-standard>
422
+ OUTPUT
423
+ end
424
+
425
+
426
+ end