class Asciidoctor::Section
def generate_id
another_section.generate_id
another_section.title = "Foo"
another_section = Section.new(parent)
=> "_foo"
section.generate_id
section.title = "Foo"
section = Section.new(parent)
Examples
until a unique id is found.
If the generated id is already in use in the document, a count is appended
Section id synthesis can be disabled by undefining the 'sectids' attribute.
is an underscore by default.
The generated id is prefixed with value of the 'idprefix' attribute, which
Public: Generate a String id for this section.
def generate_id if @document.attr? 'sectids' separator = @document.attr('idseparator', '_') base_id = @document.attr('idprefix', '_') + title.downcase.gsub(/&#[0-9]+;/, separator). gsub(/\W+/, separator).tr_s(separator, separator).chomp(separator) gen_id = base_id cnt = 2 while @document.references[:ids].has_key? gen_id gen_id = "#{base_id}#{separator}#{cnt}" cnt += 1 end @document.register(:ids, [gen_id, title]) gen_id else nil end end