lib/wparser/inline/inline.rb in wparser-0.0.2 vs lib/wparser/inline/inline.rb in wparser-0.1.0
- old
+ new
@@ -2,33 +2,41 @@
require 'wparser/inline/strong'
require 'wparser/inline/italic'
require 'wparser/inline/underLine'
require 'wparser/inline/deleted'
require 'wparser/inline/http'
+require 'wparser/inline/paragraph'
module Inline
- include Heading
- include Strong
- include Italic
- include UnderLine
- include Deleted
- include Http
+ include Inlines
def parse text
- parse_text = ""
+ @protected_preTag = nil
+ parse_lines = text.collect {|line| parse_line line}
- text.each do |line|
- parse_line = Heading.parse(line)
- parse_line = Strong.parse(parse_line)
- parse_line = Italic.parse(parse_line)
- parse_line = UnderLine.parse(parse_line)
- parse_line = Deleted.parse(parse_line)
+ Http.parse parse_lines.to_s
+ end
- parse_text << parse_line
+ private
+ # 1行ずつ処理したいメソッド郡
+ def parse_line line
+ if line =~ /^<pre.*>/
+ @protected_preTag = true
+ elsif line =~ /<\/pre>/
+ @protected_preTag = nil
end
- parse_text = Http.parse(parse_text)
- parse_text
+ parse_line = line
+ if @protected_preTag == nil
+ parse_line = Heading.parse parse_line
+ parse_line = Strong.parse parse_line
+ parse_line = Italic.parse parse_line
+ parse_line = UnderLine.parse parse_line
+ parse_line = Deleted.parse parse_line
+ parse_line = Paragraph.parse parse_line
+ else
+ parse_line
+ end
end
- module_function :parse
+ module_function :parse, :parse_line
end