Method: Vanity::Render#vanity_simple_format
- Defined in:
- lib/vanity/commands/report.rb
#vanity_simple_format(text, options = {}) ⇒ Object
Dumbed down from Rails’ simple_format.
41 42 43 44 45 46 47 |
# File 'lib/vanity/commands/report.rb', line 41 def vanity_simple_format(text, = {}) open = "<p #{.map { |k, v| "#{k}=\"#{CGI.escapeHTML v}\"" }.join(' ')}>" text = open + text.gsub(/\r\n?/, "\n") # \r\n and \r -> \n # rubocop:todo Lint/UselessAssignment .gsub(/\n\n+/, "</p>\n\n#{open}") # 2+ newline -> paragraph .gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') + # 1 newline -> br "</p>" end |