closes GitHub issue #57
This commit is contained in:
parent
bc826f07fe
commit
9de917fb23
|
@ -1,21 +1,12 @@
|
|||
module MarkdownHelper
|
||||
|
||||
def markdown(content)
|
||||
md = Redcarpet::Markdown.new(FlavoredMarkdown,
|
||||
filter_html: true,
|
||||
escape_html: true,
|
||||
no_images: true,
|
||||
no_styles: true,
|
||||
safe_links_only: true,
|
||||
xhtml: false,
|
||||
hard_wrap: true,
|
||||
no_intra_emphasis: true,
|
||||
tables: true,
|
||||
fenced_code_blocks: true,
|
||||
autolink: true,
|
||||
disable_indented_code_blocks: true,
|
||||
strikethrough: true,
|
||||
superscript: false)
|
||||
md = Redcarpet::Markdown.new(FlavoredMarkdown, MARKDOWN_OPTS)
|
||||
Sanitize.fragment(md.render(content), EVIL_TAGS).html_safe
|
||||
end
|
||||
|
||||
def strip_markdown(content)
|
||||
md = Redcarpet::Markdown.new(Redcarpet::Render::StripDown, MARKDOWN_OPTS)
|
||||
CGI.unescape_html Sanitize.fragment(md.render(content), EVIL_TAGS)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
class Services::Twitter < Service
|
||||
include Rails.application.routes.url_helpers
|
||||
include MarkdownHelper
|
||||
|
||||
def provider
|
||||
"twitter"
|
||||
|
@ -27,8 +28,8 @@ class Services::Twitter < Service
|
|||
|
||||
def prepare_tweet(answer)
|
||||
# TODO: improve this.
|
||||
question_content = answer.question.content
|
||||
answer_content = answer.content
|
||||
question_content = strip_markdown answer.question.content
|
||||
answer_content = strip_markdown answer.content
|
||||
answer_url = show_user_answer_url(
|
||||
id: answer.id,
|
||||
username: answer.user.screen_name,
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
require 'redcarpet/render_strip'
|
||||
|
||||
MARKDOWN_OPTS = {
|
||||
filter_html: true,
|
||||
escape_html: true,
|
||||
no_images: true,
|
||||
no_styles: true,
|
||||
safe_links_only: true,
|
||||
xhtml: false,
|
||||
hard_wrap: true,
|
||||
no_intra_emphasis: true,
|
||||
tables: true,
|
||||
fenced_code_blocks: true,
|
||||
autolink: true,
|
||||
disable_indented_code_blocks: true,
|
||||
strikethrough: true,
|
||||
superscript: false
|
||||
}
|
Loading…
Reference in New Issue