lib/asciidoctor/section.rb in asciidoctor-1.5.8 vs lib/asciidoctor/section.rb in asciidoctor-2.0.0.rc.1
- old
+ new
@@ -1,6 +1,6 @@
-# encoding: UTF-8
+# frozen_string_literal: true
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.
#
@@ -128,13 +128,13 @@
elsif xrefstyle
if @numbered
case xrefstyle
when 'full'
if (type = @sectname) == 'chapter' || type == 'appendix'
- quoted_title = sprintf sub_quotes('_%s_'), title
+ quoted_title = sub_placeholder (sub_quotes '_%s_'), title
else
- quoted_title = sprintf sub_quotes(@document.compat_mode ? %q(``%s'') : '"`%s`"'), title
+ quoted_title = sub_placeholder (sub_quotes @document.compat_mode ? %q(``%s'') : '"`%s`"'), title
end
if (signifier = @document.attributes[%(#{type}-refsig)])
%(#{signifier} #{sectnum '.', ','} #{quoted_title})
else
%(#{sectnum '.', ','} #{quoted_title})
@@ -144,14 +144,14 @@
%(#{signifier} #{sectnum '.', ''})
else
sectnum '.', ''
end
else # 'basic'
- (type = @sectname) == 'chapter' || type == 'appendix' ? (sprintf sub_quotes('_%s_'), title) : title
+ (type = @sectname) == 'chapter' || type == 'appendix' ? (sub_placeholder (sub_quotes '_%s_'), title) : title
end
else # apply basic styling
- (type = @sectname) == 'chapter' || type == 'appendix' ? (sprintf sub_quotes('_%s_'), title) : title
+ (type = @sectname) == 'chapter' || type == 'appendix' ? (sub_placeholder (sub_quotes '_%s_'), title) : title
end
else
title
end
end
@@ -213,12 +213,13 @@
gen_id = gen_id.tr_s sep_sub, sep
gen_id = gen_id.chop if gen_id.end_with? sep
# ensure id doesn't begin with idseparator if idprefix is empty (assuming idseparator is not empty)
gen_id = gen_id.slice 1, gen_id.length if pre.empty? && (gen_id.start_with? sep)
end
- if document.catalog[:ids].key? gen_id
- ids, cnt = document.catalog[:ids], Compliance.unique_id_start_index
- cnt += 1 while ids.key?(candidate_id = %(#{gen_id}#{sep}#{cnt}))
+ if document.catalog[:refs].key? gen_id
+ ids = document.catalog[:refs]
+ cnt = Compliance.unique_id_start_index
+ cnt += 1 while ids[candidate_id = %(#{gen_id}#{sep}#{cnt})]
candidate_id
else
gen_id
end
end