]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/html/parser/parser.factor
factor: trim using lists
[factor.git] / extra / html / parser / parser.factor
index 9fcbffd0db31daa220a9e18a125bb3c324cb70be..3b6db6aab3822d0a0f96f307a6e52b73f256a672 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hashtables sequence-parser
-html.parser.utils kernel namespaces sequences math
-unicode.case unicode.categories combinators.short-circuit
-quoting fry ;
+USING: accessors combinators.short-circuit html.parser.utils
+kernel make math namespaces quoting sequences sequences.parser
+unicode ;
 IN: html.parser
 
 TUPLE: tag name attributes text closing? ;
@@ -44,7 +43,7 @@ SYMBOL: tagstack
     CHAR: ' (read-quote) ;
 
 : read-double-quote ( sequence-parser -- string )
-    CHAR: " (read-quote) ;
+    CHAR: \" (read-quote) ;
 
 : read-quote ( sequence-parser -- string )
     dup get+increment CHAR: ' =
@@ -75,8 +74,10 @@ SYMBOL: tagstack
     [ advance advance read-comment ] [ read-dtd ] if ;
 
 : read-tag ( sequence-parser -- string )
-    [ [ current "><" member? ] take-until ]
-    [ dup current CHAR: < = [ advance ] unless drop ] bi ;
+    [
+        [ current "><" member? ] take-until
+        [ CHAR: / = ] trim-tail
+    ] [ dup current CHAR: < = [ advance ] unless drop ] bi ;
 
 : read-until-< ( sequence-parser -- string )
     [ current CHAR: < = ] take-until ;
@@ -94,11 +95,11 @@ SYMBOL: tagstack
     dup sequence-parse-end? [
         drop
     ] [
-        [ parse-key/value swap set ] [ (parse-attributes) ] bi
+        [ parse-key/value swap ,, ] [ (parse-attributes) ] bi
     ] if ;
 
 : parse-attributes ( sequence-parser -- hashtable )
-    [ (parse-attributes) ] H{ } make-assoc ;
+    [ (parse-attributes) ] H{ } make ;
 
 : (parse-tag) ( string -- string' hashtable )
     [