Sha256: 5173b3faef99435f035095d3de120408cf92b207cb4fc8b39223e8ae571a52b9

Contents?: true

Size: 720 Bytes

Versions: 69

Compression:

Stored size: 720 Bytes

Contents

# -*- coding: utf-8 -*-

module RubyToBlock
  # XMLをフォーマットするクラス
  #
  # REXML::Formatters::Prettyでは行頭、行末などのスペースが1つになって
  # しまうため、このクラスではそれらを修正している
  class Formatter < REXML::Formatters::Pretty
    def initialize
      super(2, true)
      self.compact = true
    end

    def write_text(node, output)
      s = node.to_s
      s.gsub!(/\s/, ' ')
      if !node.is_a?(REXML::Text) ||
          node.is_a?(REXML::Text) && !node.parent.whitespace
        s.squeeze!(' ')
      end
      s = wrap(s, @width - @level)
      s = indent_text(s, @level, ' ', true)
      output << (' ' * @level + s)
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
smalruby-editor-0.4.1-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.4.2-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.4.2 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.4.1 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.4.0-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.4.0 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.5-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.5 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.4-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.4 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.3-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.3 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.2-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.2 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.1-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.1 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.0-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.3.0 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.7-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.7 app/models/concerns/ruby_to_block/formatter.rb