summaryrefslogtreecommitdiff
path: root/lib/gitlab/other_markup.rb
blob: e67acf28c94b396bcaa2655f0256cf8e98458925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Gitlab
  # Parser/renderer for markups without other special support code.
  module OtherMarkup
    # Public: Converts the provided markup into HTML.
    #
    # input         - the source text in a markup format
    # context       - a Hash with the template context:
    #                 :commit
    #                 :project
    #                 :project_wiki
    #                 :requested_path
    #                 :ref
    #
    def self.render(file_name, input, context)
      html = GitHub::Markup.render(file_name, input).
        force_encoding(input.encoding)

      html = Banzai.post_process(html, context)

      filter = Banzai::Filter::SanitizationFilter.new(html)
      html = filter.call.to_s

      html.html_safe
    end
  end
end