mirror of
https://github.com/moebooru/moebooru
synced 2025-08-31 14:05:14 +00:00
No more <> spacing evilry in dtext.
This commit is contained in:
@@ -105,17 +105,15 @@ module DText
|
||||
end
|
||||
|
||||
def parseurl(str)
|
||||
str.gsub!(/([<>])/, ' \1 ')
|
||||
# Basic URL pattern
|
||||
url = /(h?ttps?:\/\/\[?(:{0,2}[\w\-]+)((:{1,2}|\.)[\w\-]+)*\]?(:\d+)*(\/[^\s\n]*)*)/
|
||||
url = /(h?ttps?:\/\/\[?(:{0,2}[\w\-]+)((:{1,2}|\.)[\w\-]+)*\]?(:\d+)*(\/[^\s\n<]*)*)/
|
||||
|
||||
# Substitute url tag in this form:
|
||||
str.gsub!(/(^|[\s\(])#{url}/, '\1<a href="\2">\2</a>') # url
|
||||
str.gsub!(/(^|[\s\(>])#{url}/, '\1<a href="\2">\2</a>') # url
|
||||
str.gsub!(/<<\s*#{url}\s*\|\s*(.+?)\s*>>/, '<a href="\1">\7</a>') # <<url|label>>
|
||||
str.gsub!(/(^|\s+)"(.+?)":#{url}/, '\1<a href="\3">\2</a>') # "label":url
|
||||
str.gsub!(/<<\s*#{url}\s*>>/, '<a href="\1">\1</a>') # <<url>>
|
||||
str.gsub!(/<a href="ttp/, '<a href="http') # Fix ttp(s) scheme
|
||||
str.gsub!(/ ([<>]) /, '\1')
|
||||
return str
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user