Posted to tcl by apn at Sun Apr 13 16:58:12 GMT 2014view raw
- # From tcllib -
- proc ::htmlparse::mapEscapes html {
- # Find HTML escape characters of the form &xxx(;|EOW)
- # Quote special Tcl chars so they pass through [subst] unharmed.
- set new [string map [list \] \\\] \[ \\\[ \$ \\\$ \\ \\\\] $html]
- regsub -all -- {&([[:alnum:]]{2,7})(;|\M)} $new {[DoNamedMap \1 {\2}]} new
- regsub -all -- {&#([[:digit:]]{1,5})(;|\M)} $new {[DoDecMap \1 {\2}]} new
- regsub -all -- {&#x([[:xdigit:]]{1,4})(;|\M)} $new {[DoHexMap \1 {\2}]} new
- return [subst $new]
- }