/extra/html/parser/utils/utils.factor
http://github.com/abeaumont/factor · Factor · 20 lines · 13 code · 5 blank · 2 comment · 5 complexity · 21252257c5cac8b6398e2b50f1a28882 MD5 · raw file
- ! Copyright (C) 2008 Doug Coleman.
- ! See http://factorcode.org/license.txt for BSD license.
- USING: assocs circular combinators continuations hashtables
- hashtables.private io kernel math namespaces prettyprint
- quotations sequences splitting strings quoting
- combinators.short-circuit ;
- IN: html.parser.utils
- : trim1 ( seq ch -- newseq )
- [ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] 2keep drop like ;
- : single-quote ( str -- newstr ) "'" dup surround ;
- : double-quote ( str -- newstr ) "\"" dup surround ;
- : quote ( str -- newstr )
- CHAR: ' over member?
- [ double-quote ] [ single-quote ] if ;
- : ?quote ( str -- newstr ) dup quoted? [ quote ] unless ;