 
       # prefer to end the teaser at the end of a sentence (a period).
       # failing that prefer to end the teaser at the end of a word (a space).
-      candidate = tryToShorten(longText, '.') or tryToShorten longText, ' ', '...'
+      candidate = tryToShorten(longText, '. ', suffix) or tryToShorten longText, ' ', suffix
 
       if candidate?.length > minLength
-        candidate
+        Encoder.htmlEncode candidate
       else
-        longText
+        Encoder.htmlEncode longText
 
   getMonthOptions : ()->
     ((if i > 9 then { title : "#{i}", value : i} else { title : "0#{i}", value : i}) for i in [1..12])

  stripTags:(value)->
    value.replace /<(?:.|\n)*?>/gm, ''

  applyTextExpansions: (text)->
    return null unless text
    # @expandWwwDotDomains @expandUrls @expandUsernames @expandTags text
    @expandWwwDotDomains @expandUrls @expandUsernames text

  expandWwwDotDomains: (text) ->

    return null unless text
    text.replace /[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, (url) ->
      "<a href='#{url}' target='_blank'>#{url}</a>"

  putShowMore: (text)->
    shortenedText = __utils.shortenText text,
      minLength : 500
      maxLength : 600
      suffix    : ''

    text = if text.length > 500
      morePart = "<span class='collapsedtext hide'><a href='#' class='more-link'>show more...</a>#{text.substr 500}<a href='#' class='less-link'>...show less</a></span>"
      shortenedText + morePart
    else
      shortenedText

  shortenText:do ->
    tryToShorten = (longText, optimalBreak, suffix)->
