Move constant from initializer to app/lib/constants (#12034)
This commit is contained in:
parent
15601285a5
commit
f98cfb59d2
4 changed files with 21 additions and 17 deletions
|
|
@ -20,7 +20,7 @@ class MarkdownParser
|
|||
def finalize(link_attributes: {})
|
||||
options = { hard_wrap: true, filter_html: false, link_attributes: link_attributes }
|
||||
renderer = Redcarpet::Render::HTMLRouge.new(options)
|
||||
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
|
||||
markdown = Redcarpet::Markdown.new(renderer, Constants::Redcarpet::CONFIG)
|
||||
catch_xss_attempts(@content)
|
||||
escaped_content = escape_liquid_tags_in_codeblock(@content)
|
||||
html = markdown.render(escaped_content)
|
||||
|
|
@ -55,7 +55,7 @@ class MarkdownParser
|
|||
return if @content.blank?
|
||||
|
||||
renderer = Redcarpet::Render::HTMLRouge.new(hard_wrap: true, filter_html: false)
|
||||
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
|
||||
markdown = Redcarpet::Markdown.new(renderer, Constants::Redcarpet::CONFIG)
|
||||
allowed_tags = %w[strong abbr aside em p h1 h2 h3 h4 h5 h6 i u b code pre
|
||||
br ul ol li small sup sub img a span hr blockquote kbd]
|
||||
allowed_attributes = %w[href strong em ref rel src title alt class]
|
||||
|
|
@ -68,7 +68,7 @@ class MarkdownParser
|
|||
return if @content.blank?
|
||||
|
||||
renderer = Redcarpet::Render::HTMLRouge.new(hard_wrap: true, filter_html: false)
|
||||
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
|
||||
markdown = Redcarpet::Markdown.new(renderer, Constants::Redcarpet::CONFIG)
|
||||
allowed_tags = %w[strong i u b em p br code]
|
||||
allowed_attributes = %w[href strong em ref rel src title alt class]
|
||||
ActionController::Base.helpers.sanitize markdown.render(@content),
|
||||
|
|
@ -80,7 +80,7 @@ class MarkdownParser
|
|||
return if @content.blank?
|
||||
|
||||
renderer = Redcarpet::Render::HTMLRouge.new(hard_wrap: true, filter_html: false)
|
||||
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
|
||||
markdown = Redcarpet::Markdown.new(renderer, Constants::Redcarpet::CONFIG)
|
||||
allowed_tags = %w[strong i u b em code]
|
||||
allowed_attributes = %w[href strong em ref rel src title alt class]
|
||||
ActionController::Base.helpers.sanitize markdown.render(@content),
|
||||
|
|
@ -92,7 +92,7 @@ class MarkdownParser
|
|||
return if @content.blank?
|
||||
|
||||
renderer = Redcarpet::Render::HTMLRouge.new(hard_wrap: true, filter_html: false)
|
||||
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
|
||||
markdown = Redcarpet::Markdown.new(renderer, Constants::Redcarpet::CONFIG)
|
||||
allowed_tags = %w[strong abbr aside em p h4 h5 h6 i u b code pre
|
||||
br ul ol li small sup sub a span hr blockquote kbd]
|
||||
allowed_attributes = %w[href strong em ref rel src title alt class]
|
||||
|
|
|
|||
15
app/lib/constants/redcarpet.rb
Normal file
15
app/lib/constants/redcarpet.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
module Constants
|
||||
module Redcarpet
|
||||
CONFIG = {
|
||||
autolink: true,
|
||||
no_intra_emphasis: true,
|
||||
fenced_code_blocks: true,
|
||||
lax_html_blocks: true,
|
||||
lax_spacing: true,
|
||||
strikethrough: true,
|
||||
superscript: false,
|
||||
tables: true,
|
||||
footnotes: true
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
|
@ -54,7 +54,7 @@ class RedditTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def parse_markdown_content(content)
|
||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTMLRouge, REDCARPET_CONFIG)
|
||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTMLRouge, Constants::Redcarpet::CONFIG)
|
||||
text = markdown.render(content)
|
||||
|
||||
sanitize(HTML_Truncator.truncate(text, 60))
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
::REDCARPET_CONFIG = {
|
||||
autolink: true,
|
||||
no_intra_emphasis: true,
|
||||
fenced_code_blocks: true,
|
||||
lax_html_blocks: true,
|
||||
lax_spacing: true,
|
||||
strikethrough: true,
|
||||
superscript: false,
|
||||
tables: true,
|
||||
footnotes: true
|
||||
}.freeze
|
||||
Loading…
Add table
Reference in a new issue