debian-mirror-gitlab/lib/gitlab/other_markup.rb

32 lines
1,013 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2016-04-02 18:10:28 +05:30
module Gitlab
# Parser/renderer for markups without other special support code.
module OtherMarkup
2023-03-04 22:38:38 +05:30
RENDER_TIMEOUT = 10.seconds
2016-04-02 18:10:28 +05:30
# Public: Converts the provided markup into HTML.
#
# input - the source text in a markup format
#
def self.render(file_name, input, context)
2023-03-04 22:38:38 +05:30
html = render_markup(file_name, input, context).force_encoding(input.encoding)
2019-10-31 01:37:42 +05:30
context[:pipeline] ||= :markup
2016-04-02 18:10:28 +05:30
2017-08-17 22:00:37 +05:30
html = Banzai.render(html, context)
2016-04-02 18:10:28 +05:30
html.html_safe
end
2023-03-04 22:38:38 +05:30
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
2016-04-02 18:10:28 +05:30
end
end