lib/asciidoctor/section.rb in asciidoctor-1.5.4 vs lib/asciidoctor/section.rb in asciidoctor-1.5.5
- old
+ new
@@ -85,11 +85,11 @@
def generate_id
if @document.attributes.has_key? 'sectids'
sep = @document.attributes['idseparator'] || '_'
pre = @document.attributes['idprefix'] || '_'
base_id = %(#{pre}#{title.downcase.gsub(InvalidSectionIdCharsRx, sep).tr_s(sep, sep).chomp(sep)})
- # ensure id doesn't begin with idprefix if requested it doesn't
- if pre.empty? && base_id.start_with?(sep)
+ # ensure id doesn't begin with idseparator if idprefix is empty and idseparator is not empty
+ if pre.empty? && !sep.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 = Compliance.unique_id_start_index