/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

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