Matt Stone
Matt Stone

Reputation: 3900

Emmet - Wrap with Abbreviation - Token that represents the wrapped text i.e. {original text}

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

Answers (2)

Matt Stone
Matt Stone

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

Chris
Chris

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

See Here

After

enter image description here

Upvotes: 1

Related Questions