+ def wikimedia_commons_link(key, value)
+ if key == "wikimedia_commons" && value =~ /^(?:file|category):/i
+ return {
+ :url => "//commons.wikimedia.org/wiki/#{value}?uselang=#{I18n.locale}",
+ :title => value
+ }
+ end
+ nil
+ end
+
+ def email_link(key, value)
+ # Avoid converting conditional tags into emails, since EMAIL_REGEXP is quite permissive
+ return nil unless %w[email contact:email].include? key
+
+ # Does the value look like an email? eg "someone@domain.tld"
+
+ # Uses Ruby built-in regexp to validate email.
+ # This will not catch certain valid emails containing comments, whitespace characters,
+ # and quoted strings.
+ # (see: https://github.com/ruby/ruby/blob/master/lib/uri/mailto.rb)
+
+ # remove any leading and trailing whitespace
+ email = value.strip
+
+ return email if email.match?(URI::MailTo::EMAIL_REGEXP)
+
+ nil
+ end
+