class TaskJuggler::RichTextSnip

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.



Public Class Methods

new(document, fileName, sectionCounter) click to toggle source

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.

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

  text = '' do |file|
    file.each_line { |line| text += line }
  rText =, @document.functionHandlers)
  unless (@richText = rText.generateIntermediateFormat(sectionCounter))

  @prevSnip = @nextSnip = nil

Public Instance Methods

cssClass=(css) click to toggle source

Set the CSS class.

# File lib/taskjuggler/RichText/Snip.rb, line 56
def cssClass=(css)
  @richText.cssClass = css
generateHTML(directory = '') click to toggle source

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.

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

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

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

  html.write(directory + @name + '.html')
internalReferences() click to toggle source

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

# File lib/taskjuggler/RichText/Snip.rb, line 68
def internalReferences
linkTarget=(target) click to toggle source

Set the target for all anchor links in the document.

# File lib/taskjuggler/RichText/Snip.rb, line 51
def linkTarget=(target)
  @richText.linkTarget = target
tableOfContents(toc, fileName) click to toggle source

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

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