packages feed

commonmark 0.2.5.1 → 0.2.6

raw patch · 6 files changed

+135/−18 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Commonmark.Entity: pEntity :: Monad m => ParsecT [Tok] s m Tok

Files

changelog.md view
@@ -1,5 +1,18 @@ # Changelog for commonmark +## 0.2.6++  * Make list tightness match the reference implementation closer (#150,+    Michael Howell). This solves the problem where blank lines in the middle+    of a list are attributed to the list itself instead of the item, making its+    parent list become spuriously loose.++  * Fix bug with entities inside link destinations (#149).+    The bug affects cases like this: `[link](\!)`; the backslash+    escape was being ignored here.++  * Commonmark.Entity: export `pEntity` [API change].+ ## 0.2.5.1    * Replace `source` with `search` in list of block tags.
commonmark.cabal view
@@ -1,6 +1,6 @@ cabal-version:  2.2 name:           commonmark-version:        0.2.5.1+version:        0.2.6 synopsis:       Pure Haskell commonmark parser. description:    This library provides the core data types and functions
src/Commonmark/Blocks.hs view
@@ -856,10 +856,10 @@              let lidata = fromDyn (blockData ndata)                              (ListItemData (BulletList '*') 0 False False)              -- a marker followed by two blanks is just an empty item:-             guard $ null (blockBlanks ndata) ||-                     not (null children)              pos <- getPosition-             gobbleSpaces (listItemIndent lidata) <|> 0 <$ lookAhead blankLine+             case blockBlanks ndata of+                  _:_ | null children -> lookAhead blankLine+                  _ -> () <$ gobbleSpaces (listItemIndent lidata) <|> lookAhead blankLine              return (pos, node)      , blockConstructor    = fmap mconcat . renderChildren      , blockFinalize       = \(Node cdata children) parent -> do
src/Commonmark/Entity.hs view
@@ -6,11 +6,11 @@   ( lookupEntity   , charEntity   , numEntity+  , pEntity   , unEntity   ) where -import Data.Functor.Identity (Identity) import qualified Data.Map.Strict as Map import Commonmark.TokParsers import Commonmark.Tokens@@ -2335,14 +2335,15 @@  unEntity :: [Tok] -> Text unEntity ts = untokenize $-  case parse (many (pEntity' <|> anyTok)) "" ts of+  case parse (many (pEntity <|> anyTok)) "" ts of         Left _    -> ts         Right ts' -> ts'-  where pEntity' :: ParsecT [Tok] () Identity Tok-        pEntity' = try $ do-          pos <- getPosition-          symbol '&'-          ent <- untokenize <$> (numEntity <|> charEntity)-          case lookupEntity ent of-                Just s  -> return $ Tok WordChars pos s-                Nothing -> mzero++pEntity :: Monad m => ParsecT [Tok] s m Tok+pEntity = try $ do+  pos <- getPosition+  symbol '&'+  ent <- untokenize <$> (numEntity <|> charEntity)+  case lookupEntity ent of+        Just s  -> return $ Tok WordChars pos s+        Nothing -> mzero
src/Commonmark/Inlines.hs view
@@ -58,7 +58,8 @@ import qualified Data.Set                   as Set import           Data.Text                  (Text) import qualified Data.Text                  as T-import           Commonmark.Entity          (unEntity, charEntity, numEntity)+import           Commonmark.Entity          (unEntity, charEntity, numEntity,+                                             pEntity) import           Text.Parsec                hiding (State, space) import           Text.Parsec.Pos @@ -906,7 +907,7 @@ pInlineLink = try $ do   _ <- symbol '('   optional whitespace-  target <- unEntity <$> pLinkDestination+  target <- untokenize <$> pLinkDestination   optional whitespace   title <- option "" $              unEntity <$> (pLinkTitle <* optional whitespace)@@ -922,7 +923,8 @@     pAngleDest = do       _ <- symbol '<'       res <- many (noneOfToks [Symbol '<', Symbol '>', Symbol '\\',-                                LineEnd] <|> pEscaped)+                               Symbol '&', LineEnd]+                    <|> pEscaped <|> pEntity <|> symbol '&')       _ <- symbol '>'       return res @@ -935,7 +937,8 @@     pNormalDest' numparens      | numparens > 32 = mzero      | otherwise = (do-          t <- satisfyTok (\case+          t <- pEntity <|>+                satisfyTok (\case                            Tok (Symbol '\\') _ _ -> True                            Tok (Symbol ')') _ _  -> numparens >= 1                            Tok Spaces _ _        -> False
test/regression.md view
@@ -350,3 +350,103 @@ <!x > ````````````````````````````````++Issue #149+```````````````````````````````` example+[link](\&#33;)++[link](&#33;)+.+<p><a href="&amp;#33;">link</a></p>+<p><a href="!">link</a></p>+````````````````````````````````++Issue #144+```````````````````````````````` example++ Is this wrapping list tight, or loose?+  * This nested list is definitely tight.+  -+++  -+.+<ul>+<li>Is this wrapping list tight, or loose?+<ul>+<li>This nested list is definitely tight.</li>+</ul>+<ul>+<li></li>+<li></li>+</ul>+</li>+</ul>+````````````````````````````````+```````````````````````````````` example++ Is this wrapping list tight, or loose?+  * This nested list is definitely tight.+  - First item+++  -+.+<ul>+<li>Is this wrapping list tight, or loose?+<ul>+<li>This nested list is definitely tight.</li>+</ul>+<ul>+<li>+<p>First item</p>+</li>+<li></li>+</ul>+</li>+</ul>+````````````````````````````````+```````````````````````````````` example++ Is this wrapping list tight, or loose?+  * This nested list is definitely tight.+  -+++  - Second item+.+<ul>+<li>Is this wrapping list tight, or loose?+<ul>+<li>This nested list is definitely tight.</li>+</ul>+<ul>+<li></li>+<li>+<p>Second item</p>+</li>+</ul>+</li>+</ul>+````````````````````````````````+```````````````````````````````` example++ Is this wrapping list tight, or loose?+  * This nested list is definitely tight.+  - First item+++  - Second item+.+<ul>+<li>Is this wrapping list tight, or loose?+<ul>+<li>This nested list is definitely tight.</li>+</ul>+<ul>+<li>+<p>First item</p>+</li>+<li>+<p>Second item</p>+</li>+</ul>+</li>+</ul>+````````````````````````````````