Better markdown output, for linuxfr
This commit is contained in:
parent
69bfd4ffc4
commit
22e4cef45a
@ -63,12 +63,10 @@ module EventsHelper
|
||||
tags: %w[p br h1 h2 h3 h4 table tr th td ul ol li a strong
|
||||
b em i sub sup],
|
||||
attributes: %w[href]
|
||||
result = Kramdown::Document.new(desc, input: :html, line_width: line_width)
|
||||
.to_kramdown
|
||||
# Remove extraneous line feeds
|
||||
return if result.nil? || result.blank?
|
||||
result.gsub(/\n\n+/, '
|
||||
|
||||
').gsub(/\\([\"'])/, '\1')
|
||||
Kramdown::Document.new(desc, input: :html, line_width: line_width)
|
||||
.to_kramdown
|
||||
.remove(/ +$/) # Remove extraneous line feeds
|
||||
.gsub(/\\([\"'])/, '\1') # Remove slash before quotes
|
||||
.gsub(/(\n\n)\n+/, '\1') # Fewer line feeds
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,13 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Test some event helper methods
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user