From 90c14106fad14dbae7bb4e88cbcf836ec9afe62f Mon Sep 17 00:00:00 2001 From: Quangbuu Le Date: Mon, 4 Sep 2017 16:04:54 +0700 Subject: [PATCH] Enhance BulkImport pre_cook (#5015) * Enhance BulkImport pre_cook * BulkImport: Trim
at begining and ending [quote][quote/] --- script/bulk_import/base.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index 6ef8e3b0117..66f61df4e05 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -18,7 +18,8 @@ class BulkImport::Base @raw_connection = PG.connect(dbname: db[:database], host: db[:host_names]&.first, port: db[:port]) @markdown = Redcarpet::Markdown.new( - Redcarpet::Render::HTML, + Redcarpet::Render::HTML.new(hard_wrap: true), + no_intra_emphasis: true, fenced_code_blocks: true, autolink: true ) @@ -579,8 +580,11 @@ class BulkImport::Base cooked = @markdown.render(cooked).scrub.strip cooked.gsub!(/\[QUOTE="?([^,"]+)(?:, post:(\d+), topic:(\d+))?"?\](.+?)\[\/QUOTE\]/im) do - username, post_id, topic_id = $1, $2, $3 - quote = @markdown.render($4.presence || "").scrub.strip + username, post_id, topic_id, quote = $1, $2, $3, $4 + + quote = quote.scrub.strip + quote.gsub!(/^(
\n?)+/, "") + quote.gsub!(/(
\n?)+$/, "") if post_id.present? && topic_id.present? <<-HTML