Sha256: 67474a6839b847d318e7bcbb1aec7329686c7222295919752b6062a84de988a4

Contents?: true

Size: 1009 Bytes

Versions: 3

Compression:

Stored size: 1009 Bytes

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?
      process_block(lines, r, syntax, lexed[:cls], lexed[:params])
    end
    
    def process_block(lines, r, syntax, cls_array, params)
      previous_pgroup , r.enable_pgroup = r.enable_pgroup , false if params.member? 'wo-pgroup'
      r << "<#{@markup}#{class_string(cls_array)}>\n"
      while lines.size > 0
        if 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

3 entries across 3 versions & 1 rubygems

Version Path
arti_mark-0.0.1.beta2 lib/arti_mark/common_block_parser.rb
arti_mark-0.0.1.beta1 lib/arti_mark/common_block_parser.rb
arti_mark-0.0.1.beta0 lib/arti_mark/common_block_parser.rb