lib/asciidoctor/section.rb in asciidoctor-0.1.0 vs lib/asciidoctor/section.rb in asciidoctor-0.1.1
- old
+ new
@@ -1,5 +1,6 @@
+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.
#
# Examples
@@ -15,11 +16,11 @@
# => "sect1"
#
# section << new_block
# section.size
# => 1
-class Asciidoctor::Section < Asciidoctor::AbstractBlock
+class Section < AbstractBlock
# Public: Get/Set the Integer index of this section within the parent block
attr_accessor :index
# Public: Get/Set the section name of this section
@@ -34,11 +35,11 @@
def initialize(parent = nil, level = nil)
super(parent, :section)
if level.nil? && !parent.nil?
@level = parent.level + 1
end
- if parent.is_a?(::Asciidoctor::Section) && parent.special
+ if parent.is_a?(Section) && parent.special
@special = true
else
@special = false
end
@index = 0
@@ -87,11 +88,12 @@
end
# Public: Get the rendered String content for this Section and all its child
# Blocks.
def render
- Asciidoctor.debug { "Now rendering section for #{self}" }
+ Debug.debug { "Now rendering section for #{self}" }
+ @document.playback_attributes @attributes
renderer.render('section', self)
end
# Public: Get the String section content by aggregating rendered section blocks.
#
@@ -150,11 +152,11 @@
# # => 1,1,1
#
# Returns the section number as a String
def sectnum(delimiter = '.', append = nil)
append ||= (append == false ? '' : delimiter)
- if !@level.nil? && @level > 1 && @parent.is_a?(::Asciidoctor::Section)
+ if !@level.nil? && @level > 1 && @parent.is_a?(Section)
"#{@parent.sectnum(delimiter)}#{@index + 1}#{append}"
else
"#{@index + 1}#{append}"
end
end
@@ -168,6 +170,7 @@
end
else
super.to_s
end
end
+end
end