[REBOL] Re: HTML tags in content, not in source
From: al::bri::xtra::co::nz at: 30-Oct-2000 17:23
Joel Neely wrote:
> 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:
You also need to account for Named Entities as well:
Named_Entities: [
"quot" "amp" "lt" "gt" "nbsp" "iexcl" "cent" "pound" "curren"
"yen" "brvbar" "sect" "uml" "copy" "ordf" "laquo" "not" "shy"
"reg" "macr" "deg" "plusmn" "sup2" "sup3" "acute" "micro"
"para" "middot" "cedil" "sup1" "ordm" "raquo" "frac14"
"frac12" "frac34" "iquest" "times" "Oslash"
]
Replace_Named_Entities: func [Script [string!]] [
Map Named_Entities func [Entity] [
replace/all Script join "&" Entity join "&"
[Amp_Entity_Replacement Entity]
]
Script
]
; A temporary replacement for "amp;" to avoid infinite recursion.
; Don't simplify! Why? The constant will be replaced when this program
is converted to HTML!
Amp_Entity_Replacement: join "a" "R2HTMLmR2HTMLpR2HTML;" ; "amp;"
with "R2HTML" between each letter.
Replace_Entities: func [Script [string!]] [
replace/all Script "&#" join "&" [Amp_Entity_Replacement "#"]
Script: Replace_Named_Entities Script
replace/all Script "<" "<"
replace/all Script ">" ">"
replace/all Script Amp_Entity_Replacement "amp;"
Script
]
Andrew Martin
Who did this, way, way back...
ICQ: 26227169
http://members.nbci.com/AndrewMartin/