Class: Comment
- Inherits:
-
SGMLObject
- Object
- TreeObject
- SGMLObject
- Comment
- Defined in:
- lib/rwd/xml.rb,
lib/rwd/sgml.rb
Instance Attribute Summary
Attributes inherited from TreeObject
#children, #closed, #level, #parent, #subtype, #text, #upordown, #visible
Instance Method Summary collapse
-
#initialize(text) ⇒ Comment
constructor
A new instance of Comment.
- #prechildren_to_sgml(res) ⇒ Object
- #prechildren_to_x(res, closetags) ⇒ Object
Methods inherited from SGMLObject
Methods inherited from TreeObject
Methods included from ParseTree
Methods included from TextArray
Constructor Details
#initialize(text) ⇒ Comment
Returns a new instance of Comment.
39 40 41 42 |
# File 'lib/rwd/sgml.rb', line 39 def initialize(text) super() @text = text end |
Instance Method Details
#prechildren_to_sgml(res) ⇒ Object
44 45 46 |
# File 'lib/rwd/sgml.rb', line 44 def prechildren_to_sgml(res) res << "#{@text}" end |
#prechildren_to_x(res, closetags) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rwd/xml.rb', line 20 def prechildren_to_x(res, ) res << "\n" if not previous([], [Text]).kind_of?(Comment) lines = @text.gsub(/(<!--|-->)/, "").lf.split(/\n/) if lines.length == 1 res << " "*(@level-1) + "<!-- " + lines[0].strip + " -->" + "\n" else res << " "*(@level-1) + "<!--" + "\n" res << lines.collect{|s| " "*(@level-1) + s.strip}.delete_if{|s| s.compress.empty?}.join("\n") res << "\n" res << " "*(@level-1) + "-->" + "\n" res << "\n" end end |