Method: YARD::Templates::Helpers::TextHelper#h

Defined in:
lib/yard/templates/helpers/text_helper.rb

#h(text) ⇒ String

Returns escapes text.

Returns:

[View source]

7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/yard/templates/helpers/text_helper.rb', line 7

def h(text)
  out = ""
  text = text.split(/\n/)
  text.each_with_index do |line, i|
    out <<
    case line
    when /^\s*$/; "\n\n"
    when /^\s+\S/, /^=/; line + "\n"
    else; line + (text[i + 1] =~ /^\s+\S/ ? "\n" : " ")
    end
  end
  out
end