lib/asciidoctor/abstract_block.rb in asciidoctor-1.5.4 vs lib/asciidoctor/abstract_block.rb in asciidoctor-1.5.5

- old
+ new

@@ -242,15 +242,14 @@ end block_given? ? results : results.to_enum end =end - # Public: Query for all descendant block nodes in the document tree that - # match the specified Symbol filter_context and, optionally, the style and/or - # role specified in the options Hash. If a block is provided, it's used as an - # additional filter. If no filters are specified, all block nodes in the tree - # are returned. + # Public: Query for all descendant block-level nodes in the document tree + # that match the specified selector (context, style, id, and/or role). If a + # Ruby block is given, it's used as an additional filter. If no selector or + # Ruby block is supplied, all block-level nodes in the tree are returned. # # Examples # # doc.find_by context: :section # #=> Asciidoctor::Section@14459860 { level: 0, title: "Hello, AsciiDoc!", blocks: 0 } @@ -260,11 +259,11 @@ # #=> Asciidoctor::Section@14505460 { level: 1, title: "First Section", blocks: 1 } # # doc.find_by context: :listing, style: 'source' # #=> Asciidoctor::Block@13136720 { context: :listing, content_model: :verbatim, style: "source", lines: 1 } # - # Returns An Array of block nodes that match the given selector or an empty Array if no matches are found + # Returns An Array of block-level nodes that match the filter or an empty Array if no matches are found #-- # TODO support jQuery-style selector (e.g., image.thumb) def find_by selector = {}, &block result = [] @@ -288,12 +287,12 @@ # process document header as a section if present if @context == :document && (any_context || context_selector == :section) && header? result.concat(@header.find_by selector, &block) end - # yuck, dlist is a special case unless context_selector == :document # optimization + # yuck, dlist is a special case if @context == :dlist if any_context || context_selector != :section # optimization @blocks.flatten.each do |li| # NOTE the list item of a dlist can be nil, so we have to check result.concat(li.find_by selector, &block) if li @@ -354,10 +353,21 @@ end end nil end + # Public: Retrieve the list marker keyword for the specified list type. + # + # For use in the HTML type attribute. + # + # list_type - the type of list; default to the @style if not specified + # + # Returns the single-character [String] keyword that represents the marker for the specified list type + def list_marker_keyword list_type = nil + ORDERED_LIST_KEYWORDS[list_type || @style] + end + # Internal: Assign the next index (0-based) to this section # # Assign the next index of this section within the parent # Block (in document order) # @@ -367,13 +377,13 @@ @next_section_index += 1 if section.sectname == 'appendix' appendix_number = @document.counter 'appendix-number', 'A' section.number = appendix_number if section.numbered - if (caption = @document.attr 'appendix-caption', '') != '' - section.caption = %(#{caption} #{appendix_number}: ) - else + if (caption = @document.attr 'appendix-caption', '').empty? section.caption = %(#{appendix_number}. ) + else + section.caption = %(#{caption} #{appendix_number}: ) end elsif section.numbered # chapters in a book doctype should be sequential even when divided into parts if (section.level == 1 || (section.level == 0 && section.special)) && @document.doctype == 'book' section.number = @document.counter('chapter-number', 1)