asciidoctor 2.0.12 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +142 -22
  3. data/LICENSE +1 -1
  4. data/README-de.adoc +15 -6
  5. data/README-fr.adoc +14 -8
  6. data/README-jp.adoc +15 -6
  7. data/README-zh_CN.adoc +14 -5
  8. data/README.adoc +135 -125
  9. data/asciidoctor.gemspec +4 -11
  10. data/data/locale/attributes-be.adoc +23 -0
  11. data/data/locale/attributes-it.adoc +4 -4
  12. data/data/locale/attributes-nl.adoc +6 -6
  13. data/data/locale/attributes-th.adoc +23 -0
  14. data/data/locale/attributes-vi.adoc +23 -0
  15. data/data/reference/syntax.adoc +14 -7
  16. data/data/stylesheets/asciidoctor-default.css +51 -52
  17. data/lib/asciidoctor.rb +12 -12
  18. data/lib/asciidoctor/abstract_block.rb +4 -4
  19. data/lib/asciidoctor/abstract_node.rb +10 -9
  20. data/lib/asciidoctor/attribute_list.rb +6 -6
  21. data/lib/asciidoctor/block.rb +6 -6
  22. data/lib/asciidoctor/cli/invoker.rb +0 -1
  23. data/lib/asciidoctor/cli/options.rb +27 -26
  24. data/lib/asciidoctor/convert.rb +1 -0
  25. data/lib/asciidoctor/converter.rb +5 -3
  26. data/lib/asciidoctor/converter/docbook5.rb +45 -26
  27. data/lib/asciidoctor/converter/html5.rb +89 -69
  28. data/lib/asciidoctor/converter/manpage.rb +113 -86
  29. data/lib/asciidoctor/converter/template.rb +11 -12
  30. data/lib/asciidoctor/document.rb +44 -51
  31. data/lib/asciidoctor/extensions.rb +10 -12
  32. data/lib/asciidoctor/helpers.rb +3 -6
  33. data/lib/asciidoctor/list.rb +2 -6
  34. data/lib/asciidoctor/load.rb +13 -11
  35. data/lib/asciidoctor/logging.rb +10 -8
  36. data/lib/asciidoctor/parser.rb +135 -150
  37. data/lib/asciidoctor/path_resolver.rb +3 -3
  38. data/lib/asciidoctor/reader.rb +72 -71
  39. data/lib/asciidoctor/rx.rb +4 -3
  40. data/lib/asciidoctor/substitutors.rb +117 -117
  41. data/lib/asciidoctor/syntax_highlighter.rb +8 -11
  42. data/lib/asciidoctor/syntax_highlighter/coderay.rb +2 -1
  43. data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +1 -1
  44. data/lib/asciidoctor/syntax_highlighter/pygments.rb +6 -5
  45. data/lib/asciidoctor/syntax_highlighter/rouge.rb +33 -26
  46. data/lib/asciidoctor/table.rb +17 -19
  47. data/lib/asciidoctor/timings.rb +3 -3
  48. data/lib/asciidoctor/version.rb +1 -1
  49. data/man/asciidoctor.1 +10 -11
  50. data/man/asciidoctor.adoc +8 -7
  51. metadata +14 -67
@@ -40,13 +40,13 @@ class Converter::TemplateConverter < Converter::Base
40
40
  @caches = { scans: {}, templates: {} }
41
41
  end
42
42
 
43
- def self.caches
44
- @caches
45
- end
43
+ class << self
44
+ attr_reader :caches
46
45
 
47
- def self.clear_caches
48
- @caches[:scans].clear if @caches[:scans]
49
- @caches[:templates].clear if @caches[:templates]
46
+ def clear_caches
47
+ @caches[:scans].clear
48
+ @caches[:templates].clear
49
+ end
50
50
  end
51
51
 
52
52
  def initialize backend, template_dirs, opts = {}
@@ -134,12 +134,10 @@ class Converter::TemplateConverter < Converter::Base
134
134
  #
135
135
  # Returns the Tilt template object
136
136
  def register name, template
137
- @templates[name] = if (template_cache = @caches[:templates])
137
+ if (template_cache = @caches[:templates])
138
138
  template_cache[template.file] = template
139
- else
140
- template
141
139
  end
142
- #create_handler name, template
140
+ @templates[name] = template
143
141
  end
144
142
 
145
143
  private
@@ -155,6 +153,7 @@ class Converter::TemplateConverter < Converter::Base
155
153
  engine = @engine
156
154
  @template_dirs.each do |template_dir|
157
155
  # FIXME need to think about safe mode restrictions here
156
+ # Ruby 2.3 requires the extra brackets around the path_resolver.system_path method call
158
157
  next unless ::File.directory?(template_dir = (path_resolver.system_path template_dir))
159
158
 
160
159
  if engine
@@ -186,8 +185,8 @@ class Converter::TemplateConverter < Converter::Base
186
185
  else
187
186
  @templates.update scan_dir(template_dir, pattern, @caches[:templates])
188
187
  end
189
- nil
190
188
  end
189
+ nil
191
190
  end
192
191
 
193
192
  # Internal: Scan the specified directory for template files matching pattern and instantiate
@@ -262,7 +261,7 @@ class Converter::TemplateConverter < Converter::Base
262
261
  [::Tilt::ErubiTemplate, {}]
263
262
  elsif name == 'erubis'
264
263
  Helpers.require_library 'erubis' unless defined? ::Erubis::FastEruby
265
- [::Tilt::ErubisTemplate, { engine_class: ::Erubis::FastEruby }]
264
+ [::Tilt::ErubisTemplate, engine_class: ::Erubis::FastEruby]
266
265
  else
267
266
  raise ::ArgumentError, %(Unknown ERB implementation: #{name})
268
267
  end
@@ -259,12 +259,14 @@ class Document < AbstractBlock
259
259
  options[:catalog_assets] = true if parent_doc.options[:catalog_assets]
260
260
  @catalog = parent_doc.catalog.merge footnotes: []
261
261
  # QUESTION should we support setting attribute in parent document from nested document?
262
- # NOTE we must dup or else all the assignments to the overrides clobbers the real attributes
263
- @attribute_overrides = attr_overrides = parent_doc.attributes.merge
264
- parent_doctype = attr_overrides.delete 'doctype'
262
+ @attribute_overrides = attr_overrides = (parent_doc.instance_variable_get :@attribute_overrides).merge parent_doc.attributes
265
263
  attr_overrides.delete 'compat-mode'
264
+ parent_doctype = attr_overrides.delete 'doctype'
265
+ attr_overrides.delete 'notitle'
266
+ attr_overrides.delete 'showtitle'
267
+ # QUESTION if toc is hard unset in parent document, should it be hard unset in nested document?
266
268
  attr_overrides.delete 'toc'
267
- attr_overrides.delete 'toc-placement'
269
+ @attributes['toc-placement'] = (attr_overrides.delete 'toc-placement') || 'auto'
268
270
  attr_overrides.delete 'toc-position'
269
271
  @safe = parent_doc.safe
270
272
  @attributes['compat-mode'] = '' if (@compat_mode = parent_doc.compat_mode)
@@ -284,7 +286,6 @@ class Document < AbstractBlock
284
286
  footnotes: [],
285
287
  links: [],
286
288
  images: [],
287
- #indexterms: [],
288
289
  callouts: Callouts.new,
289
290
  includes: {},
290
291
  }
@@ -309,7 +310,7 @@ class Document < AbstractBlock
309
310
  end
310
311
  attr_overrides[key.downcase] = val
311
312
  end
312
- if (to_file = options[:to_file])
313
+ if ::String === (to_file = options[:to_file])
313
314
  attr_overrides['outfilesuffix'] = Helpers.extname to_file
314
315
  end
315
316
  # safely resolve the safe mode from const, int or string
@@ -339,11 +340,13 @@ class Document < AbstractBlock
339
340
  (@options = options).freeze
340
341
 
341
342
  attrs = @attributes
342
- attrs['attribute-undefined'] = Compliance.attribute_undefined
343
- attrs['attribute-missing'] = Compliance.attribute_missing
344
- attrs.update DEFAULT_ATTRIBUTES
345
- # TODO if lang attribute is set, @safe mode < SafeMode::SERVER, and !parent_doc,
346
- # load attributes from data/locale/attributes-<lang>.adoc
343
+ unless parent_doc
344
+ attrs['attribute-undefined'] = Compliance.attribute_undefined
345
+ attrs['attribute-missing'] = Compliance.attribute_missing
346
+ attrs.update DEFAULT_ATTRIBUTES
347
+ # TODO if lang attribute is set, @safe mode < SafeMode::SERVER, and !parent_doc,
348
+ # load attributes from data/locale/attributes-<lang>.adoc
349
+ end
347
350
 
348
351
  if standalone
349
352
  # sync embedded attribute with :standalone option value
@@ -356,9 +359,9 @@ class Document < AbstractBlock
356
359
  # sync embedded attribute with :standalone option value
357
360
  attr_overrides['embedded'] = ''
358
361
  if (attr_overrides.key? 'showtitle') && (attr_overrides.keys & %w(notitle showtitle))[-1] == 'showtitle'
359
- attr_overrides['notitle'] = { nil => '', false => '@', '@' => false}[attr_overrides['showtitle']]
362
+ attr_overrides['notitle'] = { nil => '', false => '@', '@' => false }[attr_overrides['showtitle']]
360
363
  elsif attr_overrides.key? 'notitle'
361
- attr_overrides['showtitle'] = { nil => '', false => '@', '@' => false}[attr_overrides['notitle']]
364
+ attr_overrides['showtitle'] = { nil => '', false => '@', '@' => false }[attr_overrides['notitle']]
362
365
  else
363
366
  attrs['notitle'] = ''
364
367
  end
@@ -371,14 +374,12 @@ class Document < AbstractBlock
371
374
  attr_overrides[%(safe-mode-#{safe_mode_name})] = ''
372
375
  attr_overrides['safe-mode-level'] = @safe
373
376
 
374
- # the only way to set the max-include-depth attribute is via the API; default to 64 like AsciiDoc Python
377
+ # the only way to set the max-include-depth attribute is via the API; default to 64 like AsciiDoc.py
375
378
  attr_overrides['max-include-depth'] ||= 64
376
379
 
377
380
  # the only way to set the allow-uri-read attribute is via the API; disabled by default
378
381
  attr_overrides['allow-uri-read'] ||= nil
379
382
 
380
- attr_overrides['user-home'] = USER_HOME
381
-
382
383
  # remap legacy attribute names
383
384
  attr_overrides['sectnums'] = attr_overrides.delete 'numbered' if attr_overrides.key? 'numbered'
384
385
  attr_overrides['hardbreaks-option'] = attr_overrides.delete 'hardbreaks' if attr_overrides.key? 'hardbreaks'
@@ -397,11 +398,11 @@ class Document < AbstractBlock
397
398
 
398
399
  # allow common attributes backend and doctype to be set using options hash, coerce values to string
399
400
  if (backend_val = options[:backend])
400
- attr_overrides['backend'] = %(#{backend_val})
401
+ attr_overrides['backend'] = backend_val.to_s
401
402
  end
402
403
 
403
404
  if (doctype_val = options[:doctype])
404
- attr_overrides['doctype'] = %(#{doctype_val})
405
+ attr_overrides['doctype'] = doctype_val.to_s
405
406
  end
406
407
 
407
408
  if @safe >= SafeMode::SERVER
@@ -414,7 +415,7 @@ class Document < AbstractBlock
414
415
  attr_overrides['docfile'] = attr_overrides['docfile'][(attr_overrides['docdir'].length + 1)..-1]
415
416
  end
416
417
  attr_overrides['docdir'] = ''
417
- attr_overrides['user-home'] = '.'
418
+ attr_overrides['user-home'] ||= '.'
418
419
  if @safe >= SafeMode::SECURE
419
420
  attr_overrides['max-attribute-value-size'] = 4096 unless attr_overrides.key? 'max-attribute-value-size'
420
421
  # assign linkcss (preventing css embedding) unless explicitly disabled from the commandline or API
@@ -423,6 +424,8 @@ class Document < AbstractBlock
423
424
  # restrict document from enabling icons
424
425
  attr_overrides['icons'] ||= nil
425
426
  end
427
+ else
428
+ attr_overrides['user-home'] ||= USER_HOME
426
429
  end
427
430
 
428
431
  # the only way to set the max-attribute-value-size attribute is via the API; disabled by default
@@ -562,13 +565,15 @@ class Document < AbstractBlock
562
565
  # returns the next number in the sequence for the specified counter
563
566
  def counter name, seed = nil
564
567
  return @parent_document.counter name, seed if @parent_document
565
- if (attr_seed = !(attr_val = @attributes[name]).nil_or_empty?) && (@counters.key? name)
566
- @attributes[name] = @counters[name] = Helpers.nextval attr_val
568
+ if ((locked = attribute_locked? name) && (curr_val = @counters[name])) || !(curr_val = @attributes[name]).nil_or_empty?
569
+ next_val = @counters[name] = Helpers.nextval curr_val
567
570
  elsif seed
568
- @attributes[name] = @counters[name] = seed == seed.to_i.to_s ? seed.to_i : seed
571
+ next_val = @counters[name] = seed == seed.to_i.to_s ? seed.to_i : seed
569
572
  else
570
- @attributes[name] = @counters[name] = Helpers.nextval attr_seed ? attr_val : 0
573
+ next_val = @counters[name] = 1
571
574
  end
575
+ @attributes[name] = next_val unless locked
576
+ next_val
572
577
  end
573
578
 
574
579
  # Public: Increment the specified counter and store it in the block's attributes
@@ -610,10 +615,17 @@ class Document < AbstractBlock
610
615
  # @reftexts is set eagerly to prevent nested lazy init
611
616
  (@reftexts = {}).tap {|accum| @catalog[:refs].each {|id, ref| accum[ref.xreftext] ||= id } }[text]
612
617
  else
613
- # @reftexts is set eagerly to prevent nested lazy init
614
618
  resolved_id = nil
615
- # NOTE short-circuit early since we're throwing away this table
616
- (@reftexts = {}).tap {|accum| @catalog[:refs].each {|id, ref| (xreftext = ref.xreftext) == text ? (break (resolved_id = id)) : (accum[xreftext] ||= id) } }
619
+ # @reftexts is set eagerly to prevent nested lazy init
620
+ @reftexts = accum = {}
621
+ @catalog[:refs].each do |id, ref|
622
+ # NOTE short-circuit early since we're throwing away this table anyway
623
+ if (xreftext = ref.xreftext) == text
624
+ resolved_id = id
625
+ break
626
+ end
627
+ accum[xreftext] ||= id
628
+ end
617
629
  @reftexts = nil
618
630
  resolved_id
619
631
  end
@@ -671,7 +683,7 @@ class Document < AbstractBlock
671
683
  #
672
684
  # title - the String title to assign as the title of the document header
673
685
  #
674
- # Returns the new [String] title assigned to the document header
686
+ # Returns the specified [String] title
675
687
  def title= title
676
688
  unless (sect = @header)
677
689
  (sect = (@header = Section.new self, 0)).sectname = 'header'
@@ -980,25 +992,6 @@ class Document < AbstractBlock
980
992
  nil
981
993
  end
982
994
 
983
- =begin
984
- def convert_to target, opts = {}
985
- start = ::Time.now.to_f if (monitor = opts[:monitor])
986
- output = (r = converter opts).convert
987
- monitor[:convert] = ::Time.now.to_f - start if monitor
988
-
989
- unless target.respond_to? :write
990
- @attributes['outfile'] = target = ::File.expand_path target
991
- @attributes['outdir'] = ::File.dirname target
992
- end
993
-
994
- start = ::Time.now.to_f if monitor
995
- r.write output, target
996
- monitor[:write] = ::Time.now.to_f - start if monitor
997
-
998
- output
999
- end
1000
- =end
1001
-
1002
995
  def content
1003
996
  # NOTE per AsciiDoc-spec, remove the title before converting the body
1004
997
  @attributes.delete('title')
@@ -1020,7 +1013,7 @@ class Document < AbstractBlock
1020
1013
  def docinfo location = :head, suffix = nil
1021
1014
  if safe < SafeMode::SECURE
1022
1015
  qualifier = %(-#{location}) unless location == :head
1023
- suffix = @outfilesuffix unless suffix
1016
+ suffix ||= @outfilesuffix
1024
1017
 
1025
1018
  if (docinfo = @attributes['docinfo']).nil_or_empty?
1026
1019
  if @attributes.key? 'docinfo2'
@@ -1077,7 +1070,7 @@ class Document < AbstractBlock
1077
1070
  end
1078
1071
 
1079
1072
  def to_s
1080
- %(#<#{self.class}@#{object_id} {doctype: #{doctype.inspect}, doctitle: #{(@header != nil ? @header.title : nil).inspect}, blocks: #{@blocks.size}}>)
1073
+ %(#<#{self.class}@#{object_id} {doctype: #{doctype.inspect}, doctitle: #{(@header && @header.title).inspect}, blocks: #{@blocks.size}}>)
1081
1074
  end
1082
1075
 
1083
1076
  private
@@ -1206,8 +1199,8 @@ class Document < AbstractBlock
1206
1199
  end
1207
1200
  end
1208
1201
 
1209
- if (@compat_mode = attrs.key? 'compat-mode')
1210
- attrs['source-language'] = attrs['language'] if attrs.key? 'language'
1202
+ if (@compat_mode = attrs.key? 'compat-mode') && (attrs.key? 'language')
1203
+ attrs['source-language'] = attrs['language']
1211
1204
  end
1212
1205
 
1213
1206
  unless @parent_document
@@ -1380,7 +1373,7 @@ class Document < AbstractBlock
1380
1373
  attrs[%(basebackend-#{current_basebackend}-doctype-#{new_doctype})] = '' if current_basebackend
1381
1374
  end
1382
1375
  attrs[%(doctype-#{new_doctype})] = ''
1383
- return @doctype = attrs['doctype'] = new_doctype
1376
+ @doctype = attrs['doctype'] = new_doctype
1384
1377
  end
1385
1378
  end
1386
1379
  end
@@ -134,14 +134,14 @@ module Extensions
134
134
  if opts.fetch :numbered, (style == 'appendix')
135
135
  sect.numbered = true
136
136
  elsif !(opts.key? :numbered) && (doc.attr? 'sectnums', 'all')
137
- sect.numbered = book && level == 1 ? :chapter : true
137
+ sect.numbered = (book && level == 1 ? :chapter : true)
138
138
  end
139
139
  elsif level > 0
140
140
  if opts.fetch :numbered, (doc.attr? 'sectnums')
141
141
  sect.numbered = sect.special ? parent.numbered && true : true
142
142
  end
143
- else
144
- sect.numbered = true if opts.fetch :numbered, (book && (doc.attr? 'partnums'))
143
+ elsif opts.fetch :numbered, (book && (doc.attr? 'partnums'))
144
+ sect.numbered = true
145
145
  end
146
146
  if (id = attrs['id']) == false
147
147
  attrs.delete 'id'
@@ -229,7 +229,7 @@ module Extensions
229
229
  def parse_attributes block, attrlist, opts = {}
230
230
  return {} if attrlist ? attrlist.empty? : true
231
231
  attrlist = block.sub_attributes attrlist if opts[:sub_attributes] && (attrlist.include? ATTR_REF_HEAD)
232
- (AttributeList.new attrlist).parse (opts[:positional_attributes] || [])
232
+ (AttributeList.new attrlist).parse opts[:positional_attributes] || []
233
233
  end
234
234
 
235
235
  # TODO fill out remaining methods
@@ -1021,8 +1021,6 @@ module Extensions
1021
1021
  else
1022
1022
  @docinfo_processor_extensions
1023
1023
  end
1024
- else
1025
- nil
1026
1024
  end
1027
1025
  end
1028
1026
 
@@ -1201,7 +1199,7 @@ module Extensions
1201
1199
  # name - the String or Symbol (coersed to a Symbol) macro name
1202
1200
  #
1203
1201
  # Returns the [Extension] object stored in the registry that proxies the
1204
- # cooresponding BlockMacroProcessor or nil if a match is not found.
1202
+ # corresponding BlockMacroProcessor or nil if a match is not found.
1205
1203
  def find_block_macro_extension name
1206
1204
  @block_macro_extensions[name.to_sym]
1207
1205
  end
@@ -1288,7 +1286,7 @@ module Extensions
1288
1286
  # name - the String or Symbol (coersed to a Symbol) macro name
1289
1287
  #
1290
1288
  # Returns the [Extension] object stored in the registry that proxies the
1291
- # cooresponding InlineMacroProcessor or nil if a match is not found.
1289
+ # corresponding InlineMacroProcessor or nil if a match is not found.
1292
1290
  def find_inline_macro_extension name
1293
1291
  @inline_macro_extensions[name.to_sym]
1294
1292
  end
@@ -1330,7 +1328,7 @@ module Extensions
1330
1328
  kind_java_class = (defined? ::AsciidoctorJ) ? (::AsciidoctorJ::Extensions.const_get kind_class_symbol, false) : nil
1331
1329
  kind_store = instance_variable_get(%(@#{kind}_extensions).to_sym) || instance_variable_set(%(@#{kind}_extensions).to_sym, [])
1332
1330
  # style 1: specified as block
1333
- extension = if block_given?
1331
+ if block_given?
1334
1332
  config = resolve_args args, 1
1335
1333
  (processor = kind_class.new config).singleton_class.enable_dsl
1336
1334
  if block.arity == 0
@@ -1342,7 +1340,7 @@ module Extensions
1342
1340
  raise ::ArgumentError, %(No block specified to process #{kind_name} extension at #{block.source_location})
1343
1341
  end
1344
1342
  processor.freeze
1345
- ProcessorExtension.new kind, processor
1343
+ extension = ProcessorExtension.new kind, processor
1346
1344
  else
1347
1345
  processor, config = resolve_args args, 2
1348
1346
  # style 2: specified as Class or String class name
@@ -1352,12 +1350,12 @@ module Extensions
1352
1350
  end
1353
1351
  processor_instance = processor_class.new config
1354
1352
  processor_instance.freeze
1355
- ProcessorExtension.new kind, processor_instance
1353
+ extension = ProcessorExtension.new kind, processor_instance
1356
1354
  # style 3: specified as instance
1357
1355
  elsif kind_class === processor || (kind_java_class && kind_java_class === processor)
1358
1356
  processor.update_config config
1359
1357
  processor.freeze
1360
- ProcessorExtension.new kind, processor
1358
+ extension = ProcessorExtension.new kind, processor
1361
1359
  else
1362
1360
  raise ::ArgumentError, %(Invalid arguments specified for registering #{kind_name} extension: #{args})
1363
1361
  end
@@ -274,13 +274,10 @@ module Helpers
274
274
  def nextval current
275
275
  if ::Integer === current
276
276
  current + 1
277
+ elsif (intval = current.to_i).to_s == current.to_s
278
+ intval + 1
277
279
  else
278
- intval = current.to_i
279
- if intval.to_s != current.to_s
280
- (current[0].ord + 1).chr
281
- else
282
- intval + 1
283
- end
280
+ current.succ
284
281
  end
285
282
  end
286
283
 
@@ -80,12 +80,8 @@ class ListItem < AbstractBlock
80
80
  @text && (apply_subs @text, @subs)
81
81
  end
82
82
 
83
- # Public: Set the String text.
84
- #
85
- # Returns the new String text assigned to this ListItem
86
- def text= val
87
- @text = val
88
- end
83
+ # Public: Set the String text assigned to this ListItem
84
+ attr_writer :text
89
85
 
90
86
  # Check whether this list item has simple content (no nested blocks aside from a single outline list).
91
87
  # Primarily relevant for outline lists.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Asciidoctor
2
3
  class << self
3
4
  # Public: Parse the AsciiDoc source input into a {Document}
@@ -20,8 +21,8 @@ module Asciidoctor
20
21
  timings.start :read
21
22
  end
22
23
 
23
- if (logger = options[:logger]) && logger != LoggerManager.logger
24
- LoggerManager.logger = logger
24
+ if (options.key? :logger) && (logger = options[:logger]) != LoggerManager.logger
25
+ LoggerManager.logger = logger || NullLogger.new
25
26
  end
26
27
 
27
28
  if !(attrs = options[:attributes])
@@ -53,7 +54,8 @@ module Asciidoctor
53
54
  end
54
55
 
55
56
  if ::File === input
56
- options[:input_mtime] = input.mtime
57
+ # File#mtime on JRuby 9.1 for Windows doesn't honor TZ environment variable; see https://github.com/jruby/jruby/issues/6659
58
+ options[:input_mtime] = RUBY_ENGINE == 'jruby' ? (::Time.at input.mtime.to_i) : input.mtime
57
59
  # NOTE defer setting infile and indir until we get a better sense of their purpose
58
60
  # TODO cli checks if input path can be read and is file, but might want to add check to API too
59
61
  attrs['docfile'] = input_path = ::File.absolute_path input.path
@@ -83,23 +85,23 @@ module Asciidoctor
83
85
 
84
86
  timings.record :parse if timings
85
87
  doc
86
- rescue => ex
88
+ rescue => e
87
89
  begin
88
90
  context = %(asciidoctor: FAILED: #{attrs['docfile'] || '<stdin>'}: Failed to load AsciiDoc document)
89
- if ex.respond_to? :exception
91
+ if e.respond_to? :exception
90
92
  # The original message must be explicitly preserved when wrapping a Ruby exception
91
- wrapped_ex = ex.exception %(#{context} - #{ex.message})
93
+ wrapped_e = e.exception %(#{context} - #{e.message})
92
94
  # JRuby automatically sets backtrace; MRI did not until 2.6
93
- wrapped_ex.set_backtrace ex.backtrace
95
+ wrapped_e.set_backtrace e.backtrace
94
96
  else
95
97
  # Likely a Java exception class
96
- wrapped_ex = ex.class.new context, ex
97
- wrapped_ex.stack_trace = ex.stack_trace
98
+ wrapped_e = e.class.new context, e
99
+ wrapped_e.stack_trace = e.stack_trace
98
100
  end
99
101
  rescue
100
- wrapped_ex = ex
102
+ wrapped_e = e
101
103
  end
102
- raise wrapped_ex
104
+ raise wrapped_e
103
105
  end
104
106
 
105
107
  # Public: Parse the contents of the AsciiDoc source file into an Asciidoctor::Document