Sha256: a7bbd502de94bd8dd137dd56ffa7de5667df9e38753a953a3c3cdedc05712da5

Contents?: true

Size: 1.17 KB

Versions: 101

Compression:

Stored size: 1.17 KB

Contents

##
# A heading with a level (1-6) and text

class RDoc::Markup::Heading < Struct.new :level, :text

  @to_html = nil
  @to_label = nil

  ##
  # A singleton RDoc::Markup::ToLabel formatter for headings.

  def self.to_label
    @to_label ||= RDoc::Markup::ToLabel.new
  end

  ##
  # A singleton plain HTML formatter for headings.  Used for creating labels
  # for the Table of Contents

  def self.to_html
    return @to_html if @to_html

    markup = RDoc::Markup.new
    markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF

    @to_html = RDoc::Markup::ToHtml.new

    def @to_html.handle_special_CROSSREF special
      special.text.sub(/^\\/, '')
    end

    @to_html
  end

  ##
  # Calls #accept_heading on +visitor+

  def accept visitor
    visitor.accept_heading self
  end

  ##
  # An HTML-safe anchor reference for this header.

  def aref
    "label-#{self.class.to_label.convert text.dup}"
  end

  ##
  # HTML markup of the text of this label without the surrounding header
  # element.

  def plain_html
    self.class.to_html.to_html(text.dup)
  end

  def pretty_print q # :nodoc:
    q.group 2, "[head: #{level} ", ']' do
      q.pp text
    end
  end

end

Version data entries

101 entries across 79 versions & 20 rubygems

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/heading.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/heading.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/heading.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/heading.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/heading.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
challah-1.0.0.beta3 vendor/bundle/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
challah-1.0.0.beta2 vendor/bundle/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
challah-1.0.0.beta vendor/bundle/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
challah-1.0.0.beta vendor/bundle/gems/rdoc-3.12/lib/rdoc/markup/heading.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/heading.rb
rdoc-3.12.2 lib/rdoc/markup/heading.rb
active_mailer-0.0.5 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/heading.rb