Enhance BulkImport pre_cook (#5015)
* Enhance BulkImport pre_cook * BulkImport: Trim <br> at begining and ending [quote][quote/]
This commit is contained in:
parent
5c1143cd55
commit
90c14106fa
|
@ -18,7 +18,8 @@ class BulkImport::Base
|
||||||
@raw_connection = PG.connect(dbname: db[:database], host: db[:host_names]&.first, port: db[:port])
|
@raw_connection = PG.connect(dbname: db[:database], host: db[:host_names]&.first, port: db[:port])
|
||||||
|
|
||||||
@markdown = Redcarpet::Markdown.new(
|
@markdown = Redcarpet::Markdown.new(
|
||||||
Redcarpet::Render::HTML,
|
Redcarpet::Render::HTML.new(hard_wrap: true),
|
||||||
|
no_intra_emphasis: true,
|
||||||
fenced_code_blocks: true,
|
fenced_code_blocks: true,
|
||||||
autolink: true
|
autolink: true
|
||||||
)
|
)
|
||||||
|
@ -579,8 +580,11 @@ class BulkImport::Base
|
||||||
cooked = @markdown.render(cooked).scrub.strip
|
cooked = @markdown.render(cooked).scrub.strip
|
||||||
|
|
||||||
cooked.gsub!(/\[QUOTE="?([^,"]+)(?:, post:(\d+), topic:(\d+))?"?\](.+?)\[\/QUOTE\]/im) do
|
cooked.gsub!(/\[QUOTE="?([^,"]+)(?:, post:(\d+), topic:(\d+))?"?\](.+?)\[\/QUOTE\]/im) do
|
||||||
username, post_id, topic_id = $1, $2, $3
|
username, post_id, topic_id, quote = $1, $2, $3, $4
|
||||||
quote = @markdown.render($4.presence || "").scrub.strip
|
|
||||||
|
quote = quote.scrub.strip
|
||||||
|
quote.gsub!(/^(<br>\n?)+/, "")
|
||||||
|
quote.gsub!(/(<br>\n?)+$/, "")
|
||||||
|
|
||||||
if post_id.present? && topic_id.present?
|
if post_id.present? && topic_id.present?
|
||||||
<<-HTML
|
<<-HTML
|
||||||
|
|
Loading…
Reference in New Issue