class TaskJuggler::XMLComment
This is a specialized XMLElement
to represent a comment.
Public Class Methods
Source
# File lib/taskjuggler/XMLElement.rb, line 202 def initialize(text = +'') super(nil, {}) @text = text end
Calls superclass method
TaskJuggler::XMLElement::new
Public Instance Methods
Source
# File lib/taskjuggler/XMLElement.rb, line 207 def to_s(indent) '<!-- ' + canonicalize_comment(@text) + " -->\n#{' ' * indent}" end
Private Instance Methods
Source
# File lib/taskjuggler/XMLElement.rb, line 217 def canonicalize_comment(text) new_text = text.gsub("--", "-\\-") new_text end
It is crucial to canonicalize xml comment text because xml comment syntax forbids having a – in the comment body. I picked emacs’s “M-x comment-region” approach of putting a backslash between the two.