lib/asciidoctor/callouts.rb in asciidoctor-1.5.3 vs lib/asciidoctor/callouts.rb in asciidoctor-1.5.4

- old
+ new

@@ -25,14 +25,13 @@ # callouts.next_list # callouts.register(2) # # => "CO2-1" # # Returns The unique String id of this callout - def register(li_ordinal) - current_list << {:ordinal => li_ordinal.to_i, :id => (id = generate_next_callout_id)} + def register li_ordinal + current_list << { :ordinal => li_ordinal.to_i, :id => (id = generate_next_callout_id) } @co_index += 1 - id end # Public: Get the next callout index in the document # @@ -48,21 +47,20 @@ if @co_index <= list.size id = list[@co_index - 1][:id] end @co_index += 1 - id end # Public: Get a space-separated list of callout ids for the specified list item # # li_ordinal - the Integer ordinal (1-based) of the list item for which to # retrieve the callouts # # Returns A space-separated String of callout ids associated with the specified list item - def callout_ids(li_ordinal) + def callout_ids li_ordinal current_list.map {|element| element[:ordinal] == li_ordinal ? %(#{element[:id]} ) : nil }.join.chop end # Public: The current list for which callouts are being collected # @@ -80,38 +78,36 @@ if @lists.size < @list_index @lists << [] end @co_index = 1 - nil end # Public: Rewind the list index pointer, intended to be used when switching # from the parsing to conversion phase. # # Returns nothing def rewind @list_index = 1 @co_index = 1 - nil end # Internal: Generate a unique id for the callout based on the internal indexes # # Returns A unique String id for this callout def generate_next_callout_id - generate_callout_id(@list_index, @co_index) + generate_callout_id @list_index, @co_index end # Internal: Generate a unique id for the callout at the specified position # # list_index - The 1-based Integer index of the callout list within the document # co_index - The 1-based Integer index of the callout since the end of the last callout list # # Returns A unique String id for a callout - def generate_callout_id(list_index, co_index) - "CO#{list_index}-#{co_index}" + def generate_callout_id list_index, co_index + %(CO#{list_index}-#{co_index}) end end end