PageRenderTime 52ms CodeModel.GetById 48ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

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