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.
Attributes
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 Integer Array. These 3 numbers are used to store the section counters over multiple RichTextSnip
objects.
# 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.
# 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.
# 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.
# File lib/taskjuggler/RichText/Snip.rb, line 69 def internalReferences @richText.internalReferences end
Set the target for all anchor links in the document.
# 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
.
# File lib/taskjuggler/RichText/Snip.rb, line 63 def tableOfContents(toc, fileName) @richText.tableOfContents(toc, fileName) end