asciidoctor 0.1.4 → 1.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +209 -25
- data/{LICENSE → LICENSE.adoc} +4 -3
- data/README.adoc +392 -395
- data/Rakefile +94 -137
- data/benchmark/benchmark.rb +127 -0
- data/benchmark/sample-data/mdbasics.adoc +334 -0
- data/bin/asciidoctor +5 -8
- data/bin/asciidoctor-safe +4 -8
- data/compat/asciidoc.conf +78 -11
- data/compat/font-awesome-3-compat.css +397 -0
- data/data/stylesheets/asciidoctor-default.css +399 -0
- data/data/stylesheets/coderay-asciidoctor.css +89 -0
- data/features/open_block.feature +92 -0
- data/features/pass_block.feature +66 -0
- data/features/step_definitions.rb +42 -0
- data/features/text_formatting.feature +55 -0
- data/features/xref.feature +116 -0
- data/lib/asciidoctor.rb +1155 -605
- data/lib/asciidoctor/abstract_block.rb +157 -71
- data/lib/asciidoctor/abstract_node.rb +150 -93
- data/lib/asciidoctor/attribute_list.rb +85 -90
- data/lib/asciidoctor/block.rb +51 -24
- data/lib/asciidoctor/callouts.rb +4 -7
- data/lib/asciidoctor/cli.rb +3 -0
- data/lib/asciidoctor/cli/invoker.rb +86 -76
- data/lib/asciidoctor/cli/options.rb +111 -61
- data/lib/asciidoctor/converter.rb +232 -0
- data/lib/asciidoctor/converter/base.rb +58 -0
- data/lib/asciidoctor/converter/composite.rb +66 -0
- data/lib/asciidoctor/converter/docbook45.rb +94 -0
- data/lib/asciidoctor/converter/docbook5.rb +684 -0
- data/lib/asciidoctor/converter/factory.rb +225 -0
- data/lib/asciidoctor/converter/html5.rb +1081 -0
- data/lib/asciidoctor/converter/template.rb +296 -0
- data/lib/asciidoctor/core_ext.rb +7 -0
- data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +23 -0
- data/lib/asciidoctor/core_ext/string/chr.rb +6 -0
- data/lib/asciidoctor/core_ext/symbol/length.rb +6 -0
- data/lib/asciidoctor/document.rb +590 -304
- data/lib/asciidoctor/extensions.rb +1100 -308
- data/lib/asciidoctor/helpers.rb +109 -46
- data/lib/asciidoctor/inline.rb +16 -9
- data/lib/asciidoctor/list.rb +23 -15
- data/lib/asciidoctor/opal_ext.rb +4 -0
- data/lib/asciidoctor/opal_ext/comparable.rb +38 -0
- data/lib/asciidoctor/opal_ext/dir.rb +13 -0
- data/lib/asciidoctor/opal_ext/error.rb +2 -0
- data/lib/asciidoctor/opal_ext/file.rb +125 -0
- data/lib/asciidoctor/{lexer.rb → parser.rb} +646 -455
- data/lib/asciidoctor/path_resolver.rb +141 -77
- data/lib/asciidoctor/reader.rb +257 -187
- data/lib/asciidoctor/section.rb +12 -16
- data/lib/asciidoctor/stylesheets.rb +91 -0
- data/lib/asciidoctor/substitutors.rb +1548 -0
- data/lib/asciidoctor/table.rb +73 -57
- data/lib/asciidoctor/timings.rb +39 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +22 -14
- data/man/asciidoctor.adoc +18 -10
- data/test/attributes_test.rb +314 -14
- data/test/blocks_test.rb +763 -118
- data/test/converter_test.rb +352 -0
- data/test/document_test.rb +518 -199
- data/test/extensions_test.rb +273 -103
- data/test/fixtures/asciidoc_index.txt +27 -13
- data/test/fixtures/basic-docinfo.xml +1 -1
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/docinfo.xml +1 -1
- data/test/fixtures/include-file.asciidoc +2 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/invoker_test.rb +173 -61
- data/test/links_test.rb +97 -21
- data/test/lists_test.rb +181 -22
- data/test/options_test.rb +86 -2
- data/test/paragraphs_test.rb +47 -5
- data/test/{lexer_test.rb → parser_test.rb} +128 -57
- data/test/paths_test.rb +36 -1
- data/test/preamble_test.rb +25 -17
- data/test/reader_test.rb +404 -249
- data/test/sections_test.rb +623 -58
- data/test/substitutions_test.rb +609 -132
- data/test/tables_test.rb +198 -24
- data/test/test_helper.rb +101 -31
- data/test/text_test.rb +88 -31
- metadata +160 -64
- data/Gemfile +0 -12
- data/Guardfile +0 -18
- data/asciidoctor.gemspec +0 -143
- data/lib/asciidoctor/backends/_stylesheets.rb +0 -466
- data/lib/asciidoctor/backends/base_template.rb +0 -114
- data/lib/asciidoctor/backends/docbook45.rb +0 -774
- data/lib/asciidoctor/backends/docbook5.rb +0 -103
- data/lib/asciidoctor/backends/html5.rb +0 -1214
- data/lib/asciidoctor/renderer.rb +0 -259
- data/lib/asciidoctor/substituters.rb +0 -1083
- data/test/fixtures/asciidoc.txt +0 -105
- data/test/fixtures/ascshort.txt +0 -32
- data/test/fixtures/list_elements.asciidoc +0 -10
- data/test/renderer_test.rb +0 -162
@@ -169,7 +169,7 @@ link:asciimathml.html[ASCIIMathML] or link:latexmathml.html[LaTeXMathML]
|
|
169
169
|
notation.
|
170
170
|
|
171
171
|
The link:latex-filter.html[AsciiDoc LaTeX filter] translates LaTeX
|
172
|
-
source to
|
172
|
+
source to an image that is automatically inserted into the AsciiDoc
|
173
173
|
output documents.
|
174
174
|
|
175
175
|
AsciiDoc also has 'latexmath' macros for DocBook outputs -- they are
|
@@ -180,8 +180,8 @@ AsciiDoc documents processed by `dblatex(1)`.
|
|
180
180
|
Editor Support
|
181
181
|
--------------
|
182
182
|
- An AsciiDoc syntax highlighter for the Vim text editor is included in the
|
183
|
-
AsciiDoc distribution (see
|
184
|
-
details).
|
183
|
+
AsciiDoc distribution (see the 'Vim Syntax Highlighter' appendix in
|
184
|
+
the 'AsciiDoc User Guide' for details).
|
185
185
|
+
|
186
186
|
.Syntax highlighter screenshot
|
187
187
|
image::images/highlighter.png[height=400,caption="",link="images/highlighter.png"]
|
@@ -194,15 +194,9 @@ image::images/highlighter.png[height=400,caption="",link="images/highlighter.png
|
|
194
194
|
(used by http://projects.gnome.org/gedit/[gedit] and a number of
|
195
195
|
other applications). The project is hosted here:
|
196
196
|
https://launchpad.net/asciidoc-gtk-highlight
|
197
|
-
-
|
198
|
-
|
199
|
-
http://
|
200
|
-
- The http://xpt.sourceforge.net/[*Nix Power Tools project] has
|
201
|
-
released an http://xpt.sourceforge.net/tools/doc-mode/[AsciiDoc
|
202
|
-
syntax highlighter for Emacs].
|
203
|
-
- Terrence Brannon has written
|
204
|
-
http://github.com/metaperl/asciidoc-el[AsciiDoc functions for
|
205
|
-
Emacs].
|
197
|
+
- AsciiDoc resources for the Emacs editor can be found on the
|
198
|
+
http://www.emacswiki.org/emacs/AsciiDoc[AsciiDoc page] at the
|
199
|
+
http://www.emacswiki.org/emacs/EmacsWiki[Emacs Wiki].
|
206
200
|
- Christian Zuckschwerdt has written a
|
207
201
|
https://github.com/zuckschwerdt/asciidoc.tmbundle[TextMate bundle]
|
208
202
|
for AsciiDoc.
|
@@ -255,7 +249,7 @@ and I'll add them to the list.
|
|
255
249
|
- David Hajage has written an AsciiDoc package for the
|
256
250
|
http://www.r-project.org/[R Project] (R is a free software
|
257
251
|
environment for statistical computing). 'ascii' is available on
|
258
|
-
'CRAN' (just run `install.
|
252
|
+
'CRAN' (just run `install.packages("ascii")` from R). Briefly,
|
259
253
|
'ascii' replaces R results in AsciiDoc document with AsciiDoc
|
260
254
|
markup. More information and examples here:
|
261
255
|
http://eusebe.github.com/ascii/.
|
@@ -319,6 +313,26 @@ and I'll add them to the list.
|
|
319
313
|
- The guys from O'Reilly Media have posted an
|
320
314
|
https://github.com/oreillymedia/docbook2asciidoc[XSL Stylesheet to
|
321
315
|
github] that converts DocBook to AsciiDoc.
|
316
|
+
- Lex Trotman has written
|
317
|
+
https://github.com/elextr/flexndex[flexndex], an index generator
|
318
|
+
tool that be used with AsciiDoc.
|
319
|
+
- Michael Haberler has created a
|
320
|
+
https://code.google.com/p/asciidoc-diag-filter/[blockdiag filter for
|
321
|
+
Asciidoc] which embeds http://blockdiag.com/[blockdiag] images in
|
322
|
+
AsciiDoc documents.
|
323
|
+
- Dan Allen has written a
|
324
|
+
https://github.com/mojavelinux/asciidoc-bootstrap-docs-backend[Bootstrap
|
325
|
+
backend] for AsciiDoc.
|
326
|
+
- Steven Boscarine has written
|
327
|
+
https://github.com/StevenBoscarine/JavaAsciidocWrapper[Maven wrapper for AsciiDoc].
|
328
|
+
- Christian Goltz has written
|
329
|
+
https://github.com/christiangoltz/shaape[Shaape], an Ascii art to
|
330
|
+
image converter for AsciiDoc.
|
331
|
+
- Eduardo Santana has written an
|
332
|
+
https://github.com/edusantana/asciidoc-highlight[Asciidoc Highlight
|
333
|
+
for Notepad++].
|
334
|
+
- http://www.geany.org/[Geany] 1.23 adds document structure support
|
335
|
+
for AsciiDoc.
|
322
336
|
|
323
337
|
Please let me know if any of these links need updating.
|
324
338
|
|
data/test/fixtures/docinfo.xml
CHANGED
@@ -7,6 +7,7 @@ sixth line of included content
|
|
7
7
|
seventh line of included content
|
8
8
|
eighth line of included content
|
9
9
|
|
10
|
+
// tag::snippet[]
|
10
11
|
// tag::snippetA[]
|
11
12
|
snippetA content
|
12
13
|
// end::snippetA[]
|
@@ -16,6 +17,7 @@ non-tagged content
|
|
16
17
|
// tag::snippetB[]
|
17
18
|
snippetB content
|
18
19
|
// end::snippetB[]
|
20
|
+
// end::snippet[]
|
19
21
|
|
20
22
|
more non-tagged content
|
21
23
|
|
data/test/invoker_test.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
2
|
+
unless defined? ASCIIDOCTOR_PROJECT_DIR
|
3
|
+
$: << File.dirname(__FILE__); $:.uniq!
|
4
|
+
require 'test_helper'
|
5
|
+
end
|
3
6
|
require 'asciidoctor/cli/options'
|
4
7
|
require 'asciidoctor/cli/invoker'
|
5
8
|
|
@@ -7,9 +10,9 @@ context 'Invoker' do
|
|
7
10
|
test 'should parse source and render as html5 article by default' do
|
8
11
|
invoker = nil
|
9
12
|
output = nil
|
10
|
-
redirect_streams do |
|
13
|
+
redirect_streams do |out, err|
|
11
14
|
invoker = invoke_cli %w(-o -)
|
12
|
-
output =
|
15
|
+
output = out.string
|
13
16
|
end
|
14
17
|
assert !invoker.nil?
|
15
18
|
doc = invoker.document
|
@@ -58,6 +61,18 @@ context 'Invoker' do
|
|
58
61
|
assert_xpath '/*[@class="paragraph"]/p[text()="content"]', output, 1
|
59
62
|
end
|
60
63
|
|
64
|
+
test 'should not fail to rewind input if reading document from stdin' do
|
65
|
+
io = STDIN.dup
|
66
|
+
class << io
|
67
|
+
def readlines
|
68
|
+
['paragraph']
|
69
|
+
end
|
70
|
+
end
|
71
|
+
invoker = invoke_cli_to_buffer(%w(-s), '-') { io }
|
72
|
+
assert_equal 0, invoker.code
|
73
|
+
assert_equal 1, invoker.document.blocks.size
|
74
|
+
end
|
75
|
+
|
61
76
|
test 'should accept document from stdin and write to output file' do
|
62
77
|
sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
|
63
78
|
begin
|
@@ -73,7 +88,7 @@ context 'Invoker' do
|
|
73
88
|
assert_equal sample_outpath, doc.attr('outfile')
|
74
89
|
assert File.exist?(sample_outpath)
|
75
90
|
ensure
|
76
|
-
FileUtils
|
91
|
+
FileUtils.rm_f(sample_outpath)
|
77
92
|
end
|
78
93
|
end
|
79
94
|
|
@@ -86,31 +101,62 @@ context 'Invoker' do
|
|
86
101
|
end
|
87
102
|
|
88
103
|
test 'should display version and exit' do
|
89
|
-
|
90
|
-
|
91
|
-
|
104
|
+
expected = %(Asciidoctor #{Asciidoctor::VERSION} [http://asciidoctor.org]\nRuntime Environment (#{RUBY_DESCRIPTION}))
|
105
|
+
['--version', '-V'].each do |switch|
|
106
|
+
actual = nil
|
107
|
+
redirect_streams do |out, err|
|
108
|
+
invoke_cli [switch]
|
109
|
+
actual = out.string.rstrip
|
110
|
+
end
|
111
|
+
assert_equal expected, actual, %(Expected to print version when using #{switch} switch)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
test 'should print warnings to stderr by default' do
|
116
|
+
input = <<-EOS
|
117
|
+
2. second
|
118
|
+
3. third
|
119
|
+
EOS
|
120
|
+
warnings = nil
|
121
|
+
redirect_streams do |out, err|
|
122
|
+
invoke_cli_to_buffer(%w(-o /dev/null), '-') { input }
|
123
|
+
warnings = err.string
|
92
124
|
end
|
125
|
+
assert_match(/WARNING/, warnings)
|
126
|
+
end
|
127
|
+
|
128
|
+
test 'should silence warnings if -q flag is specified' do
|
129
|
+
input = <<-EOS
|
130
|
+
2. second
|
131
|
+
3. third
|
132
|
+
EOS
|
133
|
+
warnings = nil
|
134
|
+
redirect_streams do |out, err|
|
135
|
+
invoke_cli_to_buffer(%w(-q -o /dev/null), '-') { input }
|
136
|
+
warnings = err.string
|
137
|
+
end
|
138
|
+
assert_equal '', warnings
|
93
139
|
end
|
94
140
|
|
95
141
|
test 'should report usage if no input file given' do
|
96
|
-
redirect_streams do |
|
142
|
+
redirect_streams do |out, err|
|
97
143
|
invoke_cli [], nil
|
98
|
-
assert_match(/Usage:/,
|
144
|
+
assert_match(/Usage:/, err.string)
|
99
145
|
end
|
100
146
|
end
|
101
147
|
|
102
148
|
test 'should report error if input file does not exist' do
|
103
|
-
redirect_streams do |
|
149
|
+
redirect_streams do |out, err|
|
104
150
|
invoker = invoke_cli [], 'missing_file.asciidoc'
|
105
|
-
assert_match(/input file .* missing/,
|
151
|
+
assert_match(/input file .* missing/, err.string)
|
106
152
|
assert_equal 1, invoker.code
|
107
153
|
end
|
108
154
|
end
|
109
155
|
|
110
156
|
test 'should treat extra arguments as files' do
|
111
|
-
redirect_streams do |
|
157
|
+
redirect_streams do |out, err|
|
112
158
|
invoker = invoke_cli %w(-o /dev/null extra arguments sample.asciidoc), nil
|
113
|
-
assert_match(/input file .* missing/,
|
159
|
+
assert_match(/input file .* missing/, err.string)
|
114
160
|
assert_equal 1, invoker.code
|
115
161
|
end
|
116
162
|
end
|
@@ -130,7 +176,7 @@ context 'Invoker' do
|
|
130
176
|
assert_xpath '/html/head/title[text() = "Document Title"]', output, 1
|
131
177
|
assert_xpath '/html/body/*[@id="header"]/h1[text() = "Document Title"]', output, 1
|
132
178
|
ensure
|
133
|
-
FileUtils
|
179
|
+
FileUtils.rm_f(sample_outpath)
|
134
180
|
end
|
135
181
|
end
|
136
182
|
|
@@ -138,7 +184,7 @@ context 'Invoker' do
|
|
138
184
|
destination_path = File.expand_path(File.join(File.dirname(__FILE__), 'test_output'))
|
139
185
|
sample_outpath = File.join(destination_path, 'sample.html')
|
140
186
|
begin
|
141
|
-
FileUtils
|
187
|
+
FileUtils.mkdir_p(destination_path)
|
142
188
|
# QUESTION should -D be relative to working directory or source directory?
|
143
189
|
invoker = invoke_cli %w(-D test/test_output)
|
144
190
|
#invoker = invoke_cli %w(-D ../../test/test_output)
|
@@ -146,8 +192,8 @@ context 'Invoker' do
|
|
146
192
|
assert_equal sample_outpath, doc.attr('outfile')
|
147
193
|
assert File.exist?(sample_outpath)
|
148
194
|
ensure
|
149
|
-
FileUtils
|
150
|
-
FileUtils
|
195
|
+
FileUtils.rm_f(sample_outpath)
|
196
|
+
FileUtils.rmdir(destination_path)
|
151
197
|
end
|
152
198
|
end
|
153
199
|
|
@@ -159,14 +205,14 @@ context 'Invoker' do
|
|
159
205
|
assert_equal sample_outpath, doc.attr('outfile')
|
160
206
|
assert File.exist?(sample_outpath)
|
161
207
|
ensure
|
162
|
-
FileUtils
|
208
|
+
FileUtils.rm_f(sample_outpath)
|
163
209
|
end
|
164
210
|
end
|
165
211
|
|
166
|
-
test 'should copy default
|
212
|
+
test 'should copy default stylesheet to target directory if linkcss is specified' do
|
167
213
|
sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
|
168
214
|
asciidoctor_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor.css'))
|
169
|
-
coderay_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor
|
215
|
+
coderay_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'coderay-asciidoctor.css'))
|
170
216
|
begin
|
171
217
|
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a source-highlighter=coderay)
|
172
218
|
invoker.document
|
@@ -174,13 +220,13 @@ context 'Invoker' do
|
|
174
220
|
assert File.exist?(asciidoctor_stylesheet)
|
175
221
|
assert File.exist?(coderay_stylesheet)
|
176
222
|
ensure
|
177
|
-
FileUtils
|
178
|
-
FileUtils
|
179
|
-
FileUtils
|
223
|
+
FileUtils.rm_f(sample_outpath)
|
224
|
+
FileUtils.rm_f(asciidoctor_stylesheet)
|
225
|
+
FileUtils.rm_f(coderay_stylesheet)
|
180
226
|
end
|
181
227
|
end
|
182
228
|
|
183
|
-
test 'should not copy default
|
229
|
+
test 'should not copy default stylesheet to target directory if linkcss is set and copycss is unset' do
|
184
230
|
sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
|
185
231
|
default_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor.css'))
|
186
232
|
begin
|
@@ -189,7 +235,44 @@ context 'Invoker' do
|
|
189
235
|
assert File.exist?(sample_outpath)
|
190
236
|
assert !File.exist?(default_stylesheet)
|
191
237
|
ensure
|
192
|
-
FileUtils
|
238
|
+
FileUtils.rm_f(sample_outpath)
|
239
|
+
FileUtils.rm_f(default_stylesheet)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
test 'should copy custom stylesheet to target directory if stylesheet and linkcss is specified' do
|
244
|
+
destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output'))
|
245
|
+
sample_outpath = File.join destdir, 'sample-output.html'
|
246
|
+
stylesdir = File.join destdir, 'styles'
|
247
|
+
custom_stylesheet = File.join stylesdir, 'custom.css'
|
248
|
+
begin
|
249
|
+
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a copycss=stylesheets/custom.css -a stylesdir=./styles -a stylesheet=custom.css)
|
250
|
+
invoker.document
|
251
|
+
assert File.exist?(sample_outpath)
|
252
|
+
assert File.exist?(custom_stylesheet)
|
253
|
+
ensure
|
254
|
+
FileUtils.rm_f(sample_outpath)
|
255
|
+
FileUtils.rm_f(custom_stylesheet)
|
256
|
+
FileUtils.rmdir(stylesdir)
|
257
|
+
FileUtils.rmdir(destdir)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
test 'should not copy custom stylesheet to target directory if stylesheet and linkcss are set and copycss is unset' do
|
262
|
+
destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output'))
|
263
|
+
sample_outpath = File.join destdir, 'sample-output.html'
|
264
|
+
stylesdir = File.join destdir, 'styles'
|
265
|
+
custom_stylesheet = File.join stylesdir, 'custom.css'
|
266
|
+
begin
|
267
|
+
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a stylesdir=./styles -a stylesheet=custom.css -a copycss!)
|
268
|
+
invoker.document
|
269
|
+
assert File.exist?(sample_outpath)
|
270
|
+
assert !File.exist?(custom_stylesheet)
|
271
|
+
ensure
|
272
|
+
FileUtils.rm_f(sample_outpath)
|
273
|
+
FileUtils.rm_f(custom_stylesheet)
|
274
|
+
FileUtils.rmdir(stylesdir) if File.directory? stylesdir
|
275
|
+
FileUtils.rmdir(destdir)
|
193
276
|
end
|
194
277
|
end
|
195
278
|
|
@@ -197,24 +280,55 @@ context 'Invoker' do
|
|
197
280
|
basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
|
198
281
|
sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.html'))
|
199
282
|
begin
|
200
|
-
invoke_cli_with_filenames
|
283
|
+
invoke_cli_with_filenames [], %w(basic.asciidoc sample.asciidoc)
|
284
|
+
assert File.exist?(basic_outpath)
|
285
|
+
assert File.exist?(sample_outpath)
|
286
|
+
ensure
|
287
|
+
FileUtils.rm_f(basic_outpath)
|
288
|
+
FileUtils.rm_f(sample_outpath)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
test 'options should not be modified when processing multiple files' do
|
293
|
+
destination_path = File.expand_path(File.join(File.dirname(__FILE__), 'test_output'))
|
294
|
+
basic_outpath = File.join(destination_path, 'basic.htm')
|
295
|
+
sample_outpath = File.join(destination_path, 'sample.htm')
|
296
|
+
begin
|
297
|
+
invoke_cli_with_filenames %w(-D test/test_output -a outfilesuffix=.htm), %w(basic.asciidoc sample.asciidoc)
|
201
298
|
assert File.exist?(basic_outpath)
|
202
299
|
assert File.exist?(sample_outpath)
|
203
300
|
ensure
|
204
|
-
FileUtils
|
205
|
-
FileUtils
|
301
|
+
FileUtils.rm_f(basic_outpath)
|
302
|
+
FileUtils.rm_f(sample_outpath)
|
303
|
+
FileUtils.rmdir(destination_path)
|
206
304
|
end
|
207
305
|
end
|
208
306
|
|
209
307
|
test 'should render all files that matches a glob expression' do
|
210
308
|
basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
|
211
309
|
begin
|
212
|
-
invoke_cli_to_buffer
|
310
|
+
invoke_cli_to_buffer [], "ba*.asciidoc"
|
213
311
|
assert File.exist?(basic_outpath)
|
214
312
|
ensure
|
215
|
-
FileUtils
|
313
|
+
FileUtils.rm_f(basic_outpath)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
test 'should render all files that matches an absolute path glob expression' do
|
318
|
+
basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
|
319
|
+
glob = File.join(File.dirname(__FILE__), 'fixtures', 'ba*.asciidoc')
|
320
|
+
# test Windows using backslash-style pathname
|
321
|
+
if ::File::ALT_SEPARATOR == '\\'
|
322
|
+
glob = glob.tr '/', '\\'
|
216
323
|
end
|
217
|
-
|
324
|
+
|
325
|
+
begin
|
326
|
+
invoke_cli_to_buffer [], glob
|
327
|
+
assert File.exist?(basic_outpath)
|
328
|
+
ensure
|
329
|
+
FileUtils.rm_f(basic_outpath)
|
330
|
+
end
|
331
|
+
end
|
218
332
|
|
219
333
|
test 'should suppress header footer if specified' do
|
220
334
|
invoker = invoke_cli_to_buffer %w(-s -o -)
|
@@ -223,28 +337,12 @@ context 'Invoker' do
|
|
223
337
|
assert_xpath '/*[@id="preamble"]', output, 1
|
224
338
|
end
|
225
339
|
|
226
|
-
test 'should not compact output by default' do
|
227
|
-
# NOTE we are relying on the fact that the template leaves blank lines
|
228
|
-
# this will always fail when using a template engine which strips blank lines by default
|
229
|
-
invoker = invoke_cli_to_buffer(%w(-o -), '-') { '* content' }
|
230
|
-
output = invoker.read_output
|
231
|
-
assert_match(/\n[[:blank:]]*\n/, output)
|
232
|
-
end
|
233
|
-
|
234
|
-
test 'should compact output if specified' do
|
235
|
-
# NOTE we are relying on the fact that the template leaves blank lines
|
236
|
-
# this will always succeed when using a template engine which strips blank lines by default
|
237
|
-
invoker = invoke_cli_to_buffer(%w(-C -s -o -), '-') { '* content' }
|
238
|
-
output = invoker.read_output
|
239
|
-
assert_no_match(/\n[[:blank:]]*\n/, output)
|
240
|
-
end
|
241
|
-
|
242
340
|
test 'should output a trailing endline to stdout' do
|
243
341
|
invoker = nil
|
244
342
|
output = nil
|
245
|
-
redirect_streams do |
|
343
|
+
redirect_streams do |out, err|
|
246
344
|
invoker = invoke_cli %w(-o -)
|
247
|
-
output =
|
345
|
+
output = out.string
|
248
346
|
end
|
249
347
|
assert !invoker.nil?
|
250
348
|
assert !output.nil?
|
@@ -261,7 +359,7 @@ context 'Invoker' do
|
|
261
359
|
end
|
262
360
|
|
263
361
|
test 'should set backend to docbook45 if specified' do
|
264
|
-
invoker = invoke_cli_to_buffer %w(-b docbook45 -o -)
|
362
|
+
invoker = invoke_cli_to_buffer %w(-b docbook45 -a xmlns -o -)
|
265
363
|
doc = invoker.document
|
266
364
|
assert_equal 'docbook45', doc.attr('backend')
|
267
365
|
assert_equal '.xml', doc.attr('outfilesuffix')
|
@@ -289,7 +387,10 @@ context 'Invoker' do
|
|
289
387
|
custom_backend_root = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends'))
|
290
388
|
invoker = invoke_cli_to_buffer %W(-E haml -T #{custom_backend_root} -o -)
|
291
389
|
doc = invoker.document
|
292
|
-
assert doc.
|
390
|
+
assert doc.converter.is_a? Asciidoctor::Converter::CompositeConverter
|
391
|
+
selected = doc.converter.find_converter 'paragraph'
|
392
|
+
assert selected.is_a? Asciidoctor::Converter::TemplateConverter
|
393
|
+
assert selected.templates['paragraph'].is_a? Tilt::HamlTemplate
|
293
394
|
end
|
294
395
|
|
295
396
|
test 'should load custom templates from multiple template directories' do
|
@@ -394,17 +495,13 @@ context 'Invoker' do
|
|
394
495
|
require 'open3'
|
395
496
|
#cmd = "#{executable} -o - --trace #{input_path}"
|
396
497
|
cmd = "#{File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']} #{executable} -o - --trace #{input_path}"
|
397
|
-
_,
|
398
|
-
stderr_lines = stderr.readlines
|
399
|
-
|
400
|
-
assert stderr_lines.empty?, 'Command failed. Expected to receive a rendered document.'
|
401
|
-
stdout_lines =
|
498
|
+
_, out, _ = Open3.popen3 cmd
|
499
|
+
#stderr_lines = stderr.readlines
|
500
|
+
# warnings may be issued, so don't assert on stderr
|
501
|
+
#assert stderr_lines.empty?, 'Command failed. Expected to receive a rendered document.'
|
502
|
+
stdout_lines = out.readlines
|
402
503
|
assert !stdout_lines.empty?
|
403
|
-
if Asciidoctor::FORCE_ENCODING
|
404
|
-
stdout_lines.each do |l|
|
405
|
-
l.force_encoding Encoding::UTF_8
|
406
|
-
end
|
407
|
-
end
|
504
|
+
stdout_lines.each {|l| l.force_encoding Encoding::UTF_8 } if Asciidoctor::FORCE_ENCODING
|
408
505
|
stdout_str = stdout_lines.join
|
409
506
|
assert stdout_str.include?('Codierungen sind verrückt auf älteren Versionen von Ruby')
|
410
507
|
ensure
|
@@ -412,4 +509,19 @@ context 'Invoker' do
|
|
412
509
|
end
|
413
510
|
end
|
414
511
|
|
512
|
+
test 'should print timings when -t flag is specified' do
|
513
|
+
input = <<-EOS
|
514
|
+
Sample *AsciiDoc*
|
515
|
+
EOS
|
516
|
+
invoker = nil
|
517
|
+
error = nil
|
518
|
+
redirect_streams do |out, err|
|
519
|
+
invoker = invoke_cli(%w(-t -o /dev/null), '-') { input }
|
520
|
+
error = err.string
|
521
|
+
end
|
522
|
+
assert !invoker.nil?
|
523
|
+
assert !error.nil?
|
524
|
+
assert_match(/Total time/, error)
|
525
|
+
end
|
526
|
+
|
415
527
|
end
|