### Home Classes Methods

### In Files

- lib/maruku/toc.rb

### Parent

Object

### Methods

- ::new
- #create_toc
- #inspect
- #numerate
- #to_html
- #to_latex
- #to_latex_rec

### Included Modules

- REXML

### Class/Module Index

Quicksearch

- MaRuKu
- MaRuKu::Errors
- MaRuKu::Exception
- MaRuKu::Helpers
- MaRuKu::In
- MaRuKu::In::Markdown
- MaRuKu::In::Markdown::BlockLevelParser
- MaRuKu::In::Markdown::BlockLevelParser::BlockContext
- MaRuKu::In::Markdown::BlockLevelParser::LineSource
- MaRuKu::In::Markdown::SpanExtension
- MaRuKu::In::Markdown::SpanLevelParser
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- MaRuKu::In::Markdown::SpanLevelParser::HTMLHelper
- MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- MaRuKu::MDDocument
- MaRuKu::MDElement
- MaRuKu::Out
- MaRuKu::Out::HTML
- MaRuKu::Out::Latex
- MaRuKu::Out::Latex::LatexEntity
- MaRuKu::Out::Markdown
- MaRuKu::Section
- MaRuKu::Strings
- MaRuKu::Tests
- Array
- Hash
- Maruku
- Module
- NilClass
- Object
- String
- Textile2Signature

No matching classes.

# MaRuKu::Section

This represents a section in the TOC.

### Attributes

header_element[RW]

reference to header (header has h.meta to self)

immediate_children[RW]

Array of immediate children of this element

section_children[RW]

Array of Section inside this section

section_level[RW]

a Fixnum, is == header_element.level

section_number[RW]

An array of fixnum, like [1,2,5] for Section 1.2.5

### Public Class Methods

new() click to toggle source

    # File lib/maruku/toc.rb, line 46
    def initialize
            @immediate_children = []
            @section_children = []
    end

### Public Instance Methods

inspect(indent=1) click to toggle source

    # File lib/maruku/toc.rb, line 53
    def inspect(indent=1)
            s = ""
            if @header_element
                    s +=  "\_"*indent +  "(#{@section_level})>\t #{@section_number.join('.')} : "
                    s +=  @header_element.children_to_s +
                     " (id: '#{@header_element.attributes[:id]}')\n"
            else
                    s += "Master\n"
            end

            @section_children.each do |c|
                    s+=c.inspect(indent+1)
            end
            s
    end

numerate(a=[]) click to toggle source

Numerate this section and its children

    # File lib/maruku/toc.rb, line 70
    def numerate(a=[])
            self.section_number = a
            section_children.each_with_index do |c,i|
                    c.numerate(a.clone.push(i+1))
            end
            if h = self.header_element
                    h.attributes[:section_number] = self.section_number
            end
    end

to_html() click to toggle source

Creates an HTML toc. Call this on the root

    # File lib/maruku/toc.rb, line 83
    def to_html
            div = Element.new 'div'
            div.attributes['class'] = 'maruku_toc'
            div << create_toc
            div
    end

to_latex() click to toggle source

Creates a latex toc. Call this on the root

    # File lib/maruku/toc.rb, line 111
    def to_latex
            to_latex_rec + "\n\n"
    end

to_latex_rec() click to toggle source

    # File lib/maruku/toc.rb, line 115
    def to_latex_rec
            s = ""
            @section_children.each do |c|
                    s += "\\noindent"
                    number = c.header_element.section_number
                    s += number if number
                            text = c.header_element.children_to_latex
                            id = c.header_element.attributes[:id]
                    s += "\\hyperlink{#{id}}{#{text}}"
                    s += "\\dotfill \\pageref*{#{id}} \\linebreak\n"
                    s += c.to_latex_rec  if c.section_children.size>0

            end
            s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.