+ 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
+