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

房东的猫 提交于 2019-12-11 10:44:45

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/17645397/emmet-wrap-with-abbreviation-token-that-represents-the-wrapped-text-i-e-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!