FIX: vBulletin pre-processing regexes order

This commit is contained in:
Régis Hanol 2014-09-05 18:44:34 +02:00
parent ca5f361d0a
commit 4907053cc4

View file

@ -353,10 +353,31 @@ class ImportScripts::VBulletin < ImportScripts::Base
.gsub("\\t", "\t") .gsub("\\t", "\t")
# remove attachments # remove attachments
raw = raw.gsub(/\[attach\]\d+\[\/attach\]/i, "") raw = raw.gsub(/\[attach[^\]]*\]\d+\[\/attach\]/i, "")
# [HTML]...[/HTML]
raw = raw.gsub(/\[html\]/i, "\n```html\n")
.gsub(/\[\/html\]/i, "\n```\n")
# [PHP]...[/PHP]
raw = raw.gsub(/\[php\]/i, "\n```php\n")
.gsub(/\[\/php\]/i, "\n```\n")
# [HIGHLIGHT="..."]
raw = raw.gsub(/\[highlight="?(\w+)"?\]/i) { "\n```#{$1.downcase}\n" }
# [CODE]...[/CODE]
# [HIGHLIGHT]...[/HIGHLIGHT]
raw = raw.gsub(/\[\/?code\]/i, "\n```\n")
.gsub(/\[\/?highlight\]/i, "\n```\n")
# [SAMP]...[/SAMP]
raw = raw.gsub(/\[\/?samp\]/i, "`")
# replace all chevrons with HTML entities # replace all chevrons with HTML entities
# NOTE: must be before any of the "quote" processing # NOTE: must be done
# - AFTER all the "code" processing
# - BEFORE the "quote" processing
raw = raw.gsub(/`([^`]+)`/im) { "`" + $1.gsub("<", "\u2603") + "`" } raw = raw.gsub(/`([^`]+)`/im) { "`" + $1.gsub("<", "\u2603") + "`" }
.gsub("<", "&lt;") .gsub("<", "&lt;")
.gsub("\u2603", "<") .gsub("\u2603", "<")
@ -403,25 +424,6 @@ class ImportScripts::VBulletin < ImportScripts::Base
"\n[quote=\"#{old_username}\"]\n#{quote}\n[/quote]\n" "\n[quote=\"#{old_username}\"]\n#{quote}\n[/quote]\n"
end end
# [HTML]...[/HTML]
raw = raw.gsub(/\[html\]/i, "\n```html\n")
.gsub(/\[\/html\]/i, "\n```\n")
# [PHP]...[/PHP]
raw = raw.gsub(/\[php\]/i, "\n```php\n")
.gsub(/\[\/php\]/i, "\n```\n")
# [HIGHLIGHT="..."]
raw = raw.gsub(/\[highlight="?(\w+)"?\]/i) { "\n```#{$1.downcase}\n" }
# [CODE]...[/CODE]
# [HIGHLIGHT]...[/HIGHLIGHT]
raw = raw.gsub(/\[\/?code\]/i, "\n```\n")
.gsub(/\[\/?highlight\]/i, "\n```\n")
# [SAMP]...[/SAMP]
raw = raw.gsub(/\[\/?samp\]/i, "`")
# [YOUTUBE]<id>[/YOUTUBE] # [YOUTUBE]<id>[/YOUTUBE]
raw = raw.gsub(/\[youtube\](.+?)\[\/youtube\]/i) { "\n//youtu.be/#{$1}\n" } raw = raw.gsub(/\[youtube\](.+?)\[\/youtube\]/i) { "\n//youtu.be/#{$1}\n" }