class Wunderbar::IndentedTextNode

Public Class Methods

reflow(indent, line, width, next_indent) click to toggle source
# File lib/wunderbar/node.rb, line 321
def self.reflow(indent, line, width, next_indent)
  return [line] unless width and indent
  line = indent + line.gsub(/\s+/, ' ').strip
  indent += next_indent

  result = []
  while line.length > width
    split = line.rindex(' ', width)
    break if not split or split <= indent.to_s.length
    result << line[0...split]
    line = "#{indent}#{line[split+1..-1]}"
  end

  result << line
end

Public Instance Methods

serialize(options, result, indent) click to toggle source
# File lib/wunderbar/node.rb, line 337
def serialize(options, result, indent)
  if indent
    text = CDATANode.normalize(@text, indent)
  else
    text = @text
  end

  result.push(*IndentedTextNode.reflow(indent,
    text.to_s.gsub(/[&<>\u00A0]/,ESCAPE), options[:width], ''))
end