asciidoctor 1.5.4 → 1.5.5
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 +72 -5
- data/CONTRIBUTING.adoc +3 -3
- data/Gemfile +23 -0
- data/README-fr.adoc +416 -0
- data/README-jp.adoc +395 -0
- data/README-zh_CN.adoc +414 -0
- data/README.adoc +134 -72
- data/asciidoctor.gemspec +49 -0
- data/data/locale/attributes.adoc +470 -0
- data/data/stylesheets/asciidoctor-default.css +6 -5
- data/lib/asciidoctor.rb +22 -19
- data/lib/asciidoctor/abstract_block.rb +20 -10
- data/lib/asciidoctor/abstract_node.rb +3 -14
- data/lib/asciidoctor/cli/invoker.rb +5 -4
- data/lib/asciidoctor/cli/options.rb +1 -1
- data/lib/asciidoctor/converter/docbook5.rb +1 -1
- data/lib/asciidoctor/converter/factory.rb +1 -5
- data/lib/asciidoctor/converter/html5.rb +36 -31
- data/lib/asciidoctor/converter/manpage.rb +14 -9
- data/lib/asciidoctor/converter/template.rb +8 -4
- data/lib/asciidoctor/core_ext.rb +7 -6
- data/lib/asciidoctor/core_ext/{string → 1.8.7/string}/chr.rb +1 -1
- data/lib/asciidoctor/core_ext/1.8.7/string/limit.rb +28 -0
- data/lib/asciidoctor/core_ext/{symbol → 1.8.7/symbol}/length.rb +1 -1
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +23 -0
- data/lib/asciidoctor/core_ext/string/limit.rb +10 -0
- data/lib/asciidoctor/document.rb +33 -26
- data/lib/asciidoctor/extensions.rb +16 -16
- data/lib/asciidoctor/helpers.rb +1 -1
- data/lib/asciidoctor/list.rb +3 -0
- data/lib/asciidoctor/parser.rb +47 -43
- data/lib/asciidoctor/path_resolver.rb +3 -1
- data/lib/asciidoctor/reader.rb +15 -14
- data/lib/asciidoctor/section.rb +2 -2
- data/lib/asciidoctor/stylesheets.rb +2 -1
- data/lib/asciidoctor/substitutors.rb +44 -46
- data/lib/asciidoctor/table.rb +41 -38
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +11 -4
- data/man/asciidoctor.adoc +7 -1
- data/test/attributes_test.rb +52 -0
- data/test/blocks_test.rb +8 -8
- data/test/document_test.rb +13 -1
- data/test/extensions_test.rb +38 -0
- data/test/invoker_test.rb +15 -0
- data/test/lists_test.rb +78 -53
- data/test/manpage_test.rb +15 -0
- data/test/paths_test.rb +3 -0
- data/test/reader_test.rb +2 -2
- data/test/sections_test.rb +10 -0
- data/test/substitutions_test.rb +12 -6
- data/test/tables_test.rb +76 -2
- metadata +16 -45
- data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +0 -23
- 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 -8
- 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-tweaks/block_paragraph.html.haml +0 -1
- 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/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/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +0 -13
- data/test/fixtures/grandchild-include.adoc +0 -3
- data/test/fixtures/hello-asciidoctor.pdf +0 -0
- data/test/fixtures/include-file.asciidoc +0 -24
- data/test/fixtures/include-file.xml +0 -5
- data/test/fixtures/master.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 -26
- data/test/fixtures/stylesheets/custom.css +0 -3
- data/test/fixtures/subs-docinfo.html +0 -2
- data/test/fixtures/subs.adoc +0 -7
- data/test/fixtures/tip.gif +0 -0
- data/test/test_helper.rb +0 -399
@@ -363,54 +363,50 @@ module Substitutors
|
|
363
363
|
end
|
364
364
|
alias :sub_specialcharacters :sub_specialchars
|
365
365
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
366
|
+
if RUBY_ENGINE == 'opal'
|
367
|
+
def sub_quotes text
|
368
|
+
QUOTE_SUBS[@document.compat_mode].each do |type, scope, pattern|
|
369
|
+
text = text.gsub(pattern) { convert_quoted_text $~, type, scope }
|
370
|
+
end
|
371
|
+
text
|
372
|
+
end
|
373
|
+
|
374
|
+
def sub_replacements text
|
375
|
+
REPLACEMENTS.each do |pattern, replacement, restore|
|
376
|
+
text = text.gsub(pattern) { do_replacement $~, replacement, restore }
|
377
|
+
end
|
378
|
+
text
|
379
|
+
end
|
380
|
+
else
|
381
|
+
# Public: Substitute quoted text (includes emphasis, strong, monospaced, etc)
|
382
|
+
#
|
383
|
+
# text - The String text to process
|
384
|
+
#
|
385
|
+
# returns The converted String text
|
386
|
+
def sub_quotes text
|
378
387
|
# NOTE interpolation is faster than String#dup
|
379
|
-
|
388
|
+
text = %(#{text})
|
380
389
|
# NOTE using gsub! here as an MRI Ruby optimization
|
381
|
-
QUOTE_SUBS[@document.compat_mode].each
|
382
|
-
|
383
|
-
|
390
|
+
QUOTE_SUBS[@document.compat_mode].each do |type, scope, pattern|
|
391
|
+
text.gsub!(pattern) { convert_quoted_text $~, type, scope }
|
392
|
+
end
|
393
|
+
text
|
384
394
|
end
|
385
395
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
#
|
393
|
-
# returns The String text with the replacement characters substituted
|
394
|
-
def sub_replacements(text)
|
395
|
-
if ::RUBY_ENGINE_OPAL
|
396
|
-
result = text
|
397
|
-
REPLACEMENTS.each {|pattern, replacement, restore|
|
398
|
-
result = result.gsub(pattern) {
|
399
|
-
do_replacement $~, replacement, restore
|
400
|
-
}
|
401
|
-
}
|
402
|
-
else
|
396
|
+
# Public: Substitute replacement characters (e.g., copyright, trademark, etc)
|
397
|
+
#
|
398
|
+
# text - The String text to process
|
399
|
+
#
|
400
|
+
# returns The String text with the replacement characters substituted
|
401
|
+
def sub_replacements text
|
403
402
|
# NOTE interpolation is faster than String#dup
|
404
|
-
|
403
|
+
text = %(#{text})
|
405
404
|
# NOTE Using gsub! as optimization
|
406
|
-
REPLACEMENTS.each
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
}
|
405
|
+
REPLACEMENTS.each do |pattern, replacement, restore|
|
406
|
+
text.gsub!(pattern) { do_replacement $~, replacement, restore }
|
407
|
+
end
|
408
|
+
text
|
411
409
|
end
|
412
|
-
|
413
|
-
result
|
414
410
|
end
|
415
411
|
|
416
412
|
# Internal: Substitute replacement text for matched location
|
@@ -642,6 +638,8 @@ module Substitutors
|
|
642
638
|
|
643
639
|
target = m[1]
|
644
640
|
attributes = if extension.config[:format] == :short
|
641
|
+
# TODO if content_model is :attributes, set target to nil and parse attributes
|
642
|
+
# maybe if content_model is :text, we should put content into text attribute
|
645
643
|
{}
|
646
644
|
else
|
647
645
|
if extension.config[:content_model] == :attributes
|
@@ -1403,7 +1401,7 @@ module Substitutors
|
|
1403
1401
|
unless (highlighter_loaded = defined? ::CodeRay) || @document.attributes['coderay-unavailable']
|
1404
1402
|
if (Helpers.require_library 'coderay', true, :warn).nil?
|
1405
1403
|
# prevent further attempts to load CodeRay
|
1406
|
-
@document.set_attr 'coderay-unavailable',
|
1404
|
+
@document.set_attr 'coderay-unavailable', ''
|
1407
1405
|
else
|
1408
1406
|
highlighter_loaded = true
|
1409
1407
|
end
|
@@ -1412,7 +1410,7 @@ module Substitutors
|
|
1412
1410
|
unless (highlighter_loaded = defined? ::Pygments) || @document.attributes['pygments-unavailable']
|
1413
1411
|
if (Helpers.require_library 'pygments', 'pygments.rb', :warn).nil?
|
1414
1412
|
# prevent further attempts to load Pygments
|
1415
|
-
@document.set_attr 'pygments-unavailable',
|
1413
|
+
@document.set_attr 'pygments-unavailable', ''
|
1416
1414
|
else
|
1417
1415
|
highlighter_loaded = true
|
1418
1416
|
end
|
@@ -1460,7 +1458,7 @@ module Substitutors
|
|
1460
1458
|
when 'coderay'
|
1461
1459
|
if (linenums_mode = (attr? 'linenums') ? (@document.attributes['coderay-linenums-mode'] || :table).to_sym : nil)
|
1462
1460
|
if attr? 'highlight', nil, false
|
1463
|
-
highlight_lines =
|
1461
|
+
highlight_lines = resolve_highlight_lines(attr 'highlight', nil, false)
|
1464
1462
|
end
|
1465
1463
|
end
|
1466
1464
|
result = ::CodeRay::Duo[attr('language', :text, false).to_sym, :html, {
|
@@ -1477,7 +1475,7 @@ module Substitutors
|
|
1477
1475
|
opts[:style] = (@document.attributes['pygments-style'] || Stylesheets::DEFAULT_PYGMENTS_STYLE)
|
1478
1476
|
end
|
1479
1477
|
if attr? 'highlight', nil, false
|
1480
|
-
unless (highlight_lines =
|
1478
|
+
unless (highlight_lines = resolve_highlight_lines(attr 'highlight', nil, false)).empty?
|
1481
1479
|
opts[:hl_lines] = highlight_lines * ' '
|
1482
1480
|
end
|
1483
1481
|
end
|
@@ -1545,7 +1543,7 @@ module Substitutors
|
|
1545
1543
|
end
|
1546
1544
|
|
1547
1545
|
# e.g., highlight="1-5, !2, 10" or highlight=1-5;!2,10
|
1548
|
-
def
|
1546
|
+
def resolve_highlight_lines spec
|
1549
1547
|
lines = []
|
1550
1548
|
spec.delete(' ').split(DataDelimiterRx).map do |entry|
|
1551
1549
|
negate = false
|
data/lib/asciidoctor/table.rb
CHANGED
@@ -77,9 +77,11 @@ class Table < AbstractBlock
|
|
77
77
|
|
78
78
|
# smell like we need a utility method here
|
79
79
|
# to resolve an integer width from potential bogus input
|
80
|
-
pcwidth = attributes['width']
|
81
|
-
|
82
|
-
|
80
|
+
if (pcwidth = attributes['width'])
|
81
|
+
if (pcwidth_intval = pcwidth.to_i) > 100 || pcwidth_intval < 1
|
82
|
+
pcwidth_intval = 100 unless pcwidth_intval == 0 && (pcwidth == '0' || pcwidth == '0%')
|
83
|
+
end
|
84
|
+
else
|
83
85
|
pcwidth_intval = 100
|
84
86
|
end
|
85
87
|
@attributes['tablepcwidth'] = pcwidth_intval
|
@@ -88,6 +90,8 @@ class Table < AbstractBlock
|
|
88
90
|
@attributes['tableabswidth'] ||=
|
89
91
|
((@attributes['tablepcwidth'].to_f / 100) * @document.attributes['pagewidth']).round
|
90
92
|
end
|
93
|
+
|
94
|
+
attributes['orientation'] = 'landscape' if attributes.key? 'rotate-option'
|
91
95
|
end
|
92
96
|
|
93
97
|
# Internal: Returns whether the current row being processed is
|
@@ -99,16 +103,16 @@ class Table < AbstractBlock
|
|
99
103
|
# Internal: Creates the Column objects from the column spec
|
100
104
|
#
|
101
105
|
# returns nothing
|
102
|
-
def create_columns
|
106
|
+
def create_columns colspecs
|
103
107
|
cols = []
|
104
108
|
width_base = 0
|
105
|
-
|
106
|
-
width_base +=
|
107
|
-
cols << (Column.new self, cols.size,
|
109
|
+
colspecs.each do |colspec|
|
110
|
+
width_base += colspec['width']
|
111
|
+
cols << (Column.new self, cols.size, colspec)
|
108
112
|
end
|
109
113
|
unless (@columns = cols).empty?
|
110
114
|
@attributes['colcount'] = cols.size
|
111
|
-
|
115
|
+
assign_column_widths(width_base == 0 ? nil : width_base)
|
112
116
|
end
|
113
117
|
nil
|
114
118
|
end
|
@@ -123,7 +127,7 @@ class Table < AbstractBlock
|
|
123
127
|
# width_base - the total of the relative column values used for calculating percentage widths (default: nil)
|
124
128
|
#
|
125
129
|
# returns nothing
|
126
|
-
def
|
130
|
+
def assign_column_widths width_base = nil
|
127
131
|
pf = 10.0 ** 4 # precision factor (multipler / divisor) for managing precision of calculated result
|
128
132
|
total_width = col_pcwidth = 0
|
129
133
|
|
@@ -301,10 +305,10 @@ class Table::ParserContext
|
|
301
305
|
|
302
306
|
# Public: Get the expected column count for a row
|
303
307
|
#
|
304
|
-
#
|
308
|
+
# colcount is the number of columns to pull into a row
|
305
309
|
# A value of -1 means we use the number of columns found
|
306
|
-
# in the first line as the
|
307
|
-
attr_reader :
|
310
|
+
# in the first line as the colcount
|
311
|
+
attr_reader :colcount
|
308
312
|
|
309
313
|
# Public: The String buffer of the currently open cell
|
310
314
|
attr_accessor :buffer
|
@@ -334,12 +338,12 @@ class Table::ParserContext
|
|
334
338
|
attributes['separator'] || Table::DEFAULT_DELIMITERS[@format]
|
335
339
|
end
|
336
340
|
@delimiter_re = /#{Regexp.escape @delimiter}/
|
337
|
-
@
|
341
|
+
@colcount = table.columns.empty? ? -1 : table.columns.size
|
338
342
|
@buffer = ''
|
339
|
-
@
|
343
|
+
@cellspecs = []
|
340
344
|
@cell_open = false
|
341
345
|
@active_rowspans = [0]
|
342
|
-
@
|
346
|
+
@column_visits = 0
|
343
347
|
@current_row = []
|
344
348
|
@linenum = -1
|
345
349
|
end
|
@@ -392,17 +396,17 @@ class Table::ParserContext
|
|
392
396
|
# when the cell is being closed.
|
393
397
|
#
|
394
398
|
# returns The cell spec Hash captured from parsing the previous cell
|
395
|
-
def
|
396
|
-
@
|
399
|
+
def take_cellspec
|
400
|
+
@cellspecs.shift
|
397
401
|
end
|
398
402
|
|
399
403
|
# Public: Puts a cell spec onto the stack. Cell specs precede the delimiter, so a
|
400
404
|
# stack is used to carry over the spec to the next cell.
|
401
405
|
#
|
402
406
|
# returns nothing
|
403
|
-
def
|
407
|
+
def push_cellspec(cellspec = {})
|
404
408
|
# this shouldn't be nil, but we check anyway
|
405
|
-
@
|
409
|
+
@cellspecs << (cellspec || {})
|
406
410
|
nil
|
407
411
|
end
|
408
412
|
|
@@ -443,8 +447,8 @@ class Table::ParserContext
|
|
443
447
|
# by the next cell.
|
444
448
|
#
|
445
449
|
# returns nothing
|
446
|
-
def close_open_cell(
|
447
|
-
|
450
|
+
def close_open_cell(next_cellspec = {})
|
451
|
+
push_cellspec next_cellspec
|
448
452
|
close_cell(true) if cell_open?
|
449
453
|
advance
|
450
454
|
nil
|
@@ -459,17 +463,16 @@ class Table::ParserContext
|
|
459
463
|
cell_text = @buffer.strip
|
460
464
|
@buffer = ''
|
461
465
|
if @format == 'psv'
|
462
|
-
|
463
|
-
if
|
464
|
-
repeat =
|
465
|
-
cell_spec.delete('repeatcol')
|
466
|
+
cellspec = take_cellspec
|
467
|
+
if cellspec
|
468
|
+
repeat = cellspec.delete('repeatcol') || 1
|
466
469
|
else
|
467
470
|
warn %(asciidoctor: ERROR: #{@last_cursor.line_info}: table missing leading separator, recovering automatically)
|
468
|
-
|
471
|
+
cellspec = {}
|
469
472
|
repeat = 1
|
470
473
|
end
|
471
474
|
else
|
472
|
-
|
475
|
+
cellspec = nil
|
473
476
|
repeat = 1
|
474
477
|
if @format == 'csv'
|
475
478
|
if !cell_text.empty? && cell_text.include?('"')
|
@@ -487,9 +490,9 @@ class Table::ParserContext
|
|
487
490
|
|
488
491
|
1.upto(repeat) do |i|
|
489
492
|
# TODO make column resolving an operation
|
490
|
-
if @
|
493
|
+
if @colcount == -1
|
491
494
|
@table.columns << (column = Table::Column.new(@table, @table.columns.size + i - 1))
|
492
|
-
if
|
495
|
+
if cellspec && (cellspec.key? 'colspan') && (extra_cols = cellspec['colspan'].to_i - 1) > 0
|
493
496
|
offset = @table.columns.size
|
494
497
|
extra_cols.times do |j|
|
495
498
|
@table.columns << Table::Column.new(@table, offset + j)
|
@@ -503,16 +506,16 @@ class Table::ParserContext
|
|
503
506
|
end
|
504
507
|
end
|
505
508
|
|
506
|
-
cell = Table::Cell.new(column, cell_text,
|
509
|
+
cell = Table::Cell.new(column, cell_text, cellspec, @last_cursor)
|
507
510
|
@last_cursor = @reader.cursor
|
508
511
|
unless !cell.rowspan || cell.rowspan == 1
|
509
512
|
activate_rowspan(cell.rowspan, (cell.colspan || 1))
|
510
513
|
end
|
511
|
-
@
|
514
|
+
@column_visits += (cell.colspan || 1)
|
512
515
|
@current_row << cell
|
513
516
|
# don't close the row if we're on the first line and the column count has not been set explicitly
|
514
|
-
# TODO perhaps the
|
515
|
-
close_row if end_of_row? && (@
|
517
|
+
# TODO perhaps the colcount/linenum logic should be in end_of_row? (or a should_end_row? method)
|
518
|
+
close_row if end_of_row? && (@colcount != -1 || @linenum > 0 || (eol && i == repeat))
|
516
519
|
end
|
517
520
|
@cell_open = false
|
518
521
|
nil
|
@@ -526,8 +529,8 @@ class Table::ParserContext
|
|
526
529
|
@table.rows.body << @current_row
|
527
530
|
# don't have to account for active rowspans here
|
528
531
|
# since we know this is first row
|
529
|
-
@
|
530
|
-
@
|
532
|
+
@colcount = @column_visits if @colcount == -1
|
533
|
+
@column_visits = 0
|
531
534
|
@current_row = []
|
532
535
|
@active_rowspans.shift
|
533
536
|
@active_rowspans[0] ||= 0
|
@@ -548,13 +551,13 @@ class Table::ParserContext
|
|
548
551
|
|
549
552
|
# Public: Check whether we've met the number of effective columns for the current row.
|
550
553
|
def end_of_row?
|
551
|
-
@
|
554
|
+
@colcount == -1 || effective_column_visits == @colcount
|
552
555
|
end
|
553
556
|
|
554
557
|
# Public: Calculate the effective column visits, which consists of the number of
|
555
558
|
# cells plus any active rowspans.
|
556
|
-
def
|
557
|
-
@
|
559
|
+
def effective_column_visits
|
560
|
+
@column_visits + @active_rowspans[0]
|
558
561
|
end
|
559
562
|
|
560
563
|
# Internal: Advance to the next line (which may come after the parser begins processing
|
data/lib/asciidoctor/version.rb
CHANGED
data/man/asciidoctor.1
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
'\" t
|
2
2
|
.\" Title: asciidoctor
|
3
3
|
.\" Author: Dan Allen, Sarah White, Ryan Waldron
|
4
|
-
.\" Generator: Asciidoctor 1.5.
|
5
|
-
.\" Date: 2016-
|
4
|
+
.\" Generator: Asciidoctor 1.5.5
|
5
|
+
.\" Date: 2016-10-05
|
6
6
|
.\" Manual: Asciidoctor Manual
|
7
|
-
.\" Source: Asciidoctor 1.5.
|
7
|
+
.\" Source: Asciidoctor 1.5.5
|
8
8
|
.\" Language: English
|
9
9
|
.\"
|
10
|
-
.TH "ASCIIDOCTOR" "1" "2016-
|
10
|
+
.TH "ASCIIDOCTOR" "1" "2016-10-05" "Asciidoctor 1.5.5" "Asciidoctor Manual"
|
11
11
|
.ie \n(.g .ds Aq \(aq
|
12
12
|
.el .ds Aq '
|
13
13
|
.ss \n[.ss] 0
|
@@ -191,6 +191,13 @@ Print program version number.
|
|
191
191
|
.sp
|
192
192
|
\f[CR]\-v\fP can also be used if no other flags or arguments are present.
|
193
193
|
.RE
|
194
|
+
.SH "ENVIRONMENT"
|
195
|
+
.sp
|
196
|
+
\fBAsciidoctor\fP honors the SOURCE_DATE_EPOCH environment variable.
|
197
|
+
If this variable is assigned an integer value, that value is used as the epoch of all input documents and as the local date and time.
|
198
|
+
See \c
|
199
|
+
.URL "https://reproducible\-builds.org/specs/source\-date\-epoch/" "" " "
|
200
|
+
for more information about this environment variable.
|
194
201
|
.SH "EXIT STATUS"
|
195
202
|
.sp
|
196
203
|
\fB0\fP
|
data/man/asciidoctor.adoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Dan Allen; Sarah White; Ryan Waldron
|
3
3
|
:doctype: manpage
|
4
4
|
:man manual: Asciidoctor Manual
|
5
|
-
:man source: Asciidoctor 1.5.
|
5
|
+
:man source: Asciidoctor 1.5.5
|
6
6
|
:page-layout: base
|
7
7
|
|
8
8
|
== NAME
|
@@ -144,6 +144,12 @@ Matching templates found in subsequent directories override ones previously disc
|
|
144
144
|
+
|
145
145
|
`-v` can also be used if no other flags or arguments are present.
|
146
146
|
|
147
|
+
== ENVIRONMENT
|
148
|
+
|
149
|
+
*Asciidoctor* honors the SOURCE_DATE_EPOCH environment variable.
|
150
|
+
If this variable is assigned an integer value, that value is used as the epoch of all input documents and as the local date and time.
|
151
|
+
See https://reproducible-builds.org/specs/source-date-epoch/ for more information about this environment variable.
|
152
|
+
|
147
153
|
== EXIT STATUS
|
148
154
|
|
149
155
|
*0*::
|
data/test/attributes_test.rb
CHANGED
@@ -124,6 +124,58 @@ content
|
|
124
124
|
assert result.include? '<em>big</em>foot'
|
125
125
|
end
|
126
126
|
|
127
|
+
test 'should limit maximum size of attribute value if safe mode is SECURE' do
|
128
|
+
expected = 'a' * 4096
|
129
|
+
input = <<-EOS
|
130
|
+
:name: #{'a' * 5000}
|
131
|
+
|
132
|
+
{name}
|
133
|
+
EOS
|
134
|
+
|
135
|
+
result = render_embedded_string input, :doctype => :inline
|
136
|
+
assert_equal expected, result
|
137
|
+
assert_equal 4096, result.bytesize
|
138
|
+
end
|
139
|
+
|
140
|
+
test 'should handle multibyte characters when limiting attribute value size' do
|
141
|
+
expected = '日本'
|
142
|
+
input = <<-EOS
|
143
|
+
:name: 日本語
|
144
|
+
|
145
|
+
{name}
|
146
|
+
EOS
|
147
|
+
|
148
|
+
result = render_embedded_string input, :doctype => :inline, :attributes => { 'max-attribute-value-size' => 6 }
|
149
|
+
assert_equal expected, result
|
150
|
+
assert_equal 6, result.bytesize
|
151
|
+
end
|
152
|
+
|
153
|
+
test 'should not mangle multibyte characters when limiting attribute value size' do
|
154
|
+
expected = '日本'
|
155
|
+
input = <<-EOS
|
156
|
+
:name: 日本語
|
157
|
+
|
158
|
+
{name}
|
159
|
+
EOS
|
160
|
+
|
161
|
+
result = render_embedded_string input, :doctype => :inline, :attributes => { 'max-attribute-value-size' => 8 }
|
162
|
+
assert_equal expected, result
|
163
|
+
assert_equal 6, result.bytesize
|
164
|
+
end
|
165
|
+
|
166
|
+
test 'should allow maximize size of attribute value to be disabled' do
|
167
|
+
expected = 'a' * 5000
|
168
|
+
input = <<-EOS
|
169
|
+
:name: #{'a' * 5000}
|
170
|
+
|
171
|
+
{name}
|
172
|
+
EOS
|
173
|
+
|
174
|
+
result = render_embedded_string input, :doctype => :inline, :attributes => { 'max-attribute-value-size' => nil }
|
175
|
+
assert_equal expected, result
|
176
|
+
assert_equal 5000, result.bytesize
|
177
|
+
end
|
178
|
+
|
127
179
|
test 'resolves user-home attribute if safe mode is less than SERVER' do
|
128
180
|
input = <<-EOS
|
129
181
|
:imagesdir: {user-home}/etc/images
|