Welcome to mirror list, hosted at ThFree Co, Russian Federation.

truncate_source_filter.rb « filter « banzai « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 44f88b253d998844ce194ab1789f6305959bcd84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

module Banzai
  module Filter
    class TruncateSourceFilter < HTML::Pipeline::TextFilter
      def call
        return text unless context.key?(:limit)

        # 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: '...')
      end
    end
  end
end