Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [REBOL]HTML tags in content, not in source

From: joel:neely:fedex at: 29-Oct-2000 20:12

[rebol-bounce--rebol--com] wrote:
> Hi Al and Joe: > I've just got a minute here. If I'm still not clear enough, > I'll have to write a simple test script and send it tomorrow. > > I want to be able to show an actual tag in the web > content that my CGI program writes, to give directions > to a user. > maybe I just have to rely on '&lt and '&gt > I'm sure that will work. >
Ah! Now I understand. Yes, the bottom-level solution is the HTML entities that are "escapes" for < and >. However, you can REBOLize the process, as illustrated in the following: html-escape: func [s [string!] /local r] [ r: copy s replace/all r #"&" #"^@" ; hide ampersands replace/all r #"<" "<" ; escape lt replace/all r #">" ">" ; escape gt replace/all r #"^"" "&quot;" ; escape double-quotes replace/all r #"^@" "&amp;" ; un-hide ampersands insert head r <pre> insert tail r </pre> r ]
>> para: {
{ <p>This is a paragraph { <!-- Hello, world! --> { with an HTML comment { in the middle</p> { } == { <p>This is a paragraph <!-- Hello, world! --> with an HTML comment in the middle</p> }
>> print [
[ <html> newline [ <head> <title> {Sample} </title> </head> newline [ <body> newline [ <h3> {HTML Comments} </h3> newline [ para [ <p> {The HTML code for the preceding { paragraph looks like this:} [ html-escape para [ </p> newline [ </body> newline [ </html> newline [ ] <html> <head> <title> Sample </title> </head> <body> <h3> HTML Comments </h3> <p>This is a paragraph <!-- Hello, world! --> with an HTML comment in the middle</p> <p> The HTML code for the preceding paragraph looks like this: <pre> <p>This is a paragraph <!-- Hello, world! --> with an HTML comment in the middle</p> </pre> </p> </body> </html> ...which, of course, you could also write to a file. Hope this helps! -jn-