asciidoctor 1.5.8 → 2.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.adoc +628 -45
- data/LICENSE +2 -1
- data/README-de.adoc +28 -38
- data/README-fr.adoc +30 -43
- data/README-jp.adoc +255 -201
- data/README-zh_CN.adoc +40 -44
- data/README.adoc +170 -143
- data/asciidoctor.gemspec +22 -34
- data/bin/asciidoctor +5 -4
- data/data/locale/attributes-ar.adoc +4 -3
- data/data/locale/attributes-be.adoc +23 -0
- data/data/locale/attributes-bg.adoc +4 -3
- data/data/locale/attributes-ca.adoc +6 -5
- data/data/locale/attributes-cs.adoc +4 -3
- data/data/locale/attributes-da.adoc +6 -5
- data/data/locale/attributes-de.adoc +6 -5
- data/data/locale/attributes-en.adoc +4 -4
- data/data/locale/attributes-es.adoc +6 -5
- data/data/locale/attributes-fa.adoc +4 -3
- data/data/locale/attributes-fi.adoc +4 -3
- data/data/locale/attributes-fr.adoc +8 -7
- data/data/locale/attributes-hu.adoc +4 -3
- data/data/locale/attributes-id.adoc +4 -3
- data/data/locale/attributes-it.adoc +6 -5
- data/data/locale/attributes-ja.adoc +4 -3
- data/data/locale/{attributes-kr.adoc → attributes-ko.adoc} +4 -3
- data/data/locale/attributes-nb.adoc +4 -3
- data/data/locale/attributes-nl.adoc +6 -5
- data/data/locale/attributes-nn.adoc +4 -3
- data/data/locale/attributes-pl.adoc +8 -7
- data/data/locale/attributes-pt.adoc +6 -5
- data/data/locale/attributes-pt_BR.adoc +6 -5
- data/data/locale/attributes-ro.adoc +4 -3
- data/data/locale/attributes-ru.adoc +6 -5
- data/data/locale/attributes-sr.adoc +4 -4
- data/data/locale/attributes-sr_Latn.adoc +4 -4
- data/data/locale/attributes-sv.adoc +4 -4
- data/data/locale/attributes-th.adoc +23 -0
- data/data/locale/attributes-tr.adoc +4 -3
- data/data/locale/attributes-uk.adoc +6 -5
- data/data/locale/attributes-vi.adoc +23 -0
- data/data/locale/attributes-zh_CN.adoc +4 -3
- data/data/locale/attributes-zh_TW.adoc +4 -3
- data/data/reference/syntax.adoc +296 -0
- data/data/stylesheets/asciidoctor-default.css +120 -114
- data/data/stylesheets/coderay-asciidoctor.css +15 -17
- data/lib/asciidoctor/abstract_block.rb +146 -140
- data/lib/asciidoctor/abstract_node.rb +152 -170
- data/lib/asciidoctor/attribute_list.rb +77 -89
- data/lib/asciidoctor/block.rb +29 -28
- data/lib/asciidoctor/callouts.rb +4 -2
- data/lib/asciidoctor/cli/invoker.rb +20 -24
- data/lib/asciidoctor/cli/options.rb +107 -96
- data/lib/asciidoctor/cli.rb +3 -2
- data/lib/asciidoctor/convert.rb +199 -0
- data/lib/asciidoctor/converter/composite.rb +40 -48
- data/lib/asciidoctor/converter/docbook5.rb +627 -644
- data/lib/asciidoctor/converter/html5.rb +1053 -951
- data/lib/asciidoctor/converter/manpage.rb +581 -532
- data/lib/asciidoctor/converter/template.rb +232 -271
- data/lib/asciidoctor/converter.rb +370 -185
- data/lib/asciidoctor/core_ext/float/truncate.rb +20 -0
- data/lib/asciidoctor/core_ext/hash/merge.rb +8 -0
- data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
- data/lib/asciidoctor/core_ext.rb +8 -17
- data/lib/asciidoctor/document.rb +503 -461
- data/lib/asciidoctor/extensions.rb +127 -174
- data/lib/asciidoctor/helpers.rb +184 -107
- data/lib/asciidoctor/inline.rb +9 -12
- data/lib/asciidoctor/list.rb +11 -29
- data/lib/asciidoctor/load.rb +119 -0
- data/lib/asciidoctor/logging.rb +22 -17
- data/lib/asciidoctor/parser.rb +673 -719
- data/lib/asciidoctor/path_resolver.rb +48 -33
- data/lib/asciidoctor/reader.rb +383 -338
- data/lib/asciidoctor/rouge_ext.rb +39 -0
- data/lib/asciidoctor/rx.rb +723 -0
- data/lib/asciidoctor/section.rb +17 -16
- data/lib/asciidoctor/stylesheets.rb +19 -37
- data/lib/asciidoctor/substitutors.rb +926 -1022
- data/lib/asciidoctor/syntax_highlighter/coderay.rb +88 -0
- data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +34 -0
- data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
- data/lib/asciidoctor/syntax_highlighter/prettify.rb +30 -0
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +157 -0
- data/lib/asciidoctor/syntax_highlighter/rouge.rb +143 -0
- data/lib/asciidoctor/syntax_highlighter.rb +253 -0
- data/lib/asciidoctor/table.rb +152 -114
- data/lib/asciidoctor/timings.rb +7 -5
- data/lib/asciidoctor/version.rb +2 -1
- data/lib/asciidoctor/writer.rb +30 -0
- data/lib/asciidoctor.rb +266 -1340
- data/man/asciidoctor.1 +49 -47
- data/man/asciidoctor.adoc +54 -45
- metadata +50 -245
- data/CONTRIBUTING.adoc +0 -185
- data/Gemfile +0 -60
- data/Rakefile +0 -129
- data/bin/asciidoctor-safe +0 -15
- data/features/open_block.feature +0 -92
- data/features/pass_block.feature +0 -66
- data/features/step_definitions.rb +0 -49
- data/features/text_formatting.feature +0 -57
- data/features/xref.feature +0 -1039
- data/lib/asciidoctor/converter/base.rb +0 -59
- data/lib/asciidoctor/converter/docbook45.rb +0 -93
- data/lib/asciidoctor/converter/factory.rb +0 -226
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
- data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
- data/test/api_test.rb +0 -1240
- data/test/attribute_list_test.rb +0 -242
- data/test/attributes_test.rb +0 -1623
- data/test/blocks_test.rb +0 -3870
- data/test/converter_test.rb +0 -470
- data/test/document_test.rb +0 -1853
- data/test/extensions_test.rb +0 -1560
- data/test/fixtures/asciidoc_index.txt +0 -521
- data/test/fixtures/basic-docinfo-footer.html +0 -6
- data/test/fixtures/basic-docinfo-footer.xml +0 -8
- data/test/fixtures/basic-docinfo.html +0 -1
- data/test/fixtures/basic-docinfo.xml +0 -4
- data/test/fixtures/basic.asciidoc +0 -5
- data/test/fixtures/chapter-a.adoc +0 -3
- data/test/fixtures/child-include.adoc +0 -5
- data/test/fixtures/circle.svg +0 -9
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
- data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
- data/test/fixtures/docinfo-footer.html +0 -1
- data/test/fixtures/docinfo-footer.xml +0 -9
- data/test/fixtures/docinfo.html +0 -1
- data/test/fixtures/docinfo.xml +0 -3
- data/test/fixtures/doctime-localtime.adoc +0 -2
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +0 -13
- data/test/fixtures/file-with-missing-include.adoc +0 -1
- data/test/fixtures/grandchild-include.adoc +0 -3
- data/test/fixtures/hello-asciidoctor.pdf +0 -69
- data/test/fixtures/include-file.asciidoc +0 -24
- data/test/fixtures/include-file.jsx +0 -8
- data/test/fixtures/include-file.ml +0 -3
- data/test/fixtures/include-file.xml +0 -5
- data/test/fixtures/lists.adoc +0 -96
- data/test/fixtures/master.adoc +0 -5
- data/test/fixtures/mismatched-end-tag.adoc +0 -7
- data/test/fixtures/other-chapters.adoc +0 -11
- data/test/fixtures/outer-include.adoc +0 -5
- data/test/fixtures/parent-include-restricted.adoc +0 -5
- data/test/fixtures/parent-include.adoc +0 -5
- data/test/fixtures/sample.asciidoc +0 -30
- data/test/fixtures/section-a.adoc +0 -4
- data/test/fixtures/stylesheets/custom.css +0 -3
- data/test/fixtures/subdir/index.adoc +0 -3
- data/test/fixtures/subdir/inner-include.adoc +0 -3
- data/test/fixtures/subdir/middle-include.adoc +0 -5
- data/test/fixtures/subs-docinfo.html +0 -2
- data/test/fixtures/subs.adoc +0 -6
- data/test/fixtures/tagged-class-enclosed.rb +0 -25
- data/test/fixtures/tagged-class.rb +0 -23
- data/test/fixtures/tip.gif +0 -0
- data/test/fixtures/unclosed-tag.adoc +0 -3
- data/test/fixtures/unexpected-end-tag.adoc +0 -4
- data/test/invoker_test.rb +0 -745
- data/test/links_test.rb +0 -855
- data/test/lists_test.rb +0 -5151
- data/test/logger_test.rb +0 -211
- data/test/manpage_test.rb +0 -660
- data/test/options_test.rb +0 -262
- data/test/paragraphs_test.rb +0 -562
- data/test/parser_test.rb +0 -742
- data/test/paths_test.rb +0 -395
- data/test/preamble_test.rb +0 -173
- data/test/reader_test.rb +0 -2161
- data/test/sections_test.rb +0 -3575
- data/test/substitutions_test.rb +0 -2066
- data/test/tables_test.rb +0 -2036
- data/test/test_helper.rb +0 -447
- data/test/text_test.rb +0 -309
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
module Asciidoctor
|
3
3
|
# Public: Handles all operations for resolving, cleaning and joining paths.
|
4
4
|
# This class includes operations for handling both web paths (request URIs) and
|
@@ -84,7 +84,7 @@ module Asciidoctor
|
|
84
84
|
# => 'C:/data/docs/css'
|
85
85
|
#
|
86
86
|
# begin
|
87
|
-
# resolver.system_path('../../../css', '../../..', '/path/to/docs', :
|
87
|
+
# resolver.system_path('../../../css', '../../..', '/path/to/docs', recover: false)
|
88
88
|
# rescue SecurityError => e
|
89
89
|
# puts e.message
|
90
90
|
# end
|
@@ -109,7 +109,7 @@ class PathResolver
|
|
109
109
|
SLASH = '/'
|
110
110
|
BACKSLASH = '\\'
|
111
111
|
DOUBLE_SLASH = '//'
|
112
|
-
WindowsRootRx =
|
112
|
+
WindowsRootRx = %r(^(?:[a-zA-Z]:)?[\\/])
|
113
113
|
|
114
114
|
attr_accessor :file_separator
|
115
115
|
attr_accessor :working_dir
|
@@ -206,8 +206,9 @@ class PathResolver
|
|
206
206
|
|
207
207
|
# Public: Calculate the relative path to this absolute path from the specified base directory
|
208
208
|
#
|
209
|
-
# If neither path or base are absolute paths,
|
210
|
-
# within the base directory,
|
209
|
+
# If neither path or base are absolute paths, the path is not contained
|
210
|
+
# within the base directory, or the relative path cannot be computed, the
|
211
|
+
# original path is returned work is done.
|
211
212
|
#
|
212
213
|
# path - [String] an absolute filename.
|
213
214
|
# base - [String] an absolute base directory.
|
@@ -218,7 +219,11 @@ class PathResolver
|
|
218
219
|
if (offset = descends_from? path, base)
|
219
220
|
path.slice offset, path.length
|
220
221
|
else
|
221
|
-
|
222
|
+
begin
|
223
|
+
(Pathname.new path).relative_path_from(Pathname.new base).to_s
|
224
|
+
rescue
|
225
|
+
path
|
226
|
+
end
|
222
227
|
end
|
223
228
|
else
|
224
229
|
path
|
@@ -285,8 +290,8 @@ class PathResolver
|
|
285
290
|
# ex. ./sample/path
|
286
291
|
elsif posix_path.start_with? DOT_SLASH
|
287
292
|
root = DOT_SLASH
|
288
|
-
# else ex. sample/path
|
289
293
|
end
|
294
|
+
# otherwise ex. sample/path
|
290
295
|
elsif root? posix_path
|
291
296
|
# ex. //sample/path
|
292
297
|
if unc? posix_path
|
@@ -301,8 +306,8 @@ class PathResolver
|
|
301
306
|
# ex. ./sample/path
|
302
307
|
elsif posix_path.start_with? DOT_SLASH
|
303
308
|
root = DOT_SLASH
|
304
|
-
# else ex. sample/path
|
305
309
|
end
|
310
|
+
# otherwise ex. sample/path
|
306
311
|
|
307
312
|
path_segments = (root ? (posix_path.slice root.length, posix_path.length) : posix_path).split SLASH
|
308
313
|
# strip out all dot entries
|
@@ -326,11 +331,12 @@ class PathResolver
|
|
326
331
|
|
327
332
|
# Public: Securely resolve a system path
|
328
333
|
#
|
329
|
-
#
|
330
|
-
#
|
331
|
-
# that
|
332
|
-
# path
|
333
|
-
#
|
334
|
+
# Resolves the target to an absolute path on the current filesystem. The target is assumed to be
|
335
|
+
# relative to the start path, jail path, or working directory (specified in the constructor), in
|
336
|
+
# that order. If a jail path is specified, the resolved path is forced to descend from the jail
|
337
|
+
# path. If a jail path is not provided, the resolved path may be any location on the system. If
|
338
|
+
# the target is an absolute path, use it as is (unless it breaches the jail path). Expands all
|
339
|
+
# parent and self references in the resolved path.
|
334
340
|
#
|
335
341
|
# target - the String target path
|
336
342
|
# start - the String start path from which to resolve a relative target; falls back to jail, if
|
@@ -342,8 +348,9 @@ class PathResolver
|
|
342
348
|
# automatically recover when an illegal path is encountered
|
343
349
|
# * :target_name is used in messages to refer to the path being resolved
|
344
350
|
#
|
345
|
-
#
|
346
|
-
# if specified. The path is posixified and all parent and self references in the path
|
351
|
+
# Returns an absolute String path relative to the start path, if specified, and confined to the
|
352
|
+
# jail path, if specified. The path is posixified and all parent and self references in the path
|
353
|
+
# are expanded.
|
347
354
|
def system_path target, start = nil, jail = nil, opts = {}
|
348
355
|
if jail
|
349
356
|
raise ::SecurityError, %(Jail is not an absolute path: #{jail}) unless root? jail
|
@@ -357,7 +364,7 @@ class PathResolver
|
|
357
364
|
if jail && !(descends_from? target_path, jail)
|
358
365
|
if opts.fetch :recover, true
|
359
366
|
logger.warn %(#{opts[:target_name] || 'path'} is outside of jail; recovering automatically)
|
360
|
-
target_segments,
|
367
|
+
target_segments, = partition_path target_path
|
361
368
|
jail_segments, jail_root = partition_path jail
|
362
369
|
return join_path jail_segments + target_segments, jail_root
|
363
370
|
else
|
@@ -366,7 +373,7 @@ class PathResolver
|
|
366
373
|
end
|
367
374
|
return target_path
|
368
375
|
else
|
369
|
-
target_segments,
|
376
|
+
target_segments, = partition_path target
|
370
377
|
end
|
371
378
|
else
|
372
379
|
target_segments = []
|
@@ -382,7 +389,7 @@ class PathResolver
|
|
382
389
|
return expand_path start
|
383
390
|
end
|
384
391
|
else
|
385
|
-
target_segments,
|
392
|
+
target_segments, = partition_path start
|
386
393
|
start = jail || @working_dir
|
387
394
|
end
|
388
395
|
elsif start.nil_or_empty?
|
@@ -414,7 +421,7 @@ class PathResolver
|
|
414
421
|
if (resolved_segments = start_segments + target_segments).include? DOT_DOT
|
415
422
|
unresolved_segments, resolved_segments = resolved_segments, []
|
416
423
|
if jail
|
417
|
-
jail_segments,
|
424
|
+
jail_segments, = partition_path jail unless jail_segments
|
418
425
|
warned = false
|
419
426
|
unresolved_segments.each do |segment|
|
420
427
|
if segment == DOT_DOT
|
@@ -445,7 +452,7 @@ class PathResolver
|
|
445
452
|
target_path
|
446
453
|
elsif opts.fetch :recover, true
|
447
454
|
logger.warn %(#{opts[:target_name] || 'path'} is outside of jail; recovering automatically)
|
448
|
-
jail_segments,
|
455
|
+
jail_segments, = partition_path jail unless jail_segments
|
449
456
|
join_path jail_segments + target_segments, jail_root
|
450
457
|
else
|
451
458
|
raise ::SecurityError, %(#{opts[:target_name] || 'path'} #{target} is outside of jail: #{jail} (disallowed in safe mode))
|
@@ -471,25 +478,15 @@ class PathResolver
|
|
471
478
|
def web_path target, start = nil
|
472
479
|
target = posixify target
|
473
480
|
start = posixify start
|
474
|
-
uri_prefix = nil
|
475
481
|
|
476
482
|
unless start.nil_or_empty? || (web_root? target)
|
477
|
-
target = (start.end_with? SLASH) ?
|
478
|
-
if (uri_prefix = Helpers.uri_prefix target)
|
479
|
-
target = target[uri_prefix.length..-1]
|
480
|
-
end
|
483
|
+
target, uri_prefix = extract_uri_prefix %(#{start}#{(start.end_with? SLASH) ? '' : SLASH}#{target})
|
481
484
|
end
|
482
485
|
|
483
486
|
# use this logic instead if we want to normalize target if it contains a URI
|
484
487
|
#unless web_root? target
|
485
|
-
#
|
486
|
-
#
|
487
|
-
# elsif !start.nil_or_empty?
|
488
|
-
# target = %(#{start}#{SLASH}#{target})
|
489
|
-
# if (uri_prefix = Helpers.uri_prefix target)
|
490
|
-
# target = target[uri_prefix.length..-1]
|
491
|
-
# end
|
492
|
-
# end
|
488
|
+
# target, uri_prefix = extract_uri_prefix target if preserve_uri_target
|
489
|
+
# target, uri_prefix = extract_uri_prefix %(#{start}#{SLASH}#{target}) unless uri_prefix || start.nil_or_empty?
|
493
490
|
#end
|
494
491
|
|
495
492
|
target_segments, target_root = partition_path target, true
|
@@ -516,5 +513,23 @@ class PathResolver
|
|
516
513
|
|
517
514
|
uri_prefix ? %(#{uri_prefix}#{resolved_path}) : resolved_path
|
518
515
|
end
|
516
|
+
|
517
|
+
private
|
518
|
+
|
519
|
+
# Internal: Efficiently extracts the URI prefix from the specified String if the String is a URI
|
520
|
+
#
|
521
|
+
# Uses the Asciidoctor::UriSniffRx regex to match the URI prefix in the specified String (e.g., http://). If present,
|
522
|
+
# the prefix is removed.
|
523
|
+
#
|
524
|
+
# str - the String to check
|
525
|
+
#
|
526
|
+
# returns a tuple containing the specified string without the URI prefix, if present, and the extracted URI prefix.
|
527
|
+
def extract_uri_prefix str
|
528
|
+
if (str.include? ':') && UriSniffRx =~ str
|
529
|
+
[(str.slice $&.length, str.length), $&]
|
530
|
+
else
|
531
|
+
str
|
532
|
+
end
|
533
|
+
end
|
519
534
|
end
|
520
535
|
end
|