debian-mirror-gitlab/lib/banzai/filter/truncate_source_filter.rb

16 lines
421 B
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
module Banzai
module Filter
class TruncateSourceFilter < HTML::Pipeline::TextFilter
def call
return text unless context.key?(:limit)
2021-03-11 19:13:27 +05:30
# Use three dots instead of the ellipsis Unicode character because
# some clients show the raw Unicode value in the merge commit.
text.truncate_bytes(context[:limit], omission: '...')
2021-03-08 18:12:59 +05:30
end
end
end
end