factor/extra/html/parser/utils/utils.factor

21 lines
668 B
Factor
Raw Normal View History

2008-09-25 03:02:47 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
2007-09-20 18:09:08 -04:00
USING: assocs circular combinators continuations hashtables
2008-09-25 03:02:47 -04:00
hashtables.private io kernel math namespaces prettyprint
quotations sequences splitting strings quoting
combinators.short-circuit ;
2007-12-04 15:14:33 -05:00
IN: html.parser.utils
2007-09-20 18:09:08 -04:00
: trim1 ( seq ch -- newseq )
2009-01-04 12:38:25 -05:00
[ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] 2keep drop like ;
2007-09-20 18:09:08 -04:00
2009-01-04 12:38:25 -05:00
: single-quote ( str -- newstr ) "'" dup surround ;
2007-09-20 18:09:08 -04:00
2009-01-04 12:38:25 -05:00
: double-quote ( str -- newstr ) "\"" dup surround ;
2007-09-20 18:09:08 -04:00
: quote ( str -- newstr )
CHAR: ' over member?
[ double-quote ] [ single-quote ] if ;
2009-01-04 12:38:25 -05:00
: ?quote ( str -- newstr ) dup quoted? [ quote ] unless ;