packages feed

jira-wiki-markup 1.3.4 → 1.3.5

raw patch · 7 files changed

+87/−17 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -4,6 +4,21 @@ `jira-wiki-markup` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +1.3.5+-----++Released 2021-05-24.+++* Allow spaces and most unicode characters in attachment links.++* No longer require a newline character after `{noformat}`.++* Only allow URI path segment characters in bare links.++* The `file:` schema is no longer allowed in bare links; these+  rarely make sense.+ 1.3.4 ----- 
jira-wiki-markup.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.0 name:                jira-wiki-markup-version:             1.3.4+version:             1.3.5 synopsis:            Handle Jira wiki markup description:         Parse jira wiki text into an abstract syntax tree for easy                      transformation to other formats.
src/Text/Jira/Parser/Block.hs view
@@ -183,8 +183,9 @@ -- | Parses a preformatted text into a @NoFormat@ element. noformat :: JiraParser Block noformat = try $ do-  (_, params) <- string "{noformat" *> parameters <* char '}' <* newline-  content <- anyChar `manyTill` try (string "{noformat}" *> blankline)+  (_, params) <- string "{noformat" *> parameters <* char '}'+  optional newline+  content <- anyChar `manyTill` try (string "{noformat}" *> optional blankline)   return $ NoFormat params (pack content)  -- | Parses a preformatted text into a @NoFormat@ element.
src/Text/Jira/Parser/Inline.hs view
@@ -35,7 +35,7 @@   ) where  import Control.Monad (guard, void)-import Data.Char (isAlphaNum, isPunctuation, ord)+import Data.Char (isAlphaNum, isAscii, isPunctuation, ord) #if !MIN_VERSION_base(4,13,0) import Data.Monoid ((<>), All (..)) #else@@ -174,7 +174,8 @@                                 (External,) <$> url False <|>                                 (External,) <$> anchorLink <|>                                 (User,) <$> userLink-                           else (Attachment,) . URL . pack <$> many1 urlChar+                           else (Attachment,) . URL . pack <$>+                                many1 (noneOf "\t\r\f\n]|:;/\\")     _ <- char ']'     return $ Link linkType alias linkURL @@ -186,10 +187,10 @@     where email' = (\(URL e) -> URL ("mailto:" <> e)) <$> email  -- | Parse a URL with scheme @file@, @ftp@, @http@, @https@, @irc@,--- @nntp@, or @news@.-url :: Bool -> JiraParser URL+-- @nntp@, or @news@; ignores @file@ if @isAutoLink@ is false.+url :: Bool {-^ isAutoLink -} -> JiraParser URL url isAutoLink = try $ do-  let urlChar' = if isAutoLink then urlChar else urlChar <|> char ' '+  let urlChar' = if isAutoLink then urlPathChar else urlChar <|> char ' '   urlScheme <- scheme   sep <- pack <$> string "://"   rest <- pack <$> many urlChar'@@ -198,7 +199,8 @@     scheme = do       first <- letter       case first of-        'f' -> ("file" <$ string "ile") <|> ("ftp" <$ string "tp")+        'f' -> ("file" <$ (guard (not isAutoLink) *> string "ile")) <|>+               ("ftp" <$ string "tp")         'h' -> string "ttp" *> option "http" ("https" <$ char 's')         'i' -> "irc" <$ string "rc"         'n' -> ("nntp" <$ string "ntp") <|> ("news" <$ string "ews")@@ -222,6 +224,33 @@   ']' -> False    -- "]"   '|' -> False    -- "|"   x   -> ord x > 32 && ord x <= 126 -- excludes space++-- | Parses a character in an URL path.+urlPathChar :: JiraParser Char+urlPathChar = satisfy $ \case+  '!' -> True+  '#' -> True+  '$' -> True+  '%' -> True+  '&' -> True+  '\''-> True+  '(' -> True+  ')' -> True+  '*' -> True+  '+' -> True+  ',' -> True+  '-' -> True+  '.' -> True+  '/' -> True+  ':' -> True+  ';' -> True+  '=' -> True+  '?' -> True+  '@' -> True+  '\\'-> True+  '_' -> True+  '~' -> True+  x   -> isAlphaNum x && isAscii x  -- -- Color
test/Text/Jira/Parser/BlockTests.hs view
@@ -309,6 +309,10 @@       , testCase "with parameters" $         parseJira noformat "{noformat:title=test}\nline 1\nline 2{noformat}\n" @?=         Right (NoFormat [Parameter "title" "test"] "line 1\nline 2")++      , testCase "without newline" $+        parseJira noformat "{noformat}raw text{noformat}\n" @?=+        Right (NoFormat [] "raw text")       ]      , testGroup "panel"
test/Text/Jira/Parser/InlineTests.hs view
@@ -227,12 +227,19 @@         Right (AutoLink (URL "https://example.org/foo"))        , testCase "link followed by text" $-        parseJira autolink "file:///etc/fstab has passwords" @?=-        Right (AutoLink (URL "file:///etc/fstab"))+        parseJira autolink "ftp://example.com/passwd has passwords" @?=+        Right (AutoLink (URL "ftp://example.com/passwd"))        , testCase "email" $         parseJira autolink "mailto:nobody@test.invalid" @?=         Right (AutoLink (URL "mailto:nobody@test.invalid"))++      , testCase "braces cannot be in bare links" $+        parseJira autolink "https://example.edu/{*}" @?=+        Right (AutoLink (URL "https://example.edu/"))++      , testCase "file URIs are not autolinks" $+        isLeft (parseJira autolink "file:///etc/fstab") @? ""       ]      , testGroup "citation"@@ -277,14 +284,20 @@         Right (Link Email [Str "send", Space, Str "mail"]                (URL "me@nope.invalid")) -      , testCase "attachment link" $-        parseJira link "[testing^test.xml]" @?=-        Right (Link Attachment [Str "testing"] (URL "test.xml"))+      , testGroup "attachment link"+        [ testCase "simple attachment" $+          parseJira link "[testing^test.xml]" @?=+          Right (Link Attachment [Str "testing"] (URL "test.xml")) -      , testCase "attachment without description" $-        parseJira link "[^results.txt]" @?=-        Right (Link Attachment [] (URL "results.txt"))+        , testCase "attachment without description" $+          parseJira link "[^results.txt]" @?=+          Right (Link Attachment [] (URL "results.txt")) +        , testCase "filename with space and unicode" $+          parseJira link "[^Straßenbahn Berlin.jpg]" @?=+          Right (Link Attachment [] (URL "Straßenbahn Berlin.jpg"))+        ]+       , testCase "user link" $         parseJira link "[testing|~account-id:something]" @?=         Right (Link User [Str "testing"] (URL "account-id:something"))@@ -340,6 +353,10 @@       Right [ Str "shopping", Space, Str "at", Space             , Str "P", Entity "amp", Str "C"             ]++    , testCase "autolink followed by pipe" $+      parseJira (many1 inline) "https://jira.example/file.txt|" @?=+      Right [AutoLink (URL "https://jira.example/file.txt"), SpecialChar '|']      , testCase "autolink followed by pipe" $       parseJira (many1 inline) "https://jira.example/file.txt|" @?=
test/Text/Jira/PrinterTests.hs view
@@ -177,6 +177,10 @@         renderInline (Link Attachment [] "something.txt") @?=         "[^something.txt]" +      , testCase "attachment with space and Unicode" $+        renderInline (Link Attachment [] "Übergang links.txt") @?=+        "[^Übergang links.txt]"+       , testCase "user" $         renderInline (Link User [Str "John", Space, Str "Doe"] "ab34-cdef") @?=         "[John Doe|~ab34-cdef]"