lib/wparser/inline/underLine.rb in wparser-0.0.2 vs lib/wparser/inline/underLine.rb in wparser-0.1.0
- old
+ new
@@ -1,9 +1,13 @@
-module UnderLine
- def parse line
- parse_line = line.sub(/\+\b(\w*)\b\+/){|s| "<U>#$1</U>"}
- return line if parse_line == nil
- parse_line
- end
+require 'wparser/parse'
- module_function :parse
+module Inlines
+ class UnderLine < Parse
+ def self.parse line
+ @result = line.gsub!(/(?:(?!\\\+)(^|.)\+)(.+?)(?:(?!\\\+)(.)\+)/){|s|
+ "#$1<U>#$2#$3</U>"
+ }
+ @result = line.gsub!(/\\\+/, '+')
+ super
+ end
+ end
end