Module: DiffTools

Defined in:
app/lib/diff_tools.rb

Defined Under Namespace

Classes: SimpleDiff

Class Method Summary collapse

Class Method Details

.value_to_html(value) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'app/lib/diff_tools.rb', line 38

def self.value_to_html(value)
  too_many_words_re = /
    ((?:\S+\s+){3}) # group 1: Three words, including trailing space
    (.+)            # group 2: Drop this
    ((?:\s+\S+){3}) # group 3: Three words, including leading space
  /x
  ellipsis = value.gsub(too_many_words_re, '\1...\3')
  CGI.escapeHTML(ellipsis)
end