Sha256: 12a9fca1ae4aeb5f77e823d496a8d5d01abaa5a70a36def69cd842fdc0a32d3a

Contents?: true

Size: 524 Bytes

Versions: 9

Compression:

Stored size: 524 Bytes

Contents

# frozen-string-literal: true
require 'temple'

module Faml
  class Newline < Temple::Filter
    def on_multi(*exprs)
      i = exprs.size - 1
      marker = false
      while i >= 0
        case exprs[i]
        when [:rmnl]
          marker = true
          exprs.delete_at(i)
        when [:mknl]
          if marker
            marker = false
            exprs.delete_at(i)
          else
            exprs[i] = [:static, "\n"]
          end
        end
        i -= 1
      end
      [:multi, *exprs]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
faml-0.7.3 lib/faml/newline.rb
faml-0.7.2 lib/faml/newline.rb
faml-0.7.1 lib/faml/newline.rb
faml-0.7.0 lib/faml/newline.rb
faml-0.6.5 lib/faml/newline.rb
faml-0.6.4 lib/faml/newline.rb
faml-0.6.3 lib/faml/newline.rb
faml-0.6.2 lib/faml/newline.rb
faml-0.6.1 lib/faml/newline.rb