packages feed

hakyll-shortcut-links 0.0.0.0 → 0.1.0.0

raw patch · 6 files changed

+113/−79 lines, 6 filesdep +parsecdep −megaparsecdep ~basedep ~hakylldep ~pandocPVP ok

version bump matches the API change (PVP)

Dependencies added: parsec

Dependencies removed: megaparsec

Dependency ranges changed: base, hakyll, pandoc, pandoc-types, shortcut-links

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -3,6 +3,16 @@ `hakyll-shortcut-links` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.1.0.0 — Feb 29, 2020++* [#16](https://github.com/kowainik/hakyll-shortcut-links/issues/16):+  Support GHC-8.8.2. Update `hakyll` and `pandoc` bounds.+  Remove support of GHC-8.6.5.+* [#21](https://github.com/kowainik/hakyll-shortcut-links/issues/21):+  Use `parsec` instead of `megaparsec`.+* [#23](https://github.com/kowainik/hakyll-shortcut-links/issues/23):+  Move CI to GitHub Actions.+ ## 0.0.0.0 — May 2, 2019  * Initially created.
README.md view
@@ -1,9 +1,9 @@ # hakyll-shortcut-links  ![scissors](https://user-images.githubusercontent.com/4276606/56942330-9bf93d80-6b4c-11e9-8286-3cb98eb0c94f.png)-[![Hackage](https://img.shields.io/hackage/v/hakyll-shortcut-links.svg)](https://hackage.haskell.org/package/hakyll-shortcut-links)+[![GitHub CI](https://github.com/kowainik/hakyll-shortcut-links/workflows/CI/badge.svg)](https://github.com/kowainik/hakyll-shortcut-links/actions)+[![Hackage](https://img.shields.io/hackage/v/hakyll-shortcut-links.svg?logo=haskell)](https://hackage.haskell.org/package/hakyll-shortcut-links) [![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](LICENSE)-[![Build status](https://secure.travis-ci.org/kowainik/hakyll-shortcut-links.svg)](https://travis-ci.org/kowainik/hakyll-shortcut-links)  This library adds the support of the [`shortcut-links`](https://hackage.haskell.org/package/shortcut-links) library@@ -28,6 +28,7 @@ Here is going to be a link to the [hakyll-shortcut-links](http://hackage.haskell.org/package/hakyll-shortcut-links) library on Hackage. And another link to the [GitHub sources](https://github.com/kowainik/hakyll-shortcut-links). ```+ For the full list of the supported shortcuts, you can check [ShortcutLinks.All module](https://hackage.haskell.org/package/shortcut-links/docs/ShortcutLinks-All.html) of the `shortcut-links` library.@@ -104,10 +105,26 @@ Here is an example of the pull request that introduces the `hakyll-shortcut-links` library into the scope: -* [Some Hakyll website](https://github.com/vrom911/vrom911.github.io/pull/32)+- [Some Hakyll website](https://github.com/vrom911/vrom911.github.io/pull/32)  As you can see by the diff the only actual change needed for that was replacing `pandocCompiler` with `allShortcutLinksCompiler`.++#### Examples of the `@github` shortcut:++- Link to a user :++  | Shortcut                             | Plain markdown                       |+  | ------------------------------------ | ------------------------------------ |+  | `[foo](@github)`                     | `[foo](https://github.com/foo)` |+  | `[foo Github profile](@github(foo))` | `[foo Github profile](https://github.com/foo)`      |++- Link to a repository :++  | Shortcut                            | Plain markdown                                |+  | ----------------------------------- | --------------------------------------------- |+  | `[bar](@github:foo)`                | `[bar](https://github.com/foo/bar)`           |+  | `[Github Source](@github(foo):bar)` | `[Github Source](https://github.com/foo/bar)` |  ## Acknowledgement 
hakyll-shortcut-links.cabal view
@@ -1,54 +1,49 @@-cabal-version:       2.0+cabal-version:       2.4 name:                hakyll-shortcut-links-version:             0.0.0.0+version:             0.1.0.0 synopsis:            Use shortcut-links in markdown file for Hakyll description:         Use shortcut-links in markdown file for Hakyll. See README for more details. homepage:            https://github.com/kowainik/hakyll-shortcut-links bug-reports:         https://github.com/kowainik/hakyll-shortcut-links/issues license:             MPL-2.0 license-file:        LICENSE-author:              Kowainik-maintainer:          xrom.xkov@gmail.com-copyright:           2019 Kowainik+author:              Veronika Romashkina, Dmitrii Kovanikov+maintainer:          Kowainik <xrom.xkov@gmail.com>+copyright:           2019-2020 Kowainik category:            Web, Hakyll, Markdown build-type:          Simple extra-doc-files:     README.md-                   , CHANGELOG.md-tested-with:         GHC == 8.6.3+                     CHANGELOG.md+tested-with:         GHC == 8.8.2  source-repository head   type:                git   location:            https://github.com/kowainik/hakyll-shortcut-links.git -library-  hs-source-dirs:      src-  exposed-modules:     Hakyll.ShortcutLinks-                          Hakyll.ShortcutLinks.Parser--  build-depends:       base ^>= 4.12.0.0-                     , hakyll ^>= 4.12.5-                     , megaparsec ^>= 7.0.4-                     , mtl ^>= 2.2.2-                     , pandoc-types ^>= 1.17-                     , shortcut-links ^>= 0.4.2.1-                     , text ^>= 1.2-+common common-options+  build-depends:       base >= 4.13.0.0 && < 4.14   ghc-options:         -Wall-                       -Wincomplete-uni-patterns-                       -Wincomplete-record-updates                        -Wcompat                        -Widentities-                       -Wredundant-constraints-                       -fhide-source-paths-                       -Wmissing-export-lists+                       -Wincomplete-uni-patterns+                       -Wincomplete-record-updates+  if impl(ghc >= 8.0)+    ghc-options:       -Wredundant-constraints+  if impl(ghc >= 8.2)+    ghc-options:       -fhide-source-paths+  if impl(ghc >= 8.4)+    ghc-options:       -Wmissing-export-lists                        -Wpartial-fields+  if impl(ghc >= 8.8)+    ghc-options:       -Wmissing-deriving-strategies+                       -Werror=missing-deriving-strategies -  default-language:    Haskell2010   default-extensions:  ConstraintKinds                        DeriveGeneric+                       DerivingStrategies                        GeneralizedNewtypeDeriving-                       InstanceSigs                        KindSignatures+                       InstanceSigs                        LambdaCase                        OverloadedStrings                        RecordWildCards@@ -58,44 +53,36 @@                        TypeApplications                        ViewPatterns +  default-language:    Haskell2010+++library+  import:              common-options+  hs-source-dirs:      src+  exposed-modules:     Hakyll.ShortcutLinks+                          Hakyll.ShortcutLinks.Parser++  build-depends:       hakyll ^>= 4.13+                     , mtl ^>= 2.2.2+                     , pandoc-types ^>= 1.20+                     , parsec ^>= 3.1.14+                     , shortcut-links ^>= 0.5.0.0+                     , text ^>= 1.2+ test-suite hakyll-shortcut-links-test+  import:              common-options   type:                exitcode-stdio-1.0   hs-source-dirs:      test   main-is:             Spec.hs   other-modules:       Test.Links                        Test.Parser -  build-depends:       base ^>= 4.12.0.0-                     , hakyll-shortcut-links+  build-depends:       hakyll-shortcut-links                      , hspec ^>= 2.7.1                      , mtl-                     , pandoc >= 2.6+                     , pandoc ^>= 2.9                      , text -  ghc-options:         -Wall-                       -threaded+  ghc-options:         -threaded                        -rtsopts                        -with-rtsopts=-N-                       -Wincomplete-uni-patterns-                       -Wincomplete-record-updates-                       -Wcompat-                       -Widentities-                       -Wredundant-constraints-                       -fhide-source-paths-                       -Wmissing-export-lists-                       -Wpartial-fields--  default-language:    Haskell2010-  default-extensions:  ConstraintKinds-                       DeriveGeneric-                       GeneralizedNewtypeDeriving-                       InstanceSigs-                       KindSignatures-                       LambdaCase-                       OverloadedStrings-                       RecordWildCards-                       ScopedTypeVariables-                       StandaloneDeriving-                       TupleSections-                       TypeApplications-                       ViewPatterns
src/Hakyll/ShortcutLinks.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleContexts #-}  {- |-Copyright:  (c) 2019 Kowainik+Copyright:  (c) 2019-2020 Kowainik License:    MPL-2.0 Maintainer: Kowainik <xrom.xkov@gmail.com> @@ -10,6 +10,28 @@  The flexible interface allows to use the supported huge collection of shortcuts along with using custom ones.++Here is a few examples of the `@github` shortcut:++- Link to a user:+++----------------------------------------+----------------------------------------------------++|              Shortcut                  |                Plain markdown                      |++========================================+====================================================++| @[foo]\(\@github)@                     | @[foo]\(https:\/\/github.com\/foo)@                |++----------------------------------------+----------------------------------------------------++| @[foo Github profile]\(\@github(foo))@ | @[foo Github profile]\(https:\/\/github.com\/foo)@ |++----------------------------------------+----------------------------------------------------+++- Link to a repository:+++---------------------------------------+----------------------------------------------------++|             Shortcut                  |               Plain markdown                       |++=======================================+====================================================++| @[bar]\(\@github:foo)@                | @[bar]\(https:\/\/github.com\/foo\/bar)@           |++---------------------------------------+----------------------------------------------------++| @[Github Source]\(\@github(foo):bar)@ | @[Github Source]\(https:\/\/github.com\/foo\/bar)@ |++---------------------------------------+----------------------------------------------------+ -}  module Hakyll.ShortcutLinks@@ -43,7 +65,6 @@ import ShortcutLinks as Sh import ShortcutLinks.All -import qualified Data.Text as T import qualified Text.Pandoc.Definition as Pandoc  @@ -98,10 +119,10 @@ applyShortcuts shortcuts = bottomUpM applyLink   where     applyLink :: Pandoc.Inline -> m Pandoc.Inline-    applyLink l@(Pandoc.Link attr inl (url, title)) = case parseShortcut $ T.pack url of+    applyLink l@(Pandoc.Link attr inl (url, title)) = case parseShortcut url of         Right (name, option, text) -> maybe (checkTitle inl) pure text >>= \txtTitle ->             case useShortcutFrom shortcuts name option txtTitle of-                Success link -> pure $ Pandoc.Link attr inl (T.unpack link, title)+                Success link -> pure $ Pandoc.Link attr inl (link, title)                 Warning ws _ -> throwError ws                 Failure msg  -> throwError [msg]         Left _ -> pure l  -- the link is not shortcut@@ -110,7 +131,7 @@     checkTitle :: [Pandoc.Inline] -> m Text     checkTitle = \case         [] -> throwError ["Empty shortcut link title arguments"]-        [Pandoc.Str s] -> pure $ T.pack s+        [Pandoc.Str s] -> pure s         _ -> throwError ["Shortcut title is not a single string element"]  {- |  Modifies markdown shortcut links to the extended version and returns
src/Hakyll/ShortcutLinks/Parser.hs view
@@ -1,5 +1,5 @@ {- |-Copyright:  (c) 2019 Kowainik+Copyright:  (c) 2019-2020 Kowainik License:    MPL-2.0 Maintainer: Kowainik <xrom.xkov@gmail.com> @@ -25,14 +25,13 @@        ) where  import Data.Text (Text)-import Data.Void (Void)-import Text.Megaparsec (Parsec, anySingle, noneOf, optional, parse, some, (<|>))-import Text.Megaparsec.Char (alphaNumChar, char)+import Text.Parsec (Parsec, anyChar, many1, noneOf, optionMaybe, parse, (<|>))+import Text.Parsec.Char (alphaNum, char)  import qualified Data.Text as T  -type Parser = Parsec Void Text+type Parser = Parsec Text ()  {- | Parses a shortcut link. Allowed formats: @@ -47,15 +46,15 @@ parseShortcut = either (Left . show) Right . parse p ""   where     name :: Parser Text-    name = T.pack <$> some (alphaNumChar <|> char '-')+    name = T.pack <$> many1 (alphaNum <|> char '-')      option, text :: Parser Text-    option = fmap T.pack $ char '(' *> some (noneOf [')']) <* char ')'-    text   = fmap T.pack $ char ':' *> some anySingle+    option = fmap T.pack $ char '(' *> many1 (noneOf [')']) <* char ')'+    text   = fmap T.pack $ char ':' *> many1 anyChar      p :: Parser (Text, Maybe Text, Maybe Text)     p = do         _ <- char '@'         (,,) <$> name-             <*> optional option-             <*> optional text+             <*> optionMaybe option+             <*> optionMaybe text
test/Test/Links.hs view
@@ -40,25 +40,25 @@ expandShortcuts txt = first show $ runPure $ do     md <- readMarkdown def txt     case applyAllShortcuts md of-        Left errs   -> throwError $ PandocSomeError $ unlines errs+        Left errs   -> throwError $ PandocSomeError $ T.pack $ unlines errs         Right newMd -> writeMarkdown def{ writerWrapText = WrapPreserve } newMd  md1Before, md1After :: Text md1Before = "This is [Hello](@github:kowainik)"-md1After  = "This is [Hello](https://github.com/kowainik)"+md1After  = "This is [Hello](https://github.com/kowainik)\n"  md2Before, md2After :: Text-md2Before = T.intercalate "\n"+md2Before = T.unlines     [ "Link 1: [Hello World](@github:kowainik)"     , "Link 2: [Ordinary link](https://stackoverflow.com/)"     , "Link 3: [kowainik/hakyll-shortcut-links](@github)"-    , "Link 4: [summoner](@hackage)"+    , "Link 4: [summoner](@hackage). Check text."     ]-md2After = T.intercalate "\n"+md2After = T.unlines     [ "Link 1: [Hello World](https://github.com/kowainik)"     , "Link 2: [Ordinary link](https://stackoverflow.com/)"     , "Link 3: [kowainik/hakyll-shortcut-links](https://github.com/kowainik/hakyll-shortcut-links)"-    , "Link 4: [summoner](https://hackage.haskell.org/package/summoner)"+    , "Link 4: [summoner](https://hackage.haskell.org/package/summoner). Check text."     ]  mdError1, mdError2, mdError3 :: Text