diff --git a/script/import_scripts/phpbb3/importer.rb b/script/import_scripts/phpbb3/importer.rb index 9f88a73b2b4..83d748fa6ed 100644 --- a/script/import_scripts/phpbb3/importer.rb +++ b/script/import_scripts/phpbb3/importer.rb @@ -172,8 +172,10 @@ module ImportScripts::PhpBB3 # no need for this since the importer sets last_seen_at for each user during the import end + # Do not use the bbcode_to_md in base.rb. If enabled, it will be + # used in text_processor.rb instead. def use_bbcode_to_md? - @settings.use_bbcode_to_md + false end def batches diff --git a/script/import_scripts/phpbb3/support/text_processor.rb b/script/import_scripts/phpbb3/support/text_processor.rb index c0e99e4dd2a..edd104f6d33 100644 --- a/script/import_scripts/phpbb3/support/text_processor.rb +++ b/script/import_scripts/phpbb3/support/text_processor.rb @@ -9,6 +9,7 @@ module ImportScripts::PhpBB3 @database = database @smiley_processor = smiley_processor + @settings = settings @new_site_prefix = settings.new_site_prefix create_internal_link_regexps(settings.original_site_prefix) end @@ -18,6 +19,9 @@ module ImportScripts::PhpBB3 text = CGI.unescapeHTML(text) clean_bbcodes(text) + if @settings.use_bbcode_to_md + text = bbcode_to_md(text) + end process_smilies(text) process_links(text) process_lists(text) @@ -46,6 +50,15 @@ module ImportScripts::PhpBB3 text.gsub!(/:(?:\w{8})\]/, ']') end + def bbcode_to_md(text) + begin + text.bbcode_to_md(false) + rescue e + puts "Problem converting \n#{text}\n using ruby-bbcode-to-md" + text + end + end + def process_smilies(text) @smiley_processor.replace_smilies(text) end