+ def email_link(_key, value)
+ # 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
+
+ if email.match?(URI::MailTo::EMAIL_REGEXP)
+ # add 'mailto:'' prefix
+ return { :email => email, :url => "mailto:#{email}" }
+ end
+
+ nil
+ end
+