lib/wparser/inline/italic.rb in wparser-0.0.2 vs lib/wparser/inline/italic.rb in wparser-0.1.0

- old
+ new

@@ -1,9 +1,13 @@ -module Italic - def parse line - parse_line = line.sub(/\b_(\w*)_\b/){|s| "<I>#$1</I>"} - return line if parse_line == nil - parse_line - end +require 'wparser/parse' - module_function :parse +module Inlines + class Italic < Parse + def self.parse line + @result = line.gsub!(/(?:(?!\\_)(^|.)_)(.+?)(?:(?!\\_)(.)_)/){|s| + "#$1<I>#$2#$3</I>" + } + @result = line.gsub!(/\\_/, '_') + super + end + end end