]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/xml/entities/entities.factor
factor: trim using lists
[factor.git] / basis / xml / entities / entities.factor
index a3812c7723462310450ec4f3ee92f035e90949fa..8a1ef96c9e4dcac5c8814e036fd578da807c80e1 100644 (file)
@@ -1,25 +1,25 @@
 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces make kernel assocs sequences fry values
-io.files io.encodings.binary ;
+USING: assocs kernel make namespaces sequences xml.state ;
 IN: xml.entities
 
-: entities-out
+CONSTANT: entities-out
     H{
         { CHAR: < "&lt;"   }
         { CHAR: > "&gt;"   }
         { CHAR: & "&amp;"  }
-    } ;
+    }
 
-: quoted-entities-out
+CONSTANT: quoted-entities-out
     H{
         { CHAR: & "&amp;"  }
         { CHAR: ' "&apos;" }
-        { CHAR: " "&quot;" }
-    } ;
+        { CHAR: \" "&quot;" }
+        { CHAR: < "&lt;"   }
+    }
 
 : escape-string-by ( str table -- escaped )
-    #! Convert <, >, &, ' and " to HTML entities.
+    ! Convert <, >, &, ' and " to HTML entities.
     [ '[ dup _ at [ % ] [ , ] ?if ] each ] "" make ;
 
 : escape-string ( str -- newstr )
@@ -28,16 +28,14 @@ IN: xml.entities
 : escape-quoted-string ( str -- newstr )
     quoted-entities-out escape-string-by ;
 
-: entities
+CONSTANT: entities
     H{
         { "lt"    CHAR: <  }
         { "gt"    CHAR: >  }
         { "amp"   CHAR: &  }
         { "apos"  CHAR: '  }
-        { "quot"  CHAR: "  }
-    } ;
-
-SYMBOL: extra-entities
+        { "quot"  CHAR: \"  }
+    }
 
 : with-entities ( entities quot -- )
-    [ swap extra-entities set call ] with-scope ; inline
+    [ extra-entities ] dip with-variable ; inline