mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 03:45:43 +08:00
FEATURE: support markdown rendering for embedded posts
This commit is contained in:
parent
5316b6c6bc
commit
12706c4b29
@ -48,11 +48,17 @@ class TopicEmbed < ActiveRecord::Base
|
|||||||
Topic.transaction do
|
Topic.transaction do
|
||||||
eh = EmbeddableHost.record_for_url(url)
|
eh = EmbeddableHost.record_for_url(url)
|
||||||
|
|
||||||
|
cook_method = if SiteSetting.embed_support_markdown
|
||||||
|
Post.cook_methods[:regular]
|
||||||
|
else
|
||||||
|
Post.cook_methods[:raw_html]
|
||||||
|
end
|
||||||
|
|
||||||
creator = PostCreator.new(user,
|
creator = PostCreator.new(user,
|
||||||
title: title,
|
title: title,
|
||||||
raw: absolutize_urls(url, contents),
|
raw: absolutize_urls(url, contents),
|
||||||
skip_validations: true,
|
skip_validations: true,
|
||||||
cook_method: Post.cook_methods[:raw_html],
|
cook_method: cook_method,
|
||||||
category: eh.try(:category_id))
|
category: eh.try(:category_id))
|
||||||
post = creator.create
|
post = creator.create
|
||||||
if post.present?
|
if post.present?
|
||||||
|
@ -1558,6 +1558,7 @@ en:
|
|||||||
highlighted_languages: "Included syntax highlighting rules. (Warning: including too many languages may impact performance) see: https://highlightjs.org/static/demo/ for a demo"
|
highlighted_languages: "Included syntax highlighting rules. (Warning: including too many languages may impact performance) see: https://highlightjs.org/static/demo/ for a demo"
|
||||||
|
|
||||||
embed_truncate: "Truncate the embedded posts."
|
embed_truncate: "Truncate the embedded posts."
|
||||||
|
embed_support_markdown: "Support Markdown formatting for embedded posts."
|
||||||
allowed_href_schemes: "Schemes allowed in links in addition to http and https."
|
allowed_href_schemes: "Schemes allowed in links in addition to http and https."
|
||||||
embed_post_limit: "Maximum number of posts to embed."
|
embed_post_limit: "Maximum number of posts to embed."
|
||||||
embed_username_required: "The username for topic creation is required."
|
embed_username_required: "The username for topic creation is required."
|
||||||
|
@ -656,6 +656,8 @@ posting:
|
|||||||
- code-fences
|
- code-fences
|
||||||
embed_truncate:
|
embed_truncate:
|
||||||
default: true
|
default: true
|
||||||
|
embed_support_markdown:
|
||||||
|
default: false
|
||||||
allowed_href_schemes:
|
allowed_href_schemes:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
@ -58,6 +58,19 @@ describe TopicEmbed do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "post creation supports markdown rendering" do
|
||||||
|
before do
|
||||||
|
SiteSetting.embed_support_markdown = true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "works as expected" do
|
||||||
|
post = TopicEmbed.import(user, url, title, "some random content")
|
||||||
|
expect(post).to be_present
|
||||||
|
|
||||||
|
# It uses regular rendering
|
||||||
|
expect(post.cook_method).to eq(Post.cook_methods[:regular])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '.topic_id_for_embed' do
|
context '.topic_id_for_embed' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user