Sha256: a849b05aad708f16665bedea05d2a25ef6706605e845def8054c4753c79048e3
Contents?: true
Size: 781 Bytes
Versions: 6
Compression:
Stored size: 781 Bytes
Contents
require 'htmlentities' require 'liquid' module JekyllPagesApi # This is a hack to allow the module functions to be used class Filters include Liquid::StandardFilters def decode_html(str) html_decoder.decode(str) end # Slight tweak of # https://github.com/Shopify/liquid/blob/v2.6.1/lib/liquid/standardfilters.rb#L71-L74 # to replace newlines with spaces. def condense(str) str.to_s.gsub(/\s+/m, ' '.freeze).strip end def text_only(str) # apply each filter in order [ :strip_html, :condense, :decode_html ].reduce(str) do |result, filter| self.send(filter, result) end end private def html_decoder @html_decoder = HTMLEntities.new end end end
Version data entries
6 entries across 6 versions & 1 rubygems