[CentOS] escape .c files to html code with bash how?

2010-10-18 Thread Jozsef Vadkan
i need to encode .c files to html, like on this website:

http://centricle.com/tools/html-entities/

i tried to write a bash script for it:

http://pastebin.com/raw.php?i=mZKAw4c5

but it's not working very well :D

does anyone has a script, that does this?

thank you :\
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] escape .c files to html code with bash how?

2010-10-18 Thread m . roth
Jozsef Vadkan wrote:
 i need to encode .c files to html, like on this website:

 http://centricle.com/tools/html-entities/

 i tried to write a bash script for it:

 http://pastebin.com/raw.php?i=mZKAw4c5

 but it's not working very well :D

 does anyone has a script, that does this?

I don't understand what you want to do. I mean, won't
pre
code
/pre

do what you want? That *is* what I belive it was intended for

mark

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] escape .c files to html code with bash how?

2010-10-18 Thread Bowie Bailey
 On 10/18/2010 12:34 PM, Jozsef Vadkan wrote:
 i need to encode .c files to html, like on this website:

 http://centricle.com/tools/html-entities/

 i tried to write a bash script for it:

 http://pastebin.com/raw.php?i=mZKAw4c5

 but it's not working very well :D

 does anyone has a script, that does this?

That script is never going to work right as written.  Consider this:

Text to encode:  # 123

First, it will replace the space, resulting in:  ##32;123

Next, it will replace the two #s, resulting in: #35;#35;32;123

Next, it will replace the three s, resulting in:
#38;#35;#38;#38;#35;32;123

I'm sure you can see where this is going...

If you want to replace almost every character in a file, you either have
to do it character by character to avoid this problem, or make more
complex regexes to avoid matching stuff that has already been replaced.

What is the eventual use of this program?  Do you really need to convert
every character to an entity, or could you leave most of the normal
characters alone and only convert the ones that cause problems?

-- 
Bowie




___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos