packages feed

commonmark-extensions 0.2.5.3 → 0.2.5.4

raw patch · 4 files changed

+38/−26 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,5 +1,10 @@ # Changelog for commonmark-extensions +## 0.2.5.4++  * Fix autolink parsing regression (#151). This affects autolinks with+    doubled internal line-ending punctuation characters.+ ## 0.2.5.3    * Fix rebase_relative_paths extension so it works with URLs with
commonmark-extensions.cabal view
@@ -1,5 +1,5 @@ name:           commonmark-extensions-version:        0.2.5.3+version:        0.2.5.4 synopsis:       Pure Haskell commonmark parser. description:    This library provides some useful extensions to core commonmark
src/Commonmark/Extensions/Autolink.hs view
@@ -48,30 +48,32 @@   skipMany1 $ try (symbol '.' >> domainPart)  linkPath :: Monad m => Int -> InlineParser m ()-linkPath openParens =+linkPath openParens = optional $ do+   Tok tt _ _ <- lookAhead anyTok+   case tt of+     Symbol '&' -> optional $       try (symbol '&' *>            notFollowedBy              (try (satisfyWord (const True) *> symbol ';' *> linkEnd)) *>            linkPath openParens)-  <|> (pathPunctuation *> linkPath openParens)-  <|> (symbol '(' *> linkPath (openParens + 1))-  <|> (guard (openParens > 0) *> symbol ')' *> linkPath (openParens - 1))-  -- the following clause is needed to implement the GFM spec, which allows-  -- unbalanced ) except at link end. However, leaving this in causes-  -- problematic interaction with explicit link syntax in certain odd cases (see #147).-  -- <|> (notFollowedBy linkEnd *> symbol ')' *> linkPath (openParens - 1))-  <|> (satisfyTok (\t -> case tokType t of-                            LineEnd -> False-                            Spaces -> False-                            Symbol c -> not (isTrailingPunctuation c || c == '&' || c == ')')-                            _ -> True) *> linkPath openParens)-  <|> pure ()+     Symbol '(' -> symbol '(' *> linkPath (openParens + 1)+     Symbol ')' -> optional $ guard (openParens > 0) *> symbol ')' *> linkPath (openParens - 1)+     Symbol '<' -> pure ()+     Symbol c | isTrailingPunctuation c -> optional $+         try (do skipMany1 trailingPunctuation+                 pos <- getPosition+                 linkPath openParens+                 pos' <- getPosition+                 guard (pos' > pos)) *> linkPath openParens+     LineEnd -> pure ()+     Spaces -> pure ()+     _ -> anyTok *> linkPath openParens  linkEnd :: Monad m => InlineParser m () linkEnd = try $ skipMany trailingPunctuation *> (void whitespace <|> eof) -trailingPunctuation :: Monad m => InlineParser m ()-trailingPunctuation = void $+trailingPunctuation :: Monad m => InlineParser m Tok+trailingPunctuation =   satisfyTok (\t -> case tokType t of                            Symbol c -> isTrailingPunctuation c                            _ -> False)@@ -79,15 +81,6 @@ isTrailingPunctuation :: Char -> Bool isTrailingPunctuation =   (`elem` ['!', '"', '\'', ')', '*', ',', '.', ':', ';', '?', '_', '~', '<'])--pathPunctuation :: Monad m => InlineParser m ()-pathPunctuation = try $ do-  satisfyTok (\t -> case tokType t of-                       Symbol c -> isTrailingPunctuation c && c /= ')' && c /= '<'-                       _        -> False)-  void $ lookAhead (satisfyTok (\t -> case tokType t of-                                        WordChars -> True-                                        _ -> False))  urlAutolink :: Monad m => InlineParser m Text urlAutolink = try $ do
test/autolinks.md view
@@ -194,3 +194,17 @@ . <p><a href="http://www.google.com/">a link</a>stuff?</p> ````````````````````````````````++Autolinks with punctuation (#151):++```````````````````````````````` example+https://en.wikipedia.org/wiki/St._Petersburg_paradox++https://en.wikipedia.org/wiki/Liaison_(French)++https://en.wikipedia.org/wiki/Frederick_III,_German_Emperor+.+<p><a href="https://en.wikipedia.org/wiki/St._Petersburg_paradox">https://en.wikipedia.org/wiki/St._Petersburg_paradox</a></p>+<p><a href="https://en.wikipedia.org/wiki/Liaison_(French)">https://en.wikipedia.org/wiki/Liaison_(French)</a></p>+<p><a href="https://en.wikipedia.org/wiki/Frederick_III,_German_Emperor">https://en.wikipedia.org/wiki/Frederick_III,_German_Emperor</a></p>+````````````````````````````````