packages feed

jira-wiki-markup 1.3.5 → 1.4.0

raw patch · 7 files changed

+77/−10 lines, 7 filesdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: text

API changes (from Hackage documentation)

+ Text.Jira.Markup: SmartCard :: LinkType
+ Text.Jira.Markup: SmartLink :: LinkType

Files

CHANGELOG.md view
@@ -4,6 +4,18 @@ `jira-wiki-markup` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +1.4.0+-----++Released 2021-05-25.++* Allow quoted image parameters.++* Added support for "smart links".++* **API Change**: Add new constructors `SmartCard` and `SmartLink` to+  Text.Jira.Markup.LinkType.+ 1.3.5 ----- 
jira-wiki-markup.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.0 name:                jira-wiki-markup-version:             1.3.5+version:             1.4.0 synopsis:            Handle Jira wiki markup description:         Parse jira wiki text into an abstract syntax tree for easy                      transformation to other formats.@@ -20,7 +20,8 @@                    , GHC == 8.4.4                    , GHC == 8.6.5                    , GHC == 8.8.3-                   , GHC == 8.10.1+                   , GHC == 8.10.4+                   , GHC == 9.0  source-repository head   type:                git
src/Text/Jira/Markup.hs view
@@ -67,6 +67,8 @@   = Attachment                          -- ^ link to an attachment   | Email                               -- ^ link to an email address   | External                            -- ^ external resource, like a website+  | SmartCard                           -- ^ smart-card link (external)+  | SmartLink                           -- ^ "smart" link with icon, short-name   | User                                -- ^ link to a user   deriving (Eq, Ord, Show) 
src/Text/Jira/Parser/Inline.hs view
@@ -159,8 +159,10 @@     thumbnail = [Parameter "thumbnail" ""] <$ try (string "thumbnail")     imgParams = try (Parameter <$> key <*> (char '=' *> value))     key       = pack <$> many1 (noneOf ",\"'\t\n\r |{}=!")-    value     = pack <$> many1 (noneOf ",\"'\n\r|{}=!")+    value     = pack <$> (try quotedValue <|> unquotedValue)     comma     = char ',' *> skipSpaces+    quotedValue = char '"' *> manyTill (noneOf "\n\r") (char '"')+    unquotedValue = many1 (noneOf ",\"'\n\r|{}=!")  -- | Parse link into a @Link@ element. link :: JiraParser Inline@@ -169,13 +171,14 @@   withStateFlag (\b st -> st { stateInLink = b }) $ do     _ <- char '['     (alias, sep) <- option ([], '|') . try $ (,) <$> many inline <*> oneOf "^|"-    (linkType, linkURL) <- if sep == '|'-                           then (Email,) <$> email <|>-                                (External,) <$> url False <|>-                                (External,) <$> anchorLink <|>-                                (User,) <$> userLink-                           else (Attachment,) . URL . pack <$>-                                many1 (noneOf "\t\r\f\n]|:;/\\")+    (linkType, linkURL) <-+      if sep == '|'+      then (Email,) <$> email <|>+           (External,) <$> anchorLink <|>+           (User,) <$> userLink <|>+           externalLink+      else (Attachment,) . URL . pack <$>+           many1 (noneOf "\t\r\f\n]|:;/\\")     _ <- char ']'     return $ Link linkType alias linkURL @@ -217,6 +220,23 @@ -- | Parses a user-identifying resource name userLink :: JiraParser URL userLink = URL . pack <$> (char '~' *> many (noneOf "|]\n\r"))++-- | Parses an external link, i.e., either a plain link to an external+-- website, or a \"smart\" link or card.+externalLink :: JiraParser (LinkType, URL)+externalLink = do+  url' <- url False+  mSmartType <- optionMaybe (char '|' *> smartLinkType)+  return $ case mSmartType of+    Nothing -> (External, url')+    Just st -> (st, url')++-- | Finds the type of a "smart" link.+smartLinkType :: JiraParser LinkType+smartLinkType = string "smart-" *> choice+  [ SmartLink <$ string "link"+  , SmartCard <$ string "card"+  ]  -- | Parses a character which is allowed in URLs urlChar :: JiraParser Char
src/Text/Jira/Printer.hs view
@@ -264,11 +264,15 @@   Attachment -> "[" <> prettyInlines inlines <> "^" <> fromURL url <> "]"   Email      -> link' $ "mailto:" <> fromURL url   External   -> link' $ fromURL url+  SmartCard  -> smartLink (fromURL url) "smart-card"+  SmartLink  -> smartLink (fromURL url) "smart-link"   User       -> link' $ "~" <> fromURL url  where   link' urlText = case inlines of     [] -> "[" <> urlText <> "]"     _  -> "[" <> prettyInlines inlines <> "|" <> urlText <> "]"+  smartLink urlText smartType =+    "[" <> prettyInlines inlines <> "|" <> urlText <> "|" <> smartType <> "]"  delimiterChar :: InlineStyle -> Char delimiterChar = \case
test/Text/Jira/Parser/InlineTests.hs view
@@ -298,6 +298,19 @@           Right (Link Attachment [] (URL "Straßenbahn Berlin.jpg"))         ] +      , testGroup "smart links"+        [ testCase "smart link" $+          parseJira link "[hslua|https://github.com/hslua/hslua|smart-link]" @?=+          Right (Link SmartLink [Str "hslua"]+                 (URL "https://github.com/hslua/hslua"))++        , testCase "smart card" $+          parseJira link+            "[repo|https://github.com/tarleb/jira-wiki-markup|smart-card]" @?=+          Right (Link SmartCard [Str "repo"]+                 (URL "https://github.com/tarleb/jira-wiki-markup"))+        ]+       , testCase "user link" $         parseJira link "[testing|~account-id:something]" @?=         Right (Link User [Str "testing"] (URL "account-id:something"))@@ -326,6 +339,11 @@                      , Parameter "vspace" "4"                      ]         in Right (Image params (URL "image.gif"))++      , testCase "quoted parameter" $+        parseJira image "!foo.jpg|alt=\"some foo!\"!" @?=+        let params = [ Parameter "alt" "some foo!"]+        in Right (Image params (URL "foo.jpg"))       ]      , testGroup "color"
test/Text/Jira/PrinterTests.hs view
@@ -184,6 +184,16 @@       , testCase "user" $         renderInline (Link User [Str "John", Space, Str "Doe"] "ab34-cdef") @?=         "[John Doe|~ab34-cdef]"++      , testCase "smart link" $+        renderInline (Link SmartLink [Str "repo"]+                      "https://github.com/tarleb/jira-wiki-markup") @?=+        "[repo|https://github.com/tarleb/jira-wiki-markup|smart-link]"++      , testCase "smart card" $+        renderInline (Link SmartCard [Str "hslua"]+                      "https://github.com/hslua/hslua") @?=+        "[hslua|https://github.com/hslua/hslua|smart-card]"       ]      , testCase "Styled Emphasis" $