Sha256: a3169269df30ff4b70dceb2dc39523536fe7ce7c7752edc0b3c91d4c4e07762c

Contents?: true

Size: 928 Bytes

Versions: 5

Compression:

Stored size: 928 Bytes

Contents

# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2016 Akinori Ichigo <akinori.ichigo@gmail.com>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown
  module Parser
    class Kramdown

      SPAN_START = /(?:\[\[\s*?)/

      # Parse the span at the current location.
      def parse_span
        start_line_number = @src.current_line_number
        saved_pos = @src.save_pos

        result = @src.scan(SPAN_START)
        stop_re = /(?:\s*?\]\])/

         el = Element.new(:span, nil, nil, :location => start_line_number)
         found = parse_spans(el, stop_re) do
           el.children.size > 0
         end

        if found
          @src.scan(stop_re)
          @tree.children << el
        else
          @src.revert_pos(saved_pos)
          @src.pos += result.length
          add_text(result)
        end
      end
      define_parser(:span, SPAN_START, '\[\[')

    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
darkmouun-1.2.0 lib/darkmouun/parser/span.rb
darkmouun-1.1.0 lib/darkmouun/parser/span.rb
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/darkmouun-1.0.4/lib/darkmouun/parser/span.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/darkmouun-1.0.4/lib/darkmouun/parser/span.rb
darkmouun-1.0.4 lib/darkmouun/parser/span.rb