diff --git a/extra/xml/test/templating.factor b/extra/xml/test/templating.factor index 0ee4ae51b0..2dd69ca99b 100644 --- a/extra/xml/test/templating.factor +++ b/extra/xml/test/templating.factor @@ -1,4 +1,3 @@ -IN: templating USING: kernel xml sequences assocs tools.test io arrays namespaces xml.data xml.utilities xml.writer generic sequences.deep ; @@ -9,10 +8,10 @@ SYMBOL: ref-table GENERIC: (r-ref) ( xml -- ) M: tag (r-ref) - sub-tag over at [ + sub-tag over at* [ ref-table get at swap set-tag-children - ] [ drop ] if* ; + ] [ 2drop ] if ; M: object (r-ref) drop ; : template ( xml -- ) @@ -40,4 +39,4 @@ M: object (r-ref) drop ; sample-doc string>xml dup template xml>string ] with-scope ; -[ "\nfoo
blah

" ] [ test-refs ] unit-test +[ "foo

blah

" ] [ test-refs ] unit-test diff --git a/extra/xml/test/test.factor b/extra/xml/test/test.factor index 80a508787e..ec59d3564e 100644 --- a/extra/xml/test/test.factor +++ b/extra/xml/test/test.factor @@ -26,7 +26,7 @@ SYMBOL: xml-file ] unit-test [ V{ "fa&g" } ] [ xml-file get "x" get-id tag-children ] unit-test [ "that" ] [ xml-file get "this" swap at ] unit-test -[ "\n" ] +[ "" ] [ "" string>xml xml>string ] unit-test [ "abcd" ] [ "

abcd
" string>xml @@ -44,7 +44,7 @@ SYMBOL: xml-file at swap "z" >r tuck r> swap set-at T{ name f "blah" "z" f } swap at ] unit-test [ "foo" ] [ "" string>xml children>string ] unit-test -[ "\nbar baz" ] +[ "bar baz" ] [ "bar" string>xml [ " baz" append ] map xml>string ] unit-test [ "\n\n bar\n" ] [ " bar " string>xml pprint-xml>string ] unit-test diff --git a/extra/xml/writer/writer.factor b/extra/xml/writer/writer.factor index f943f24ccd..95f38f3da9 100644 --- a/extra/xml/writer/writer.factor +++ b/extra/xml/writer/writer.factor @@ -14,7 +14,9 @@ SYMBOL: indenter sensitive-tags get swap [ names-match? ] curry contains? ; : indent-string ( -- string ) - indentation get indenter get concat ; + xml-pprint? get + [ indentation get indenter get concat ] + [ "" ] if ; : ?indent ( -- ) xml-pprint? get [ nl indent-string write ] when ; @@ -53,7 +55,7 @@ SYMBOL: indenter GENERIC: write-item ( object -- ) M: string write-item - escape-string xml-pprint? over empty? not and + escape-string dup empty? not xml-pprint? get and [ nl 80 indent-string indented-break ] when write ; : write-tag ( tag -- )