Sha256: ef3780e360d7db9e2e3ab10da5c31a4c6221649b66c2e7a0dd6c3287bb4b2435

Contents?: true

Size: 942 Bytes

Versions: 24

Compression:

Stored size: 942 Bytes

Contents

# @Opulent
module Opulent
  # @Parser
  class Parser
    # Match one line or multiline comments
    #
    def comment(parent, indent)
      if (accept :comment)
        multiline = true if (accept :comment)

        buffer = accept(:line_feed)
        buffer += accept(:newline) || ""
        buffer += get_indented_lines indent if multiline


        # If we have a comment which is visible in the output, we will
        # create a new comment element. Otherwise, we ignore the current
        # gathered text and we simply begin the root parsing again
        if buffer[0] == '!'
          offset = 1; options = {}

          # Allow leading comment newline
          if buffer[1] == '^'
            offset = 2; options[:newline] = true
          end

          parent[@children] << [:comment, buffer[offset..-1].strip, options, nil, indent]
        end

        return parent
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
opulent-1.5.5 lib/opulent/parser/comment.rb
opulent-1.5.4 lib/opulent/parser/comment.rb
opulent-1.5.3 lib/opulent/parser/comment.rb
opulent-1.5.2 lib/opulent/parser/comment.rb
opulent-1.5.1 lib/opulent/parser/comment.rb
opulent-1.5.0 lib/opulent/parser/comment.rb
opulent-1.4.8 lib/opulent/parser/comment.rb
opulent-1.4.7 lib/opulent/parser/comment.rb
opulent-1.4.6 lib/opulent/parser/comment.rb
opulent-1.4.5 lib/opulent/parser/comment.rb
opulent-1.4.3 lib/opulent/parser/comment.rb
opulent-1.4.2 lib/opulent/parser/comment.rb
opulent-1.4.1 lib/opulent/parser/comment.rb
opulent-1.4.0 lib/opulent/parser/comment.rb
opulent-1.3.3 lib/opulent/parser/comment.rb
opulent-1.3.2 lib/opulent/parser/comment.rb
opulent-1.3.1 lib/opulent/parser/comment.rb
opulent-1.3.0 lib/opulent/parser/comment.rb
opulent-1.2.1 lib/opulent/parser/comment.rb
opulent-1.2.0 lib/opulent/parser/comment.rb