mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:13:16 +08:00
FIX: the phpbbb import script was not parsing youtube tags (#17787)
This commit is contained in:
parent
2003c2d4cd
commit
8836c8bcdf
|
@ -185,6 +185,13 @@ module ImportScripts::PhpBB3::BBCode
|
|||
end
|
||||
end
|
||||
|
||||
def visit_YOUTUBE(xml_node, md_node)
|
||||
youtube_id = xml_node.attr("content")
|
||||
md_node.text = "https://www.youtube.com/watch?v=" + youtube_id
|
||||
md_node.prefix_linebreaks = md_node.postfix_linebreaks = 1
|
||||
md_node.skip_children
|
||||
end
|
||||
|
||||
def visit_QUOTE(xml_node, md_node)
|
||||
if post = quoted_post(xml_node)
|
||||
md_node.prefix = %Q{[quote="#{post[:username]}, post:#{post[:post_number]}, topic:#{post[:topic_id]}"]\n}
|
||||
|
|
|
@ -59,7 +59,7 @@ module ImportScripts::PhpBB3
|
|||
process_code(text)
|
||||
fix_markdown(text)
|
||||
process_attachments(text, attachments) if attachments.present?
|
||||
|
||||
process_videos(text)
|
||||
text
|
||||
end
|
||||
end
|
||||
|
@ -197,5 +197,11 @@ module ImportScripts::PhpBB3
|
|||
text.gsub!(/^!\[[^\]]*\]\([^\]]*\)$/i) { |img| "\n#{img.strip}\n" } # space out images single on line
|
||||
text
|
||||
end
|
||||
|
||||
def process_videos(text)
|
||||
# [YOUTUBE]<id>[/YOUTUBE]
|
||||
text.gsub(/\[youtube\](.+?)\[\/youtube\]/i) { "\nhttps://www.youtube.com/watch?v=#{$1}\n" }
|
||||
text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user