Sha256: 10af30a30d408813145f0ef44c47f6675251fff7226e7757c46277ee34580e6b

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# -*- encoding: utf-8 -*-
require 'singleton'

module ArtiMark
  module CommonBlockParser
    include BaseParser
    def accept?(lines)
      lex_block_command(lines[0])[:cmd] =~ @command
    end

    def parse(lines, r, syntax)
      lexed = lex_block_command(lines.shift)
      throw 'something wrong here #{lines}' unless lexed[:cmd] =~ @command
      @markup = lexed[:cmd] if @markup.nil?
      r.enter_block(lexed)
      process_block(lines, r, syntax, lexed[:ids], lexed[:cls], lexed[:params])
      r.exit_block(lexed)
    end
    
    def process_block(lines, r, syntax, ids_array, cls_array, params)
      previous_pgroup , r.enable_pgroup = r.enable_pgroup , false if params.member? 'wo-pgroup'
      r << "<#{@markup}#{ids_string(ids_array)}#{class_string(cls_array)}>\n"
      while lines.size > 0
        if r.block_close? lines[0] 
          lines.shift
          break
        else
          syntax.determine_parser(lines, :get_default => true).call(lines, r, syntax)
        end
      end
      r << "</#{@markup}>\n"
      r.enable_pgroup = previous_pgroup if !previous_pgroup.nil?
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
arti_mark-0.1.beta3 lib/arti_mark/common_block_parser.rb
arti_mark-0.1.beta2 lib/arti_mark/common_block_parser.rb
arti_mark-0.1.beta1 lib/arti_mark/common_block_parser.rb
arti_mark-0.0.1.beta4 lib/arti_mark/common_block_parser.rb