lib/asciidoctor/section.rb in asciidoctor-1.5.1 vs lib/asciidoctor/section.rb in asciidoctor-1.5.2

- old
+ new

@@ -1,5 +1,6 @@ +# encoding: UTF-8 module Asciidoctor # Public: Methods for managing sections of AsciiDoc content in a document. # The section responds as an Array of content blocks by delegating # block-related methods to its @blocks Array. # @@ -39,18 +40,14 @@ # Public: Initialize an Asciidoctor::Section object. # # parent - The parent Asciidoc Object. def initialize parent = nil, level = nil, numbered = true, opts = {} super parent, :section, opts - if level.nil? - if parent - @level = parent.level + 1 - elsif @level.nil? - @level = 1 - end - else + if level @level = level + else + @level = parent ? (parent.level + 1) : 1 end @numbered = numbered && @level > 0 @special = parent && parent.context == :section && parent.special @index = 0 @number = 1 @@ -94,10 +91,10 @@ if pre.empty? && base_id.start_with?(sep) base_id = base_id[1..-1] base_id = base_id[1..-1] while base_id.start_with?(sep) end gen_id = base_id - cnt = 2 + cnt = Compliance.unique_id_start_index while @document.references[:ids].has_key? gen_id gen_id = "#{base_id}#{sep}#{cnt}" cnt += 1 end gen_id