packages feed

markdown 0.1.7.1 → 0.1.8

raw patch · 3 files changed

+31/−14 lines, 3 files

Files

Text/Markdown/Block.hs view
@@ -11,6 +11,7 @@     ) where  import Prelude+import Control.Monad (msum) #if MIN_VERSION_conduit(1, 0, 0) import Data.Conduit #else@@ -275,10 +276,8 @@  listStart :: Text -> Maybe (ListType, Text) listStart t0-    | Just t' <- T.stripPrefix "* " t = Just (Unordered, t')-    | Just t' <- T.stripPrefix "+ " t = Just (Unordered, t')-    | Just t' <- T.stripPrefix "- " t = Just (Unordered, t')-    | Just t' <- stripNumber t, Just t'' <- stripSeparator t' = Just (Ordered, t'')+    | Just t' <- stripUnorderedListSeparator t = Just (Unordered, t')+    | Just t' <- stripNumber t, Just t'' <- stripOrderedListSeparator t' = Just (Ordered, t'')     | otherwise = Nothing   where     t = T.stripStart t0@@ -290,13 +289,19 @@   where     (y, z) = T.span isDigit x -stripSeparator :: Text -> Maybe Text-stripSeparator x =-    case T.uncons x of-        Nothing -> Nothing-        Just ('.', y) -> Just y-        Just (')', y) -> Just y-        _ -> Nothing+stripUnorderedListSeparator :: Text -> Maybe Text+stripUnorderedListSeparator =+  stripPrefixChoice ["* ", "*\t", "+ ", "+\t", "- ", "-\t"]++stripOrderedListSeparator :: Text -> Maybe Text+stripOrderedListSeparator =+  stripPrefixChoice [". ", ".\t", ") ", ")\t"]++-- | Attempt to strip each of the prefixes in @xs@ from the start of @x@. As+-- soon as one matches, return the remainder of @x@. Prefixes are tried in+-- order. If none match, return @Nothing@.+stripPrefixChoice :: [Text] -> Text -> Maybe Text+stripPrefixChoice xs x = msum $ map (flip T.stripPrefix x) xs  getIndented :: Monad m => Int -> Conduit Text m Text getIndented leader =
markdown.cabal view
@@ -1,5 +1,5 @@ Name:                markdown-Version:             0.1.7.1+Version:             0.1.8 Synopsis:            Convert Markdown to HTML, with XSS protection Description:         This library leverages existing high-performance libraries (attoparsec, blaze-html, text, and conduit), and should integrate well with existing codebases. Homepage:            https://github.com/snoyberg/markdown
test/Block.hs view
@@ -29,11 +29,18 @@             "~~~\nfoo\n\nbar\n"             [BlockPara " ~~~\nfoo", BlockPara "bar"]     describe "list" $ do-        it "simple" $ check-            "* foo\n\n*    bar\n\n"+        it "simple unordered" $ check+            "* foo\n\n*    bar\n\n*\t\tqux"             [ BlockList Unordered (Right [BlockPara "foo"])             , BlockList Unordered (Right [BlockPara "bar"])+            , BlockList Unordered (Right [BlockPara "qux"])             ]+        it "simple ordered" $ check+            "1. foo\n\n3.    bar\n\n17.\t\tqux"+            [ BlockList Ordered (Right [BlockPara "foo"])+            , BlockList Ordered (Right [BlockPara "bar"])+            , BlockList Ordered (Right [BlockPara "qux"])+            ]         it "nested" $ check             "* foo\n* \n    1. bar\n    2. baz"             [ BlockList Unordered (Left "foo")@@ -51,6 +58,11 @@             , BlockList Unordered $ Right                 [ BlockPara "baz"                 ]+            ]+        it "without whitespace" $ check+            "*foo\n\n1.bar"+            [ BlockPara "*foo"+            , BlockPara "1.bar"             ]     describe "blockquote" $ do         it "simple" $ check