mardownify doesn't strip _/__/*/** without context anymore and allow __/** to be escaped with \__/\** instead of \_\_/\*\*. probably makes it less robust against weired constructs though
This commit is contained in:
parent
1a8e0788c2
commit
c3356af8d1
2 changed files with 12 additions and 9 deletions
|
|
@ -186,14 +186,17 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:emphasis]
|
if options[:emphasis]
|
||||||
message.gsub!(/([^\\]|^)\*\*(([^*]|([^*]\*[^*]))*[^*\\])\*\*/, '\1<strong>\2</strong>')
|
message.gsub!("\\**", "-^doublestar^-")
|
||||||
message.gsub!(/([^\\]|^)__(([^_]|([^_]_[^_]))*[^_\\])__/, '\1<strong>\2</strong>')
|
message.gsub!("\\__", "-^doublescore^-")
|
||||||
message.gsub!(/([^\\]|^)\*([^*]*[^\\])\*/, '\1<em>\2</em>')
|
message.gsub!("\\*", "-^star^-")
|
||||||
message.gsub!(/([^\\]|^)_([^_]*[^\\])_/, '\1<em>\2</em>')
|
message.gsub!("\\_", "-^score^-")
|
||||||
message.gsub!(/([^\\]|^)\*/, '\1')
|
message.gsub!(/(\*\*\*|___)(.+?)\1/m, '<em><strong>\2</strong></em>')
|
||||||
message.gsub!(/([^\\]|^)_/, '\1')
|
message.gsub!(/(\*\*|__)(.+?)\1/m, '<strong>\2</strong>')
|
||||||
message.gsub!("\\*", "*")
|
message.gsub!(/(\*|_)(.+?)\1/m, '<em>\2</em>')
|
||||||
message.gsub!("\\_", "_")
|
message.gsub!("-^doublestar^-", "**")
|
||||||
|
message.gsub!("-^doublescore^-", "__")
|
||||||
|
message.gsub!("-^star^-", "*")
|
||||||
|
message.gsub!("-^score^-", "_")
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:youtube]
|
if options[:youtube]
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ describe ApplicationHelper do
|
||||||
|
|
||||||
it "should allow escaping" do
|
it "should allow escaping" do
|
||||||
message = '*some text* \\*some text* \\**some text* _some text_ \\_some text_ \\__some text_'
|
message = '*some text* \\*some text* \\**some text* _some text_ \\_some text_ \\__some text_'
|
||||||
markdownify(message).should == "<em>some text</em> *some text<em> *</em>some text <em>some text</em> _some text<em> _</em>some text"
|
markdownify(message).should == "<em>some text</em> *some text<em> **some text</em> <em>some text</em> _some text<em> __some text</em>"
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "options" do
|
describe "options" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue