summaryrefslogtreecommitdiff
path: root/_site_build/_plugins/posts.rb
blob: 41826dd84908d9400cb5a15007a702341c798a21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'sanitize'

module Jekyll
  module PostFilter
    def truncate(html, num_characters = 1000, indicator = ' [...]')
      '<p>' << Sanitize.clean(html).slice(Regexp.new(".{1,#{num_characters}}( |$)")).chomp(' ') << indicator << '</p>'
    end

    def chomp_url(url, str = 'index.html')
      url.chomp(str)
    end
  end
end

Liquid::Template.register_filter(Jekyll::PostFilter)