Better support for imbricated markdown emphasis

This commit is contained in:
livefromthemoon@gmail.com 2010-10-30 18:02:43 +02:00
parent 112088ace3
commit ebf9dd464f
2 changed files with 4 additions and 2 deletions

View file

@ -36,8 +36,8 @@ module StatusMessagesHelper
end
# markdown
message.gsub!(/([^\\]|^)\*\*(([^*]|([^*]\*[^*]))*[^\\])\*\*/, '\1<strong>\2</strong>')
message.gsub!(/([^\\]|^)__(([^_]|([^_]_[^_]))*[^\\])__/, '\1<strong>\2</strong>')
message.gsub!(/([^\\]|^)\*\*(([^*]|([^*]\*[^*]))*[^*\\])\*\*/, '\1<strong>\2</strong>')
message.gsub!(/([^\\]|^)__(([^_]|([^_]_[^_]))*[^_\\])__/, '\1<strong>\2</strong>')
message.gsub!(/([^\\]|^)\*([^*]*[^\\])\*/, '\1<em>\2</em>')
message.gsub!(/([^\\]|^)_([^_]*[^\\])_/, '\1<em>\2</em>')
message.gsub!(/([^\\]|^)\*/, '\1')

View file

@ -99,6 +99,8 @@ describe StatusMessagesHelper do
make_links(message).should == "<strong>this is <em>some</em> text</strong>"
message = "*this is **some** text*"
make_links(message).should == "<em>this is <strong>some</strong> text</em>"
message = "___some text___"
make_links(message).should == "<em><strong>some text</strong></em>"
end
end