Sha256: fa09c7ce293aa0278e61bdf1ae5a81112cdd50c0f35ca54b3871105c0f93b528

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

require 'wparser/parse'

module Inline
  class Paragraph < Parse
    def self.parse line
      rex = %r!
      ^((<(\/?pre.*|\/?h\d|\/?p|\/?ol|\/?ul|\/?li|\/?blockquote)>)
        |
          (\s?\n))
      !x
      @result = if @p_flag == nil
                  if line !~ rex and @pre_flag == nil
                    @p_flag = true
                    "<p>\n" + line.sub(/\n/, "<br />\n")
                  end
                else # <p>と</>の間にいます。
                  if line =~ rex # 段落の終了点
                    @p_flag = nil
                    "</p>\n" + line
                  else
                    line.sub(/\n/, "<br />\n")
                  end
                end
      super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wparser-0.1.3 lib/wparser/inline/paragraph.rb
wparser-0.1.2 lib/wparser/inline/paragraph.rb
wparser-0.1.1 lib/wparser/inline/paragraph.rb
wparser-0.1.0 lib/wparser/inline/paragraph.rb