|
|
|
@ -63,10 +63,18 @@ 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] |
|
|
|
|
Kramdown::Document.new(desc, input: :html, line_width: line_width) |
|
|
|
|
Kramdown::Document.new(spaces(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 |
|
|
|
|
.remove(/{::}/) # Markdown artefact |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
|
# Cleaner html elements, to correct things like <em> test</em> |
|
|
|
|
def spaces(desc) |
|
|
|
|
desc.gsub(/<(strong|em)> /, ' <\1>') |
|
|
|
|
.gsub(%r{ </(strong|em)>}, '</\1> ') |
|
|
|
|
.gsub(/ ([,.])/, '\1') |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|