Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

17 lines (13 sloc) 0.449 kb
module Jekyll
module SimpleFormatFilter
def simple_format(text)
text = '' if text.nil?
text = text.to_str
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n\n+/, "</p>\n\n<p>") # 2+ newline -> paragraph
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
"<p>#{text}</p>"
end
end
end
Liquid::Template.register_filter(Jekyll::SimpleFormatFilter)
Jump to Line
Something went wrong with that request. Please try again.