Friday, July 30, 2010

[SOLVED] Re: Simple Html2Txt function , doesn't work for `&' symbol ?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/30/2010 04:55 PM, John Beckett wrote:
> Aaron Lewis wrote:
>> Consider following function , i tried to do a simple
>> html conversation, not working for the third one ?
>>
>> function HtmlToText()
>> exec "%s/&lt;/</g"
>> exec "%s/&gt;/>/g"
>> exec "%s/&amp;/\&/g"
>> endfunc
>
> Probably something to do with using a double-quoted string
> (try :echo "a\&b").
>
> You do not need to "execute" a command, so just omit all the
> "exec" and quotes. The tip with the polished product is:

Exactly working after remove all exec statements.

> http://vim.wikia.com/wiki/HTML_entities
>
> John
>

They're much more cool , and thanks !

function HtmlEscape()
silent s/&/\&amp;/eg
silent s/</\&lt;/eg
silent s/>/\&gt;/eg
endfunction

- --
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4R0NL3WI5 on freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxSlDMACgkQvf41sEptMqAYHgCdHK1yyc4Ggzbix6O7T696L4sx
mEkAnAnl7PzNKznM7r4agfd5Tt51PK4c
=aqYm
-----END PGP SIGNATURE-----

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment