1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs kernel quoting sequences splitting ;
6 : trim1 ( seq ch -- newseq )
7 [ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] 2keep drop like ;
9 : single-quote ( str -- newstr ) "'" dup surround ;
11 : double-quote ( str -- newstr ) "\"" dup surround ;
13 : quote ( str -- newstr )
15 [ double-quote ] [ single-quote ] if ;
17 : ?quote ( str -- newstr ) dup quoted? [ quote ] unless ;
19 CONSTANT: html-entities H{
27 : html-unescape ( str -- str' )
28 html-entities [ replace ] assoc-each ;
30 : html-escape ( str -- str' )
31 html-entities [ swap replace ] assoc-each ;