Class: TaskJuggler::RichTextIntermediate
- Defined in:
- lib/taskjuggler/RichText.rb,
lib/taskjuggler/RichText/RTFWithQuerySupport.rb
Overview
The RichTextIntermediate is a container for the intermediate representation of a RichText object. By calling the to_* members it can be converted into the respective formats. A RichTextIntermediate object is generated by RichText::generateIntermediateFormat.
Instance Attribute Summary collapse
-
#blockMode ⇒ Object
Returns the value of attribute blockMode.
-
#cssClass ⇒ Object
Returns the value of attribute cssClass.
-
#functionHandlers ⇒ Object
readonly
Returns the value of attribute functionHandlers.
-
#indent ⇒ Object
Returns the value of attribute indent.
-
#lineWidth ⇒ Object
Returns the value of attribute lineWidth.
-
#linkTarget ⇒ Object
Returns the value of attribute linkTarget.
-
#listIndent ⇒ Object
Returns the value of attribute listIndent.
-
#parIndent ⇒ Object
Returns the value of attribute parIndent.
-
#preIndent ⇒ Object
Returns the value of attribute preIndent.
-
#richText ⇒ Object
readonly
Returns the value of attribute richText.
-
#sectionNumbers ⇒ Object
Returns the value of attribute sectionNumbers.
-
#titleIndent ⇒ Object
Returns the value of attribute titleIndent.
-
#tree ⇒ Object
Returns the value of attribute tree.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Return true if the RichText has no content.
-
#functionHandler(function) ⇒ Object
Return the handler for the given function or raise an exception if it does not exist.
-
#initialize(richText) ⇒ RichTextIntermediate
constructor
A new instance of RichTextIntermediate.
-
#internalReferences ⇒ Object
Return an Array with all other snippet names that are referenced by internal references in this RichTextElement.
-
#registerFunctionHandler(functionHandler) ⇒ Object
Use this function to register new RichTextFunctionHandler objects with this class.
- #setQuery(query) ⇒ Object
-
#tableOfContents(toc, fileName) ⇒ Object
Recursively extract the section headings from the RichTextElement and build the TableOfContents toc with the gathered sections.
-
#to_html ⇒ Object
Convert the intermediate format into a XMLElement objects tree.
-
#to_s ⇒ Object
Convert the intermediate format into a plain text String object.
-
#to_tagged ⇒ Object
Convert the intermediate format into a tagged syntax String object.
Constructor Details
#initialize(richText) ⇒ RichTextIntermediate
Returns a new instance of RichTextIntermediate.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/taskjuggler/RichText.rb', line 148 def initialize(richText) # A reference to the corresponding RichText object the RTI is derived # from. @richText = richText # The root of the generated intermediate format. This is a # RichTextElement. @tree = nil # The blockMode specifies whether the RichText should be interpreted as # a line of text or a block (default). @blockMode = true # Set this to false to disable automatically generated section numbers. @sectionNumbers = true # Set this to the maximum width used for text output. @lineWidth = 80 # The indentation used for all text output. @indent = 0 # Additional indentation used for titles in text output. @titleIndent = 0 # Additional indentation used for paragraph text output. @parIndent = 0 # Additional indentation used for lists in text output. @listIndent = 1 # Additional indentation used for <pre> sections in text output. @preIndent = 0 # The target used for hypertext links. @linkTarget = nil # The CSS class used for some key HTML elements. @cssClass = nil # These are the RichTextFunctionHandler objects to handle references with # a function specification. @functionHandlers = {} end |
Instance Attribute Details
#blockMode ⇒ Object
Returns the value of attribute blockMode.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def blockMode @blockMode end |
#cssClass ⇒ Object
Returns the value of attribute cssClass.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def cssClass @cssClass end |
#functionHandlers ⇒ Object (readonly)
Returns the value of attribute functionHandlers.
142 143 144 |
# File 'lib/taskjuggler/RichText.rb', line 142 def functionHandlers @functionHandlers end |
#indent ⇒ Object
Returns the value of attribute indent.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def indent @indent end |
#lineWidth ⇒ Object
Returns the value of attribute lineWidth.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def lineWidth @lineWidth end |
#linkTarget ⇒ Object
Returns the value of attribute linkTarget.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def linkTarget @linkTarget end |
#listIndent ⇒ Object
Returns the value of attribute listIndent.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def listIndent @listIndent end |
#parIndent ⇒ Object
Returns the value of attribute parIndent.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def parIndent @parIndent end |
#preIndent ⇒ Object
Returns the value of attribute preIndent.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def preIndent @preIndent end |
#richText ⇒ Object (readonly)
Returns the value of attribute richText.
142 143 144 |
# File 'lib/taskjuggler/RichText.rb', line 142 def richText @richText end |
#sectionNumbers ⇒ Object
Returns the value of attribute sectionNumbers.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def sectionNumbers @sectionNumbers end |
#titleIndent ⇒ Object
Returns the value of attribute titleIndent.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def titleIndent @titleIndent end |
#tree ⇒ Object
Returns the value of attribute tree.
143 144 145 |
# File 'lib/taskjuggler/RichText.rb', line 143 def tree @tree end |
Instance Method Details
#empty? ⇒ Boolean
Return true if the RichText has no content.
195 196 197 |
# File 'lib/taskjuggler/RichText.rb', line 195 def empty? @tree.empty? end |
#functionHandler(function) ⇒ Object
Return the handler for the given function or raise an exception if it does not exist.
190 191 192 |
# File 'lib/taskjuggler/RichText.rb', line 190 def functionHandler(function) @functionHandlers[function] end |
#internalReferences ⇒ Object
Return an Array with all other snippet names that are referenced by internal references in this RichTextElement.
209 210 211 |
# File 'lib/taskjuggler/RichText.rb', line 209 def internalReferences @tree.internalReferences end |
#registerFunctionHandler(functionHandler) ⇒ Object
Use this function to register new RichTextFunctionHandler objects with this class.
183 184 185 186 |
# File 'lib/taskjuggler/RichText.rb', line 183 def registerFunctionHandler(functionHandler) raise "Bad function handler" unless functionHandler @functionHandlers[functionHandler.function] = functionHandler.dup end |
#setQuery(query) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/taskjuggler/RichText/RTFWithQuerySupport.rb', line 36 def setQuery(query) @functionHandlers.each_value do |handler| if handler.respond_to?('setQuery') handler.setQuery(query) end end end |
#tableOfContents(toc, fileName) ⇒ Object
Recursively extract the section headings from the RichTextElement and build the TableOfContents toc with the gathered sections. fileName is the base name (without .html or other suffix) of the file the TOCEntries should point to.
203 204 205 |
# File 'lib/taskjuggler/RichText.rb', line 203 def tableOfContents(toc, fileName) @tree.tableOfContents(toc, fileName) end |
#to_html ⇒ Object
Convert the intermediate format into a XMLElement objects tree.
221 222 223 224 225 |
# File 'lib/taskjuggler/RichText.rb', line 221 def to_html html = @tree.to_html html.chomp! while html[-1] == ?\n html end |
#to_s ⇒ Object
Convert the intermediate format into a plain text String object.
214 215 216 217 218 |
# File 'lib/taskjuggler/RichText.rb', line 214 def to_s str = @tree.to_s str.chomp! while str[-1] == ?\n str end |
#to_tagged ⇒ Object
Convert the intermediate format into a tagged syntax String object.
228 229 230 |
# File 'lib/taskjuggler/RichText.rb', line 228 def to_tagged @tree.to_tagged end |