mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FEATURE: Updated IPB import script
* IPB import script replace PHP code tags with proper markdown remove excess newlines in code blocks decode HTML entities in code blocks add replacement for list items proper handling of attachments that are not images fix typo improved quote handling fix code style complaint from travis-ci build
This commit is contained in:
parent
16bd3f2cf2
commit
921e2213b8
|
@ -788,6 +788,10 @@ EOM
|
|||
raw.gsub!(/'/, "'")
|
||||
raw.gsub!(/\[url="(.+?)"\]http.+?\[\/url\]/, "\\1\n")
|
||||
raw.gsub!(/\[media\](.+?)\[\/media\]/, "\n\\1\n\n")
|
||||
raw.gsub!(/\[php\](.+?)\[\/php\]/m) { |m| "\n\n```php\n\n" + @htmlentities.decode($1.gsub(/\n\n/, "\n")) + "\n\n```\n\n" }
|
||||
raw.gsub!(/\[code\](.+?)\[\/code\]/m) { |m| "\n\n```\n\n" + @htmlentities.decode($1.gsub(/\n\n/, "\n")) + "\n\n```\n\n" }
|
||||
raw.gsub!(/\[list\](.+?)\[\/list\]/m) { |m| "\n" + $1.gsub(/\[\*\]/, "\n- ") + "\n\n" }
|
||||
raw.gsub!(/\[quote\]/, "\n[quote]\n")
|
||||
raw.gsub!(/\[\/quote\]/, "\n[/quote]\n")
|
||||
raw.gsub!(/date=\'(.+?)\'/, '')
|
||||
raw.gsub!(/timestamp=\'(.+?)\' /, '')
|
||||
|
@ -829,9 +833,16 @@ EOM
|
|||
puts "Attachment #{attach_id} not found."
|
||||
attach_string = "Attachment #{attach_id} not found."
|
||||
else
|
||||
attach_string = "#{attach_id}\n\n![#{attachments.first['filename']}](#{UPLOADS}/#{attachments.first['loc']})\n"
|
||||
attach_url = "#{UPLOADS}/#{attachments.first['loc'].gsub(' ', '%20')}"
|
||||
if attachments.first['filename'].match(/(png|jpg|jpeg|gif)$/)
|
||||
# images are rendered as a link that contains the image
|
||||
attach_string = "#{attach_id}\n\n[![#{attachments.first['filename']}](#{attach_url})](#{attach_url})\n"
|
||||
else
|
||||
# other attachments are simple download links
|
||||
attach_string = "#{attach_id}\n\n[#{attachments.first['filename']}](#{attach_url})\n"
|
||||
end
|
||||
end
|
||||
raw.gsub!(attach_regex, attach_string)
|
||||
raw.sub!(attach_regex, attach_string)
|
||||
end
|
||||
|
||||
raw
|
||||
|
|
Loading…
Reference in New Issue
Block a user