Reputation: 3900
I'm attempting to convert a list of URLs into HTML links as lazily as possible:
www.annaandsally.com.au
www.babylush.com.au
www.babysgotstyle.com.au
... etc
Using wrap in abbreviation, I'd like to do something like: a[href="http://${1}/"]*
The expanded abbreviation would result in:
<a href="http://www.annaandsally.com.au/">www.annaandsally.com.au</a>
<a href="http://www.babylush.com.au/">www.babylush.com.au</a>
<a href="http://www.babysgotstyle.com.au/">www.babysgotstyle.com.au</a>
... etc
The missing piece of the puzzle is an abbreviation token that represents the text being wrapped.
Any idea if this can be done?
Upvotes: 2
Views: 476
Reputation: 3900
Sergey from Emmet was kind enough to point me in the right direction. The $#
token contains the original content:
a[href="http://$#/"]*>{$#}
By specifying $#
as the href
attribute, the original content is no longer 'wrapped' and must be be reinserted via {$#}
.
http://docs.emmet.io/actions/wrap-with-abbreviation/#controlling-output-position
Upvotes: 1
Reputation: 58322
If they are already on their own lines (which in the question, they look like they are), a simple Find and Replace with RegEx turned on will work. The Params are as follows:
Find What:
(.+)
Replace With:
<a href=\"http://$1\">$1</a>
Before
After
Upvotes: 1