Module: Source2MD::TextHelper
Instance Method Summary collapse
- #add_newline_at_end_of_text(text) ⇒ Object
- #blank_lines_squish(text) ⇒ Object
- #hankaku_kana(text) ⇒ Object
- #oneline(text) ⇒ Object
- #squish(text) ⇒ Object
Instance Method Details
#add_newline_at_end_of_text(text) ⇒ Object
9 10 11 |
# File 'lib/source2md/text_helper.rb', line 9 def add_newline_at_end_of_text(text) text.strip + "\n" end |
#blank_lines_squish(text) ⇒ Object
5 6 7 |
# File 'lib/source2md/text_helper.rb', line 5 def blank_lines_squish(text) text.gsub(/\n{3,}/, "\n\n") end |
#hankaku_kana(text) ⇒ Object
21 22 23 |
# File 'lib/source2md/text_helper.rb', line 21 def hankaku_kana(text) NKF.nkf("-wxZ4", text) end |
#oneline(text) ⇒ Object
13 14 15 |
# File 'lib/source2md/text_helper.rb', line 13 def oneline(text) text.remove(/\R+/) end |
#squish(text) ⇒ Object
17 18 19 |
# File 'lib/source2md/text_helper.rb', line 17 def squish(text) text.gsub(/[[:space:]]+/, " ").strip end |