Skip to content
Extraits de code Groupes Projets
Valider 24ff28b6 rédigé par echarp's avatar echarp
Parcourir les fichiers

b and i tags also have their eventual inner spaces better managed

parent 2cc80127
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -66,6 +66,7 @@ module EventsHelper ...@@ -66,6 +66,7 @@ module EventsHelper
Kramdown::Document.new(spaces(desc), input: :html, line_width: line_width) Kramdown::Document.new(spaces(desc), input: :html, line_width: line_width)
.to_kramdown .to_kramdown
.gsub(/\\([\"'])/, '\1') # Remove slash before quotes .gsub(/\\([\"'])/, '\1') # Remove slash before quotes
.remove(/[[:blank:]]+$/) # Remove extraneous spaces
.remove(/{::}/) # Markdown artefact .remove(/{::}/) # Markdown artefact
end end
...@@ -73,8 +74,8 @@ module EventsHelper ...@@ -73,8 +74,8 @@ module EventsHelper
# Cleaner html elements, to correct things like <em> test</em> # Cleaner html elements, to correct things like <em> test</em>
def spaces(desc) def spaces(desc)
desc.gsub(/<(strong|em)> /, ' <\1>') desc.gsub(/<(strong|em|b|i)> /, ' <\1>')
.gsub(%r{ </(strong|em)>}, '</\1> ') .gsub(%r{ </(strong|em|b|i)>}, '</\1> ')
.gsub(/ ([,.])/, '\1') .gsub(/[[:space:]]([,.])/, '\1')
end end
end end
...@@ -16,5 +16,6 @@ class EventsHelperTest < ActionView::TestCase ...@@ -16,5 +16,6 @@ class EventsHelperTest < ActionView::TestCase
assert_equal '**h**,', to_markdown('<strong>h </strong>,') assert_equal '**h**,', to_markdown('<strong>h </strong>,')
assert_equal '*ho***h**,', to_markdown('<em>ho</em><strong>h </strong>,') assert_equal '*ho***h**,', to_markdown('<em>ho</em><strong>h </strong>,')
assert_equal '*ho* **h**,', to_markdown('<em>ho</em><strong> h</strong>,') assert_equal '*ho* **h**,', to_markdown('<em>ho</em><strong> h</strong>,')
assert_equal '*ho* **h**,', to_markdown('<i>ho</i><b> h</b>,')
end end
end end
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