1 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: namespaces make kernel assocs sequences fry values
4 io.files io.encodings.binary xml.state ;
22 : escape-string-by ( str table -- escaped )
23 #! Convert <, >, &, ' and " to HTML entities.
24 [ '[ dup _ at [ % ] [ , ] ?if ] each ] "" make ;
26 : escape-string ( str -- newstr )
27 entities-out escape-string-by ;
29 : escape-quoted-string ( str -- newstr )
30 quoted-entities-out escape-string-by ;
41 : with-entities ( entities quot -- )
42 [ swap extra-entities set call ] with-scope ; inline