1 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: namespaces kernel assocs sequences ;
20 : escape-string-by ( str table -- escaped )
21 #! Convert <, >, &, ' and " to HTML entities.
22 [ [ dupd at [ % ] [ , ] ?if ] curry each ] "" make ;
24 : escape-string ( str -- newstr )
25 entities-out escape-string-by ;
27 : escape-quoted-string ( str -- newstr )
28 quoted-entities-out escape-string-by ;
41 #! http://www.w3.org/TR/REC-html40/sgml/entities.html
293 SYMBOL: extra-entities
294 f extra-entities set-global
296 : with-entities ( entities quot -- )
297 [ swap extra-entities set call ] with-scope ; inline
299 : with-html-entities ( quot -- )
300 html-entities swap with-entities ; inline