Class TaskJuggler::RichTextSnip
In: lib/taskjuggler/RichText/Snip.rb
Parent: Object

A RichTextSnip is a building block for a RichTextDocument. It represents the contense of a text file that contains structured text using the RichText syntax. The class can read-in such a text file and generate an equivalent HTML version.

Methods

Attributes

name  [R] 
nextSnip  [RW] 
prevSnip  [RW] 

Public Class methods

Create a RichTextSnip object. document is a reference to the RichTextDocument. fileName is the name of the structured text file using RichText syntax. sectionCounter is an 3 item Fixnum Array. These 3 numbers are used to store the section counters over multiple RichTextSnip objects.

[Source]

# File lib/taskjuggler/RichText/Snip.rb, line 33
    def initialize(document, fileName, sectionCounter)
      @document = document
      # Strip any directories from fileName.
      @name = fileName.index('/') ? fileName[fileName.rindex('/') + 1 .. -1] :
                                    fileName

      text = ''
      File.open(fileName) do |file|
        file.each_line { |line| text += line }
      end
      rText = RichText.new(text, @document.functionHandlers)
      unless (@richText = rText.generateIntermediateFormat(sectionCounter))
        exit
      end

      @prevSnip = @nextSnip = nil
    end

Public Instance methods

Set the CSS class.

[Source]

# File lib/taskjuggler/RichText/Snip.rb, line 57
    def cssClass=(css)
      @richText.cssClass = css
    end

Generate a HTML version of the structured text. The base file name is the same as the original file. directory is the name of the output directory.

[Source]

# File lib/taskjuggler/RichText/Snip.rb, line 76
    def generateHTML(directory = '')
      html = HTMLDocument.new
      head = html.generateHead(@name)
      head << @document.generateStyleSheet

      html.html << (body = XMLElement.new('body'))
      body << @document.generateHTMLHeader
      body << generateHTMLNavigationBar

      body << (div = XMLElement.new('div',
        'style' => 'width:90%; margin-left:5%; margin-right:5%'))
      div << @richText.to_html
      body << generateHTMLNavigationBar
      body << @document.generateHTMLFooter

      html.write(directory + @name + '.html')
    end

Return an Array with all other snippet names that are referenced by internal references in this snip.

[Source]

# File lib/taskjuggler/RichText/Snip.rb, line 69
    def internalReferences
      @richText.internalReferences
    end

Set the target for all anchor links in the document.

[Source]

# File lib/taskjuggler/RichText/Snip.rb, line 52
    def linkTarget=(target)
      @richText.linkTarget = target
    end

Generate a TableOfContents object from the section headers of the RichTextSnip.

[Source]

# File lib/taskjuggler/RichText/Snip.rb, line 63
    def tableOfContents(toc, fileName)
      @richText.tableOfContents(toc, fileName)
    end

[Validate]