diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2019-03-28 15:46:11 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2019-03-28 15:46:11 -0600 |
| commit | 44c315e3c6558213706487ed9f2bc95319704050 (patch) | |
| tree | feadd7257f3faa48b46b622815cc590eece475fe | |
| parent | 7695b3c48bd22c95df8ae22c8fec2e3fab727ac8 (diff) | |
map caption prefix for an image block to the string key 'figure'
| -rw-r--r-- | lib/asciidoctor.rb | 3 | ||||
| -rw-r--r-- | lib/asciidoctor/abstract_block.rb | 3 | ||||
| -rw-r--r-- | lib/asciidoctor/extensions.rb | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/parser.rb | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb index 76b4d67c..97dcaac7 100644 --- a/lib/asciidoctor.rb +++ b/lib/asciidoctor.rb @@ -293,7 +293,8 @@ module Asciidoctor DELIMITED_BLOCK_HEADS = {}.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum[k.slice 0, 2] = true } } DELIMITED_BLOCK_TAILS = {}.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum[k] = k[k.length - 1] if k.length == 4 } } - CAPTION_ATTR_NAMES = { example: 'example-caption', image: 'figure-caption', listing: 'listing-caption', table: 'table-caption' } + # NOTE the 'figure' key as a string is historical and used by image blocks + CAPTION_ATTR_NAMES = { example: 'example-caption', 'figure' => 'figure-caption', listing: 'listing-caption', table: 'table-caption' } LAYOUT_BREAK_CHARS = { '\'' => :thematic_break, diff --git a/lib/asciidoctor/abstract_block.rb b/lib/asciidoctor/abstract_block.rb index 3e214ecc..cffc052c 100644 --- a/lib/asciidoctor/abstract_block.rb +++ b/lib/asciidoctor/abstract_block.rb @@ -378,8 +378,7 @@ class AbstractBlock < AbstractNode def assign_caption value = nil, caption_context = @context unless @caption || !@title || (@caption = value || @document.attributes['caption']) if (attr_name = CAPTION_ATTR_NAMES[caption_context]) && (prefix = @document.attributes[attr_name]) - counter_name = caption_context == :image ? 'figure-number' : %(#{caption_context}-number) - @caption = %(#{prefix} #{@numeral = @document.increment_and_store_counter counter_name, self}. ) + @caption = %(#{prefix} #{@numeral = @document.increment_and_store_counter %(#{caption_context}-number), self}. ) nil end end diff --git a/lib/asciidoctor/extensions.rb b/lib/asciidoctor/extensions.rb index d2945cf7..fb6621f2 100644 --- a/lib/asciidoctor/extensions.rb +++ b/lib/asciidoctor/extensions.rb @@ -197,7 +197,7 @@ module Extensions block = create_block parent, :image, nil, attrs, opts if title block.title = title - block.assign_caption (attrs.delete 'caption'), (opts[:caption_context] || :image) + block.assign_caption (attrs.delete 'caption'), 'figure' end block end diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index 46f9b395..57ab1310 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -605,7 +605,7 @@ class Parser end if attributes['title'] block.title = block_title = attributes.delete 'title' - block.assign_caption (attributes.delete 'caption') + block.assign_caption (attributes.delete 'caption'), 'figure' end end attributes['target'] = target |
