Module: Gitlab::OtherMarkup

Defined in:
lib/gitlab/other_markup.rb

Overview

Parser/renderer for markups without other special support code.

Constant Summary collapse

RENDER_TIMEOUT =
10.seconds

Class Method Summary collapse

Class Method Details

.render(file_name, input, context) ⇒ Object

Public: Converts the provided markup into HTML.

input - the source text in a markup format



12
13
14
15
16
17
18
19
# File 'lib/gitlab/other_markup.rb', line 12

def self.render(file_name, input, context)
  html = render_markup(file_name, input, context).force_encoding(input.encoding)

  context[:pipeline] ||= :markup

  html = Banzai.render(html, context)
  html.html_safe
end

.render_markup(file_name, input, context) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/other_markup.rb', line 21

def self.render_markup(file_name, input, context)
  Gitlab::RenderTimeout.timeout(foreground: RENDER_TIMEOUT) { GitHub::Markup.render(file_name, input) }
rescue Timeout::Error => e
  class_name = name.demodulize
  Gitlab::ErrorTracking.track_exception(e, project_id: context[:project]&.id, class_name: class_name,
                                           file_name: file_name)

  ActionController::Base.helpers.simple_format(input)
end