mirror of
https://github.com/discourse/discourse.git
synced 2025-03-04 11:57:24 +08:00
FEATURE: attempt to recover from corrupt markdown engine
This commit is contained in:
parent
c7bc692f40
commit
a79b1807d7
@ -116,6 +116,12 @@ module PrettyText
|
|||||||
@ctx
|
@ctx
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.reset_context
|
||||||
|
@ctx_init.synchronize do
|
||||||
|
@ctx = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.decorate_context(context)
|
def self.decorate_context(context)
|
||||||
context.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
context.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
||||||
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
||||||
@ -151,6 +157,19 @@ module PrettyText
|
|||||||
baked = context.eval('Discourse.Markdown.markdownConverter(opts).makeHtml(raw)')
|
baked = context.eval('Discourse.Markdown.markdownConverter(opts).makeHtml(raw)')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if baked.blank? && !(opts || {})[:skip_blank_test]
|
||||||
|
# we may have a js engine issue
|
||||||
|
test = markdown("a", skip_blank_test: true)
|
||||||
|
if test.blank?
|
||||||
|
Rails.logger.warn("Markdown engine appears to have crashed, resetting context")
|
||||||
|
reset_context
|
||||||
|
opts ||= {}
|
||||||
|
opts = opts.dup
|
||||||
|
opts[:skip_blank_test] = true
|
||||||
|
baked = markdown(text, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
baked
|
baked
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user