Fixing syndication to handle more RSS feeds seen in the wild
parent
334d6d86c3
commit
38d5151322
|
@ -53,7 +53,7 @@ TUPLE: entry title url description date ;
|
|||
swap {
|
||||
[ "title" tag-named children>string >>title ]
|
||||
[ { "link" "guid" } any-tag-named children>string >url >>url ]
|
||||
[ "description" tag-named children>string >>description ]
|
||||
[ { "description" "encoded" } any-tag-named children>string >>description ]
|
||||
[
|
||||
{ "date" "pubDate" } any-tag-named
|
||||
children>string try-parsing-timestamp >>date
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
IN: xml.utilities.tests
|
||||
USING: xml xml.utilities tools.test ;
|
||||
|
||||
[ "bar" ] [ "<foo>bar</foo>" string>xml children>string ] unit-test
|
||||
|
||||
[ "" ] [ "<foo></foo>" string>xml children>string ] unit-test
|
||||
|
||||
[ "" ] [ "<foo/>" string>xml children>string ] unit-test
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel namespaces sequences words io assocs
|
||||
quotations strings parser lexer arrays xml.data xml.writer debugger
|
||||
splitting vectors sequences.deep ;
|
||||
splitting vectors sequences.deep combinators ;
|
||||
IN: xml.utilities
|
||||
|
||||
! * System for words specialized on tag names
|
||||
|
@ -48,10 +48,11 @@ M: process-missing error.
|
|||
standard-prolog { } rot { } <xml> ;
|
||||
|
||||
: children>string ( tag -- string )
|
||||
tag-children
|
||||
dup [ string? ] all?
|
||||
[ "XML tag unexpectedly contains non-text children" throw ] unless
|
||||
concat ;
|
||||
tag-children {
|
||||
{ [ dup empty? ] [ drop "" ] }
|
||||
{ [ dup [ string? not ] contains? ] [ "XML tag unexpectedly contains non-text children" throw ] }
|
||||
[ concat ]
|
||||
} cond ;
|
||||
|
||||
: children-tags ( tag -- sequence )
|
||||
tag-children [ tag? ] filter ;
|
||||
|
|
Loading…
Reference in New Issue