tagsoup 0.14 → 0.14.1
raw patch · 5 files changed
+23/−11 lines, 5 files
Files
- CHANGES.txt +2/−0
- LICENSE +1/−1
- README.md +3/−2
- Text/HTML/TagSoup/Type.hs +9/−2
- tagsoup.cabal +8/−6
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for TagSoup +0.14.1+ #63, add maybeAttrib 0.14 #14, eliminate Text.HTML.Download 0.13.10
LICENSE view
@@ -1,4 +1,4 @@-Copyright Neil Mitchell 2006-2016.+Copyright Neil Mitchell 2006-2017. All rights reserved. Redistribution and use in source and binary forms, with or without
README.md view
@@ -256,6 +256,7 @@ * [TagSoup for Java](http://tagsoup.info/) - an independently written malformed HTML parser for Java. Including [links to other](http://tagsoup.info/#other) HTML parsers. * [HXT: Haskell XML Toolbox](http://www.fh-wedel.de/~si/HXmlToolbox/) - a more comprehensive XML parser, giving the option of using TagSoup as a lexer. * [Other Related Work](http://www.fh-wedel.de/~si/HXmlToolbox/#rel) - as described on the HXT pages.-* [Using TagSoup with Parsec](http://therning.org/magnus/archives/367) - a nice combination of Haskell libraries.-* [tagsoup-parsec](http://hackage.haskell.org/packages/tagsoup-parsec) - a library for easily using TagSoup as a token type in Parsec.+* [Using TagSoup with Parsec](http://therning.org/magnus/posts/2008-08-08-367-tagsoup-meet-parsec.html) - a nice combination of Haskell libraries.+* [tagsoup-parsec](http://hackage.haskell.org/package/tagsoup-parsec) - a library for easily using TagSoup as a token type in Parsec.+* [tagsoup-megaparsec](http://hackage.haskell.org/package/tagsoup-megaparsec) - a library for easily using TagSoup as a token type in Megaparsec. * [WraXML](http://hackage.haskell.org/packages/archive/wraxml/latest/doc/html/Text-XML-WraXML-Tree-TagSoup.html) - construct a lazy tree from TagSoup lexemes.
Text/HTML/TagSoup/Type.hs view
@@ -115,10 +115,17 @@ -- | Extract an attribute, crashes if not a 'TagOpen'. -- Returns @\"\"@ if no attribute present.+--+-- Warning: does not distinquish between missing attribute+-- and present attribute with value @\"\"@. fromAttrib :: (Show str, Eq str, StringLike str) => str -> Tag str -> str-fromAttrib att (TagOpen _ atts) = fromMaybe empty $ lookup att atts-fromAttrib _ x = error ("(" ++ show x ++ ") is not a TagOpen")+fromAttrib att tag = fromMaybe empty $ maybeAttrib att tag +-- | Extract an attribute, crashes if not a 'TagOpen'.+-- Returns @Nothing@ if no attribute present.+maybeAttrib :: (Show str, Eq str) => str -> Tag str -> Maybe str+maybeAttrib att (TagOpen _ atts) = lookup att atts+maybeAttrib _ x = error ("(" ++ show x ++ ") is not a TagOpen") -- | Returns True if the 'Tag' is 'TagOpen' and matches the given name isTagOpenName :: Eq str => str -> Tag str -> Bool
tagsoup.cabal view
@@ -1,7 +1,7 @@-cabal-version: >= 1.6+cabal-version: >= 1.18 name: tagsoup-version: 0.14-copyright: Neil Mitchell 2006-2016+version: 0.14.1+copyright: Neil Mitchell 2006-2017 author: Neil Mitchell <ndmitchell@gmail.com> maintainer: Neil Mitchell <ndmitchell@gmail.com> homepage: https://github.com/ndmitchell/tagsoup#readme@@ -11,7 +11,7 @@ license-file: LICENSE build-type: Simple synopsis: Parsing and extracting information from (possibly malformed) HTML/XML documents-tested-with: GHC==8.0.1, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2+tested-with: GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2 description: TagSoup is a library for parsing HTML/XML. It supports the HTML 5 specification, and can be used to parse either well-formed XML, or unstructured and malformed HTML@@ -29,9 +29,11 @@ flag testprog default: False+ manual: True description: Build the test program library+ default-language: Haskell2010 build-depends: base == 4.*, containers, bytestring, text exposed-modules:@@ -51,16 +53,16 @@ Text.HTML.TagSoup.Type executable test-tagsoup+ default-language: Haskell2010 if flag(testprog) buildable: True build-depends:+ base == 4.*, containers, bytestring, text, QuickCheck >= 2.4, deepseq >= 1.1, time, directory, process else buildable: False-- extensions: CPP main-is: Main.hs other-modules: