FIX: the phpbbb import script was not parsing youtube tags (#17787)

This commit is contained in:
Constanza 2022-08-05 15:20:32 -04:00 committed by GitHub
parent 2003c2d4cd
commit 8836c8bcdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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}

View File

@ -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