]> gitweb.factorcode.org Git - factor.git/commitdiff
html.parser.printer: fixed to use repeated write calls instead of surround
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 5 Aug 2013 11:57:55 +0000 (13:57 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 5 Aug 2013 16:56:44 +0000 (09:56 -0700)
extra/html/parser/printer/printer-tests.factor
extra/html/parser/printer/printer.factor

index 1d4d676000125f4108ea483d641349e60c40e817..dad813dca6d0150c168fab3e640980497e6d5585 100644 (file)
@@ -2,13 +2,14 @@ USING:
     html.parser html.parser.printer
     io.streams.string
     namespaces
+    strings
     tools.test ;
 IN: html.parser.printer.tests
 
 [
     "          "
 ] [
-    [ 5 #indentations set 2 tab-width set tabs ] with-scope
+    [ 5 #indentations set 2 tab-width set tabs >string ] with-scope
 ] unit-test
 
 [
index 237a0be312e8bb749d9afa6b978951f3133d760b..cd067d8edc3f50db40d128c3109a98a6f4b9eae8 100644 (file)
@@ -1,7 +1,7 @@
 USING: accessors assocs html.parser html.parser.utils combinators
 continuations hashtables
 hashtables.private io kernel make math
-namespaces prettyprint quotations sequences sequences.repeating splitting
+namespaces prettyprint quotations sequences splitting
 strings unicode.categories ;
 IN: html.parser.printer
 
@@ -73,17 +73,18 @@ SYMBOL: tagstack
         print-tags
     ] with-scope ;
 
-: tabs ( -- str )
-    " " tab-width get #indentations get * repeat ;
+: tabs ( -- vseq )
+    tab-width get #indentations get * CHAR: \s <repetition> ;
 
 M: html-prettyprinter print-opening-tag ( tag -- )
     name>>
-    [ tabs "<" append ">\n" surround write ]
+    [ tabs write "<" write write ">\n" write ]
     ! These tags usually don't have any closing tag associated with them.
     [ { "br" "img" } member? [ #indentations inc ] unless ] bi ;
 
 M: html-prettyprinter print-closing-tag ( tag -- )
-    #indentations dec name>> tabs "</" append ">\n" surround write ;
+    #indentations dec
+    tabs write "</" write name>> write ">\n" write ;
 
 M: html-prettyprinter print-text-tag ( tag -- )
-    text>> [ blank? ] trim [ tabs "\n" surround write ] unless-empty ;
+    text>> [ blank? ] trim [ tabs write write "\n" write ] unless-empty ;