mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
Feature: Change markdown engine to markdown it
This commit removes the old evilstreak markdownjs engine. - Adds specs to WhiteLister and changes it to stop using globals (Fixes large memory leak) - Fixes edge cases around bbcode handling - Removes mdtest which is no longer valid (to be replaced with CommonMark) - Updates MiniRacer to correct minor unmanaged memory leak - Fixes plugin specs
This commit is contained in:
@ -80,11 +80,7 @@ module PrettyText
|
||||
ctx_load(ctx, "#{Rails.root}/app/assets/javascripts/discourse-loader.js")
|
||||
ctx_load(ctx, "vendor/assets/javascripts/lodash.js")
|
||||
ctx_load_manifest(ctx, "pretty-text-bundle.js")
|
||||
|
||||
if SiteSetting.enable_experimental_markdown_it
|
||||
ctx_load_manifest(ctx, "markdown-it-bundle.js")
|
||||
end
|
||||
|
||||
ctx_load_manifest(ctx, "markdown-it-bundle.js")
|
||||
root_path = "#{Rails.root}/app/assets/javascripts/"
|
||||
|
||||
apply_es6_file(ctx, root_path, "discourse/lib/utilities")
|
||||
@ -152,13 +148,6 @@ module PrettyText
|
||||
paths[:S3BaseUrl] = Discourse.store.absolute_base_url
|
||||
end
|
||||
|
||||
if SiteSetting.enable_experimental_markdown_it
|
||||
# defer load markdown it
|
||||
unless context.eval("window.markdownit")
|
||||
ctx_load_manifest(context, "markdown-it-bundle.js")
|
||||
end
|
||||
end
|
||||
|
||||
custom_emoji = {}
|
||||
Emoji.custom.map { |e| custom_emoji[e.name] = e.url }
|
||||
|
||||
@ -186,12 +175,14 @@ module PrettyText
|
||||
|
||||
buffer << "__textOptions = __buildOptions(__optInput);\n"
|
||||
|
||||
# Be careful disabling sanitization. We allow for custom emails
|
||||
if opts[:sanitize] == false
|
||||
buffer << ('__textOptions.sanitize = false;')
|
||||
end
|
||||
|
||||
buffer << ("__pt = new __PrettyText(__textOptions);")
|
||||
|
||||
# Be careful disabling sanitization. We allow for custom emails
|
||||
if opts[:sanitize] == false
|
||||
buffer << ('__pt.disableSanitizer();')
|
||||
end
|
||||
|
||||
opts = context.eval(buffer)
|
||||
|
||||
DiscourseEvent.trigger(:markdown_context, context)
|
||||
|
Reference in New Issue
Block a user