asciidoctor 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of asciidoctor might be problematic. Click here for more details.

Files changed (42) hide show
  1. data/README.asciidoc +163 -41
  2. data/Rakefile +3 -1
  3. data/asciidoctor.gemspec +13 -5
  4. data/bin/asciidoctor +6 -3
  5. data/bin/asciidoctor-safe +13 -0
  6. data/lib/asciidoctor.rb +237 -26
  7. data/lib/asciidoctor/abstract_node.rb +27 -17
  8. data/lib/asciidoctor/attribute_list.rb +6 -0
  9. data/lib/asciidoctor/backends/base_template.rb +3 -4
  10. data/lib/asciidoctor/backends/docbook45.rb +114 -55
  11. data/lib/asciidoctor/backends/html5.rb +173 -104
  12. data/lib/asciidoctor/cli/invoker.rb +105 -0
  13. data/lib/asciidoctor/cli/options.rb +146 -0
  14. data/lib/asciidoctor/document.rb +135 -35
  15. data/lib/asciidoctor/lexer.rb +86 -33
  16. data/lib/asciidoctor/list_item.rb +2 -2
  17. data/lib/asciidoctor/reader.rb +6 -7
  18. data/lib/asciidoctor/section.rb +17 -5
  19. data/lib/asciidoctor/substituters.rb +216 -97
  20. data/lib/asciidoctor/table.rb +9 -2
  21. data/lib/asciidoctor/version.rb +1 -1
  22. data/man/asciidoctor.1 +212 -0
  23. data/man/asciidoctor.ad +156 -0
  24. data/test/attributes_test.rb +108 -5
  25. data/test/blocks_test.rb +102 -15
  26. data/test/document_test.rb +214 -3
  27. data/test/fixtures/encoding.asciidoc +4 -0
  28. data/test/fixtures/sample.asciidoc +26 -0
  29. data/test/invoker_test.rb +254 -0
  30. data/test/lexer_test.rb +53 -0
  31. data/test/links_test.rb +30 -0
  32. data/test/lists_test.rb +648 -9
  33. data/test/options_test.rb +68 -0
  34. data/test/paragraphs_test.rb +65 -1
  35. data/test/reader_test.rb +18 -4
  36. data/test/{headers_test.rb → sections_test.rb} +237 -0
  37. data/test/substitutions_test.rb +247 -5
  38. data/test/tables_test.rb +22 -4
  39. data/test/test_helper.rb +47 -3
  40. data/test/text_test.rb +20 -4
  41. metadata +34 -6
  42. data/noof.rb +0 -16
@@ -19,6 +19,7 @@ module Asciidoctor
19
19
  # Public: A Hash mapping styles abbreviations to styles that can be applied
20
20
  # to a table column or cell
21
21
  TEXT_STYLES = {
22
+ 'd' => :none,
22
23
  's' => :strong,
23
24
  'e' => :emphasis,
24
25
  'm' => :monospaced,
@@ -407,8 +408,14 @@ module Asciidoctor
407
408
  @buffer = ''
408
409
  if format == 'psv'
409
410
  cell_spec = take_cell_spec
410
- repeat = cell_spec.fetch('repeatcol', 1)
411
- cell_spec.delete('repeatcol')
411
+ if cell_spec.nil?
412
+ puts 'asciidoctor: ERROR: table missing leading separator, recovering automatically'
413
+ cell_spec = {}
414
+ repeat = 1
415
+ else
416
+ repeat = cell_spec.fetch('repeatcol', 1)
417
+ cell_spec.delete('repeatcol')
418
+ end
412
419
  else
413
420
  cell_spec = nil
414
421
  repeat = 1
@@ -1,3 +1,3 @@
1
1
  module Asciidoctor
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,212 @@
1
+ '\" t
2
+ .\" Title: asciidoctor
3
+ .\" Author: [see the "AUTHORS" section]
4
+ .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
5
+ .\" Date: 01/30/2013
6
+ .\" Manual: \ \&
7
+ .\" Source: \ \&
8
+ .\" Language: English
9
+ .\"
10
+ .TH "ASCIIDOCTOR" "1" "01/30/2013" "\ \&" "\ \&"
11
+ .\" -----------------------------------------------------------------
12
+ .\" * Define some portability stuff
13
+ .\" -----------------------------------------------------------------
14
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+ .\" http://bugs.debian.org/507673
16
+ .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
+ .ie \n(.g .ds Aq \(aq
19
+ .el .ds Aq '
20
+ .\" -----------------------------------------------------------------
21
+ .\" * set default formatting
22
+ .\" -----------------------------------------------------------------
23
+ .\" disable hyphenation
24
+ .nh
25
+ .\" disable justification (adjust text to left margin only)
26
+ .ad l
27
+ .\" -----------------------------------------------------------------
28
+ .\" * MAIN CONTENT STARTS HERE *
29
+ .\" -----------------------------------------------------------------
30
+ .SH "NAME"
31
+ asciidoctor \- converts an AsciiDoc source file to HTML, DocBook and other formats
32
+ .SH "SYNOPSIS"
33
+ .sp
34
+ \fBasciidoctor\fR [\fIOPTION\fR]\&... \fIFILE\fR
35
+ .SH "DESCRIPTION"
36
+ .sp
37
+ The asciidoctor(1) command converts the AsciiDoc source file \fIFILE\fR to HTML 5, DocBook 4\&.5 and other output formats\&.
38
+ .sp
39
+ If \fIFILE\fR is \fI\-\fR then the AsciiDoc source is read from standard input\&.
40
+ .SH "OPTIONS"
41
+ .SS "Security Settings"
42
+ .PP
43
+ \fB\-B, \-\-base\-dir\fR=\fIDIR\fR
44
+ .RS 4
45
+ Base directory containing the document and resources\&. Defaults to the directory containing the source file, or the working directory if the source is read from a stream\&. Can be used as a way to chroot the execution of the program\&.
46
+ .RE
47
+ .PP
48
+ \fB\-S, \-\-safe\-mode\fR=\fISAFE_MODE\fR
49
+ .RS 4
50
+ Set safe mode level explicity:
51
+ \fIunsafe\fR,
52
+ \fIsafe\fR,
53
+ \fIsecure\fR\&. Defaults to
54
+ \fIsecure\fR\&. Disables potentially dangerous macros in source files, such as include::[]\&.
55
+ .RE
56
+ .PP
57
+ \fB\-\-safe\fR
58
+ .RS 4
59
+ Set safe mode to
60
+ \fIsafe\fR
61
+ from the default safe mode of
62
+ \fIsecure\fR\&. Enables include macros, but restricts access to ancestor paths of source file\&. Provided for compatibility with the asciidoc command\&.
63
+ .RE
64
+ .SS "Document Settings"
65
+ .PP
66
+ \fB\-a, \-\-attribute\fR=\fIATTRIBUTE\fR
67
+ .RS 4
68
+ Define, override or delete a document attribute\&. Command\-line attributes take precedence over attributes defined in the source file\&.
69
+ .sp
70
+ \fIATTRIBUTE\fR
71
+ is formatted as a key\-value pair, in the form
72
+ \fINAME=VALUE\fR\&. Values containing spaces should be enclosed in double\-quote characters\&. Alternate acceptable forms are
73
+ \fINAME\fR
74
+ (the
75
+ \fIVALUE\fR
76
+ defaults to an empty string),
77
+ \fINAME!\fR
78
+ (deletes the
79
+ \fINAME\fR
80
+ attribute) and
81
+ \fINAME=VALUE@\fR
82
+ (does not override
83
+ \fINAME\fR
84
+ attribute if already defined in the source file)\&.
85
+ .sp
86
+ This option may be specified more than once\&.
87
+ .RE
88
+ .PP
89
+ \fB\-b, \-\-backend\fR=\fIBACKEND\fR
90
+ .RS 4
91
+ Backend output file format:
92
+ \fIdocbook45\fR
93
+ or
94
+ \fIhtml5\fR\&. You can also use the backend alias names
95
+ \fIhtml\fR
96
+ (aliased to
97
+ \fIhtml5\fR) or
98
+ \fIdocbook\fR
99
+ (aliased to
100
+ \fIdocbook45\fR)\&. Defaults to
101
+ \fIhtml5\fR\&.
102
+ .RE
103
+ .PP
104
+ \fB\-d, \-\-doctype\fR=\fIDOCTYPE\fR
105
+ .RS 4
106
+ Document type:
107
+ \fIarticle\fR
108
+ or
109
+ \fIbook\fR\&. Sets the root element when using the
110
+ \fIdocbook\fR
111
+ backend and the style class on the HTML body element when using the
112
+ \fIhtml\fR
113
+ backend\&. The
114
+ \fIbook\fR
115
+ document type allows multiple level\-0 section titles in a single document\&. Defaults to
116
+ \fIarticle\fR\&.
117
+ .RE
118
+ .SS "Rendering Control"
119
+ .PP
120
+ \fB\-C, \-\-compact\fR
121
+ .RS 4
122
+ Compact the output by removing blank lines\&. Not enabled by default\&.
123
+ .RE
124
+ .PP
125
+ \fB\-D, \-\-destination\-dir\fR=\fIDIR\fR
126
+ .RS 4
127
+ Destination output directory\&. Defaults to the directory containing the source file, or the working directory if the source is read from a stream\&.
128
+ .RE
129
+ .PP
130
+ \fB\-e, \-\-eruby\fR
131
+ .RS 4
132
+ Specifies the eRuby implementation to use for rendering the built\-in templates\&. Supported values are
133
+ \fIerb\fR
134
+ and
135
+ \fIerubis\fR\&. Defaults to
136
+ \fIerb\fR\&.
137
+ .RE
138
+ .PP
139
+ \fB\-n, \-\-section\-numbers\fR
140
+ .RS 4
141
+ Auto\-number section titles\&. Synonym for
142
+ \fB\-\-attribute numbered\fR\&.
143
+ .RE
144
+ .PP
145
+ \fB\-o, \-\-out\-file\fR=\fIOUT_FILE\fR
146
+ .RS 4
147
+ Write output to file
148
+ \fIOUT_FILE\fR\&. Defaults to the base name of the input file suffixed with
149
+ \fIbackend\fR
150
+ extension\&. If the input is read from standard input, then the output file defaults to stdout\&. If
151
+ \fIOUT_FILE\fR
152
+ is
153
+ \fI\-\fR
154
+ then the standard output is also used\&.
155
+ .RE
156
+ .PP
157
+ \fB\-s, \-\-no\-header\-footer\fR
158
+ .RS 4
159
+ Suppress the document header and footer in the output\&.
160
+ .RE
161
+ .PP
162
+ \fB\-T, \-\-template\-dir\fR=\fIDIR\fR
163
+ .RS 4
164
+ Directory containing custom render templates that override one or more templates from the the built\-in set\&.
165
+ .RE
166
+ .SS "Processing Information"
167
+ .PP
168
+ \fB\-\-trace\fR
169
+ .RS 4
170
+ Include backtrace information on errors\&. Not enabled by default\&.
171
+ .RE
172
+ .PP
173
+ \fB\-v, \-\-verbose\fR
174
+ .RS 4
175
+ Verbosely print processing information and configuration file checks to stderr\&.
176
+ .RE
177
+ .SS "Program Information"
178
+ .PP
179
+ \fB\-h, \-\-help\fR
180
+ .RS 4
181
+ Show the help message\&.
182
+ .RE
183
+ .PP
184
+ \fB\-V, \-\-version\fR
185
+ .RS 4
186
+ Print program version number\&.
187
+ .RE
188
+ .SH "EXIT STATUS"
189
+ .PP
190
+ \fB0\fR
191
+ .RS 4
192
+ Success
193
+ .RE
194
+ .PP
195
+ \fB1\fR
196
+ .RS 4
197
+ Failure (syntax or usage error; configuration error; document processing failure; unexpected error)\&.
198
+ .RE
199
+ .SH "BUGS"
200
+ .sp
201
+ See the \fBAsciidoctor\fR issue tracker: <\fBhttps://github\&.com/erebor/asciidoctor/issues?state=open\fR>
202
+ .SH "AUTHORS"
203
+ .sp
204
+ \fBAsciidoctor\fR was written by Ryan Waldron, Dan Allen and other contributors\&. \fBAsciiDoc\fR was written by Stuart Rackham and has received contributions from many other individuals\&.
205
+ .SH "RESOURCES"
206
+ .sp
207
+ Git source repository on GitHub: <\fBhttps://github\&.com/erebor/asciidoctor\fR>
208
+ .sp
209
+ Main web site: <\fBhttp://asciidoctor\&.org\fR>
210
+ .SH "COPYING"
211
+ .sp
212
+ Copyright (C) Ryan Waldron\&. Free use of this software is granted under the terms of the MIT License\&.
@@ -0,0 +1,156 @@
1
+ asciidoctor(1)
2
+ ==============
3
+ :doctype: manpage
4
+
5
+
6
+ NAME
7
+ ----
8
+ asciidoctor - converts an AsciiDoc source file to HTML, DocBook and other formats
9
+
10
+
11
+ SYNOPSIS
12
+ --------
13
+ *asciidoctor* ['OPTION']... 'FILE'
14
+
15
+
16
+ DESCRIPTION
17
+ -----------
18
+ The asciidoctor(1) command converts the AsciiDoc source file 'FILE' to HTML 5,
19
+ DocBook 4.5 and other output formats.
20
+
21
+ If 'FILE' is '-' then the AsciiDoc source is read from standard input.
22
+
23
+
24
+ OPTIONS
25
+ -------
26
+
27
+ Security Settings
28
+ ~~~~~~~~~~~~~~~~~
29
+
30
+ *-B, --base-dir*='DIR'::
31
+ Base directory containing the document and resources. Defaults to the
32
+ directory containing the source file, or the working directory if the
33
+ source is read from a stream. Can be used as a way to chroot the execution
34
+ of the program.
35
+
36
+ *-S, --safe-mode*='SAFE_MODE'::
37
+ Set safe mode level explicity: 'unsafe', 'safe', 'secure'. Defaults to
38
+ 'secure'. Disables potentially dangerous macros in source files, such as
39
+ include::[].
40
+
41
+ *--safe*::
42
+ Set safe mode to 'safe' from the default safe mode of 'secure'. Enables
43
+ include macros, but restricts access to ancestor paths of source file.
44
+ Provided for compatibility with the asciidoc command.
45
+
46
+ Document Settings
47
+ ~~~~~~~~~~~~~~~~~
48
+
49
+ *-a, --attribute*='ATTRIBUTE'::
50
+ Define, override or delete a document attribute. Command-line attributes
51
+ take precedence over attributes defined in the source file.
52
+ +
53
+ 'ATTRIBUTE' is formatted as a key-value pair, in the form 'NAME=VALUE'. Values
54
+ containing spaces should be enclosed in double-quote characters. Alternate
55
+ acceptable forms are 'NAME' (the 'VALUE' defaults to an empty string), 'NAME!'
56
+ (deletes the 'NAME' attribute) and 'NAME=VALUE@' (does not override 'NAME'
57
+ attribute if already defined in the source file).
58
+ +
59
+ This option may be specified more than once.
60
+
61
+ *-b, --backend*='BACKEND'::
62
+ Backend output file format: 'docbook45' or 'html5'. You can also use the
63
+ backend alias names 'html' (aliased to 'html5') or 'docbook' (aliased to
64
+ 'docbook45'). Defaults to 'html5'.
65
+
66
+ *-d, --doctype*='DOCTYPE'::
67
+ Document type: 'article' or 'book'. Sets the root element when using the
68
+ 'docbook' backend and the style class on the HTML body element when using
69
+ the 'html' backend. The 'book' document type allows multiple level-0
70
+ section titles in a single document. Defaults to 'article'.
71
+
72
+ Rendering Control
73
+ ~~~~~~~~~~~~~~~~~
74
+
75
+ *-C, --compact*::
76
+ Compact the output by removing blank lines. Not enabled by default.
77
+
78
+ *-D, --destination-dir*='DIR'::
79
+ Destination output directory. Defaults to the directory containing the
80
+ source file, or the working directory if the source is read from a stream.
81
+
82
+ *-e, --eruby*::
83
+ Specifies the eRuby implementation to use for rendering the built-in
84
+ templates. Supported values are 'erb' and 'erubis'. Defaults to 'erb'.
85
+
86
+ *-n, --section-numbers*::
87
+ Auto-number section titles. Synonym for *--attribute numbered*.
88
+
89
+ *-o, --out-file*='OUT_FILE'::
90
+ Write output to file 'OUT_FILE'. Defaults to the base name of the input
91
+ file suffixed with 'backend' extension. If the input is read from standard
92
+ input, then the output file defaults to stdout. If 'OUT_FILE' is '-' then
93
+ the standard output is also used.
94
+
95
+ *-s, --no-header-footer*::
96
+ Suppress the document header and footer in the output.
97
+
98
+ *-T, --template-dir*='DIR'::
99
+ Directory containing custom render templates that override one or more
100
+ templates from the the built-in set.
101
+
102
+ Processing Information
103
+ ~~~~~~~~~~~~~~~~~~~~~~
104
+
105
+ *--trace*::
106
+ Include backtrace information on errors. Not enabled by default.
107
+
108
+ *-v, --verbose*::
109
+ Verbosely print processing information and configuration file checks to
110
+ stderr.
111
+
112
+ Program Information
113
+ ~~~~~~~~~~~~~~~~~~~
114
+
115
+ *-h, --help*::
116
+ Show the help message.
117
+
118
+ *-V, --version*::
119
+ Print program version number.
120
+
121
+
122
+ EXIT STATUS
123
+ -----------
124
+ *0*::
125
+ Success
126
+
127
+ *1*::
128
+ Failure (syntax or usage error; configuration error; document processing
129
+ failure; unexpected error).
130
+
131
+
132
+ BUGS
133
+ ----
134
+ See the *Asciidoctor* issue tracker: <**https://github.com/asciidoctor/asciidoctor/issues?state=open**>
135
+
136
+
137
+ AUTHORS
138
+ -------
139
+ *Asciidoctor* was written by Ryan Waldron, Dan Allen and other contributors.
140
+ *AsciiDoc* was written by Stuart Rackham and has received contributions from
141
+ many other individuals.
142
+
143
+
144
+ RESOURCES
145
+ ---------
146
+ Git source repository on GitHub: <**https://github.com/asciidoctor/asciidoctor**>
147
+
148
+ Project web site: <**http://asciidoctor.org**>
149
+
150
+ GitHub organization: <**http://github.com/asciidoctor**>
151
+
152
+
153
+ COPYING
154
+ -------
155
+ Copyright \(C) Ryan Waldron. Free use of this software is granted under the
156
+ terms of the MIT License.
@@ -9,7 +9,7 @@ context 'Attributes' do
9
9
 
10
10
  test 'creates an attribute by fusing a multi-line value' do
11
11
  str = <<-EOS
12
- :description: This is the first +
12
+ :description: This is the first +
13
13
  Ruby implementation of +
14
14
  AsciiDoc.
15
15
  EOS
@@ -86,14 +86,14 @@ endif::holygrail[]
86
86
  end
87
87
 
88
88
  test 'attribute undefined in document options cannot be assigned in document' do
89
- doc = document_from_string(':cash: money', :attributes => {'cash!' => 1 })
89
+ doc = document_from_string(':cash: money', :attributes => {'cash!' => '' })
90
90
  assert_equal nil, doc.attributes['cash']
91
91
  doc = document_from_string(':cash: money', :attributes => {'cash' => nil })
92
92
  assert_equal nil, doc.attributes['cash']
93
93
  end
94
94
 
95
- test 'backend attributes are updated if backend attribute is defined in document' do
96
- doc = document_from_string(':backend: docbook45')
95
+ test 'backend attributes are updated if backend attribute is defined in document and safe mode is less than SERVER' do
96
+ doc = document_from_string(':backend: docbook45', :safe => Asciidoctor::SafeMode::SAFE)
97
97
  assert_equal 'docbook45', doc.attributes['backend']
98
98
  assert doc.attributes.has_key? 'backend-docbook45'
99
99
  assert_equal 'docbook', doc.attributes['basebackend']
@@ -101,7 +101,7 @@ endif::holygrail[]
101
101
  end
102
102
 
103
103
  test 'backend attributes defined in document options overrides backend attribute in document' do
104
- doc = document_from_string(':backend: docbook45', :attributes => {'backend' => 'html5'})
104
+ doc = document_from_string(':backend: docbook45', :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'backend' => 'html5'})
105
105
  assert_equal 'html5', doc.attributes['backend']
106
106
  assert doc.attributes.has_key? 'backend-html5'
107
107
  assert_equal 'html', doc.attributes['basebackend']
@@ -118,6 +118,11 @@ endif::holygrail[]
118
118
  assert_equal "Yo, Tanglefoot!\nBeat Spiderman!", result.css("p").first.content.strip
119
119
  end
120
120
 
121
+ test 'attribute lookup is not case sensitive' do
122
+ result = render_embedded_string(":He-Man: The most powerful man in the universe\n\n{He-Man}")
123
+ assert_xpath '//p[text()="The most powerful man in the universe"]', result, 1
124
+ end
125
+
121
126
  test "render properly with single character name" do
122
127
  html = render_string(":r: Ruby\n\nR is for {r}!")
123
128
  result = Nokogiri::HTML(html)
@@ -220,6 +225,32 @@ of the attribute named foo in your document.
220
225
  output = render_string(input)
221
226
  assert_match(/\{foo\}/, output)
222
227
  end
228
+
229
+ test 'does not show docdir and shows relative docfile if safe mode is SERVER or greater' do
230
+ input = <<-EOS
231
+ * docdir: {docdir}
232
+ * docfile: {docfile}
233
+ EOS
234
+
235
+ docdir = Dir.pwd
236
+ docfile = File.join(docdir, 'sample.asciidoc')
237
+ output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docdir' => docdir, 'docfile' => docfile}
238
+ assert_xpath '//li[1]/p[text()="docdir: "]', output, 1
239
+ assert_xpath '//li[2]/p[text()="docfile: sample.asciidoc"]', output, 1
240
+ end
241
+
242
+ test 'shows absolute docdir and docfile paths if safe mode is less than SERVER' do
243
+ input = <<-EOS
244
+ * docdir: {docdir}
245
+ * docfile: {docfile}
246
+ EOS
247
+
248
+ docdir = Dir.pwd
249
+ docfile = File.join(docdir, 'sample.asciidoc')
250
+ output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => docdir, 'docfile' => docfile}
251
+ assert_xpath %(//li[1]/p[text()="docdir: #{docdir}"]), output, 1
252
+ assert_xpath %(//li[2]/p[text()="docfile: #{docfile}"]), output, 1
253
+ end
223
254
  end
224
255
 
225
256
  context "Intrinsic attributes" do
@@ -241,6 +272,78 @@ of the attribute named foo in your document.
241
272
  html = render_string('<node>&</node>')
242
273
  assert_match(/&lt;node&gt;&amp;&lt;\/node&gt;/, html)
243
274
  end
275
+
276
+ test 'creates counter' do
277
+ input = <<-EOS
278
+ {counter:mycounter}
279
+ EOS
280
+
281
+ doc = document_from_string input
282
+ output = doc.render
283
+ assert_equal 1, doc.attributes['mycounter']
284
+ assert_xpath '//p[text()="1"]', output, 1
285
+ end
286
+
287
+ test 'creates counter silently' do
288
+ input = <<-EOS
289
+ {counter2:mycounter}
290
+ EOS
291
+
292
+ doc = document_from_string input
293
+ output = doc.render
294
+ assert_equal 1, doc.attributes['mycounter']
295
+ assert_xpath '//p[text()="1"]', output, 0
296
+ end
297
+
298
+ test 'creates counter with numeric seed value' do
299
+ input = <<-EOS
300
+ {counter2:mycounter:10}
301
+ EOS
302
+
303
+ doc = document_from_string input
304
+ doc.render
305
+ assert_equal 10, doc.attributes['mycounter']
306
+ end
307
+
308
+ test 'creates counter with character seed value' do
309
+ input = <<-EOS
310
+ {counter2:mycounter:A}
311
+ EOS
312
+
313
+ doc = document_from_string input
314
+ doc.render
315
+ assert_equal 'A', doc.attributes['mycounter']
316
+ end
317
+
318
+ test 'increments counter with numeric value' do
319
+ input = <<-EOS
320
+ :mycounter: 1
321
+
322
+ {counter:mycounter}
323
+
324
+ {mycounter}
325
+ EOS
326
+
327
+ doc = document_from_string input
328
+ output = doc.render
329
+ assert_equal 2, doc.attributes['mycounter']
330
+ assert_xpath '//p[text()="2"]', output, 2
331
+ end
332
+
333
+ test 'increments counter with character value' do
334
+ input = <<-EOS
335
+ :mycounter: @
336
+
337
+ {counter:mycounter}
338
+
339
+ {mycounter}
340
+ EOS
341
+
342
+ doc = document_from_string input
343
+ output = doc.render
344
+ assert_equal 'A', doc.attributes['mycounter']
345
+ assert_xpath '//p[text()="A"]', output, 2
346
+ end
244
347
 
245
348
  end
246
349