summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/preview_orgmode.rb
blob: de7c22cf9418606061e627c93e0bedd95f6c0698 (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
# frozen_string_literal: true

module PreviewOrgmode
  extend ActiveSupport::Concern

  def preview_orgmode
    context = {
      current_user: (current_user if defined?(current_user)),

      # RelativeLinkFilter
      project:        project,
      commit:         @commit,
      project_wiki:   @project_wiki,
      ref:            @ref,
      requested_path: @path
    }

    html = Gitlab::OtherMarkup.render('preview.org', params[:text], context)
    html = Banzai.post_process(html, context)
    html = Hamlit::RailsHelpers.preserve(html)

    render json: {
      body: html
    }
  end
end