Last active
April 24, 2019 15:47
-
-
Save puffy/94fd09b7f1f3cf8fe7bf568ccd70fc58 to your computer and use it in GitHub Desktop.
Add attributes for html links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mark_html_links!(html) | |
link_regexp = %r{(<a.*?href=["']?[^"']*["']?)(.*?)(>.*?<\/a>)} | |
html.gsub!(link_regexp, '\1 data-test="true"\2\3') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment