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

Better markdown output, for linuxfr

parent 69bfd4ff
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -63,12 +63,10 @@ module EventsHelper ...@@ -63,12 +63,10 @@ module EventsHelper
tags: %w[p br h1 h2 h3 h4 table tr th td ul ol li a strong tags: %w[p br h1 h2 h3 h4 table tr th td ul ol li a strong
b em i sub sup], b em i sub sup],
attributes: %w[href] attributes: %w[href]
result = Kramdown::Document.new(desc, input: :html, line_width: line_width) Kramdown::Document.new(desc, input: :html, line_width: line_width)
.to_kramdown .to_kramdown
# Remove extraneous line feeds .remove(/ +$/) # Remove extraneous line feeds
return if result.nil? || result.blank? .gsub(/\\([\"'])/, '\1') # Remove slash before quotes
result.gsub(/\n\n+/, ' .gsub(/(\n\n)\n+/, '\1') # Fewer line feeds
').gsub(/\\([\"'])/, '\1')
end end
end end
require 'test_helper' require 'test_helper'
# Test some event helper methods
class EventsHelperTest < ActionView::TestCase class EventsHelperTest < ActionView::TestCase
test 'Markdown with empty content' do
assert_equal '', to_markdown('')
assert_equal '', to_markdown(' ')
assert_equal "'", to_markdown("\'")
assert_equal '', to_markdown('
')
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