commonmark-extensions 0.2.5.5 → 0.2.5.6
raw patch · 3 files changed
+19/−11 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +6/−0
- commonmark-extensions.cabal +1/−1
- src/Commonmark/Extensions/Autolink.hs +12/−10
changelog.md view
@@ -1,5 +1,11 @@ # Changelog for commonmark-extensions +## 0.2.5.6++ * Autolink parser: track balanced brackets in path (improves+ on #156). We still get a link within a link, which isn't right, but at+ least the link goes to the right place. Cf. jgm/pandoc#10333.+ ## 0.2.5.5 * Fix auto_identifiers extension: it now replaces emojis with
commonmark-extensions.cabal view
@@ -1,5 +1,5 @@ name: commonmark-extensions-version: 0.2.5.5+version: 0.2.5.6 synopsis: Pure Haskell commonmark parser. description: This library provides some useful extensions to core commonmark
src/Commonmark/Extensions/Autolink.hs view
@@ -32,7 +32,7 @@ wwwAutolink = try $ do lookAhead $ satisfyWord (== "www") validDomain- linkPath 0+ linkPath 0 0 return "http://" validDomain :: Monad m => InlineParser m ()@@ -47,27 +47,29 @@ domainPart skipMany1 $ try (symbol '.' >> domainPart) -linkPath :: Monad m => Int -> InlineParser m ()-linkPath openParens = optional $ do+linkPath :: Monad m => Int -> Int -> InlineParser m ()+linkPath openParens openBrackets = optional $ do Tok tt _ _ <- lookAhead anyTok case tt of Symbol '&' -> optional $ try (symbol '&' *> notFollowedBy (try (satisfyWord (const True) *> symbol ';' *> linkEnd)) *>- linkPath openParens)- Symbol '(' -> symbol '(' *> linkPath (openParens + 1)- Symbol ')' -> optional $ guard (openParens > 0) *> symbol ')' *> linkPath (openParens - 1)+ linkPath openParens openBrackets)+ Symbol '(' -> symbol '(' *> linkPath (openParens + 1) openBrackets+ Symbol ')' -> optional $ guard (openParens > 0) *> symbol ')' *> linkPath (openParens - 1) openBrackets+ Symbol '[' -> symbol '[' *> linkPath openParens (openBrackets + 1)+ Symbol ']' -> optional $ guard (openParens > 0) *> symbol ']' *> linkPath openParens (openBrackets - 1) Symbol '<' -> pure () Symbol c | isTrailingPunctuation c -> optional $ try (do skipMany1 trailingPunctuation pos <- getPosition- linkPath openParens+ linkPath openParens openBrackets pos' <- getPosition- guard (pos' > pos)) *> linkPath openParens+ guard (pos' > pos)) *> linkPath openParens openBrackets LineEnd -> pure () Spaces -> pure ()- _ -> anyTok *> linkPath openParens+ _ -> anyTok *> linkPath openParens openBrackets linkEnd :: Monad m => InlineParser m () linkEnd = try $ skipMany trailingPunctuation *> (void whitespace <|> eof)@@ -89,7 +91,7 @@ symbol '/' symbol '/' validDomain- linkPath 0+ linkPath 0 0 return "" emailAutolink :: Monad m => InlineParser m Text