Skip to content
Extraits de code Groupes Projets
Valider c3356af8 rédigé par MrZYX's avatar MrZYX
Parcourir les fichiers

mardownify doesn't strip _/__/*/** without context anymore and allow __/** to...

mardownify doesn't strip _/__/*/** without context anymore and allow __/** to be escaped with \__/\** instead of \_\_/\*\*. probably makes it less robust against weired constructs though
parent 1a8e0788
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -186,14 +186,17 @@ module ApplicationHelper ...@@ -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 ...@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter