packages feed

commonmark-extensions 0.2.5.4 → 0.2.5.5

raw patch · 6 files changed

+42/−9 lines, 6 filesdep ~emojisPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: emojis

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,5 +1,12 @@ # Changelog for commonmark-extensions +## 0.2.5.5++  * Fix auto_identifiers extension: it now replaces emojis with+    their aliases, as documented.+  * Fix auto_identifiers_ascii extension: it now ignores+    non-ASCII characters with no ASCII equivalent.+ ## 0.2.5.4    * Fix autolink parsing regression (#151). This affects autolinks with
commonmark-extensions.cabal view
@@ -1,5 +1,5 @@ name:           commonmark-extensions-version:        0.2.5.4+version:        0.2.5.5 synopsis:       Pure Haskell commonmark parser. description:    This library provides some useful extensions to core commonmark@@ -62,7 +62,7 @@     , network-uri     , commonmark >= 0.2.4.1 && < 0.3     -- for extensions:-    , emojis >= 0.1 && < 0.2+    , emojis >= 0.1.4.1 && < 0.2   exposed-modules:       Commonmark.Extensions       Commonmark.Extensions.Smart
src/Commonmark/Extensions/AutoIdentifiers.hs view
@@ -16,6 +16,7 @@ import Data.Dynamic import qualified Data.Map as M import qualified Data.Text as T+import qualified Text.Emoji as Emoji import Text.Parsec  autoIdentifiersSpec :: (Monad m, IsBlock il bl, IsInline il, ToPlainText il)@@ -49,7 +50,8 @@       Nothing  -> do         contents <- runInlineParser                     (removeIndent . mconcat . reverse . blockLines $ bd)-        let ident = makeIdentifier ascii (toPlainText contents)+        let ident = makeIdentifier ascii+                     (Emoji.replaceEmojis emojiToAlias $ toPlainText contents)         counterMap <- counters <$> getState         let key = "identifier:" <> ident         cnt <- case M.lookup key counterMap of@@ -64,6 +66,10 @@       Just _ -> return $! bd   | otherwise = return $! bd +emojiToAlias :: T.Text -> [T.Text] -> T.Text+emojiToAlias t [] = t+emojiToAlias _ (a:_) = a+ makeIdentifier :: Bool -> T.Text -> T.Text makeIdentifier ascii = toIdent . T.toLower   where@@ -76,9 +82,13 @@                     = fromchar c         | otherwise = mempty     fromchar c-      | ascii-      , not (isAscii c) = maybe mempty T.singleton $ M.lookup c asciiMap-      | otherwise       = T.singleton c+      | ascii =+        if isAscii c+           then T.singleton c+           else case M.lookup c asciiMap of+                       Nothing -> mempty+                       Just d -> T.singleton d+      | otherwise = T.singleton c  asciiMap :: M.Map Char Char asciiMap = M.fromList
test/auto_identifiers.md view
@@ -82,3 +82,11 @@ <h1 id="hi-2">Hi</h1> <h1 id="hi-3">Hi</h1> ````````````````````````````````++Emojis should be replaced with aliases:++```+# Introduction ❤️💯+.+<h1 id="introduction-heart-100">Introduction ❤️💯</h1>+```
test/auto_identifiers_ascii.md view
@@ -3,10 +3,17 @@ The `auto_identifiers_ascii` extension is like `auto_identifiers` but limits identifiers to ASCII. Accented Latin characters are converted into the-closest ASCII equivalent.+closest ASCII equivalent. Other non-ASCII characters+are simply omitted.  ```````````````````````````````` example-# Heading with &auml;+# Heading with &auml; and &alpha; .-<h1 id="heading-with-a">Heading with &auml;</h1>+<h1 id="heading-with-a-and-">Heading with ä and α</h1>+````````````````````````````````++```````````````````````````````` example+# Heading with ❤️+.+<h1 id="heading-with-heart">Heading with ❤️</h1> ````````````````````````````````
test/test-commonmark-extensions.hs view
@@ -45,6 +45,7 @@              , ("test/bracketed_spans.md", bracketedSpanSpec)              , ("test/fenced_divs.md", fencedDivSpec)              , ("test/auto_identifiers.md", autoIdentifiersSpec <> attributesSpec)+             , ("test/auto_identifiers_ascii.md", autoIdentifiersAsciiSpec <> attributesSpec)              , ("test/implicit_heading_references.md",                  autoIdentifiersSpec <> attributesSpec <> implicitHeadingReferencesSpec)              , ("test/wikilinks_title_before_pipe.md", wikilinksSpec TitleBeforePipe)