jira-wiki-markup 1.3.3 → 1.3.4
raw patch · 8 files changed
+74/−15 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +15/−0
- jira-wiki-markup.cabal +1/−1
- src/Text/Jira/Parser/Block.hs +4/−2
- src/Text/Jira/Parser/Inline.hs +13/−10
- src/Text/Jira/Printer.hs +3/−2
- test/Text/Jira/Parser/BlockTests.hs +4/−0
- test/Text/Jira/Parser/InlineTests.hs +8/−0
- test/Text/Jira/PrinterTests.hs +26/−0
CHANGELOG.md view
@@ -4,6 +4,21 @@ `jira-wiki-markup` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +1.3.4+-----++Released 2021-03-13.++* Fixed parsing of autolinks (i.e., of bare URLs in the text).+ Previously an autolink would take up the rest of a line, as+ spaces were allowed characters in these items.+ +* Emoji character sequences no longer cause parsing failures. This+ was due to missing backtracking when emoji parsing fails.+ +* Block quotes are only rendered as `bq.` if they do not contain a+ linebreak.+ 1.3.3 -----
jira-wiki-markup.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: jira-wiki-markup-version: 1.3.3+version: 1.3.4 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
@@ -170,8 +170,10 @@ (string "bq." *> skipMany (char ' ') *> inline `manyTill` (void newline <|> eof)) multiLineBq = BlockQuote <$>- (string "{quote}" *> optional blankline *>- block `manyTill` try (string "{quote}"))+ (string "{quote}"+ *> optional blankline+ *> skipMany (char ' ')+ *> block `manyTill` try (string "{quote}")) -- | Parses four consecutive hyphens as @'HorizontalRule'@. horizontalRule :: JiraParser Block
src/Text/Jira/Parser/Inline.hs view
@@ -110,7 +110,7 @@ -- | Parses textual representation of an icon into an @'Emoji'@ element. emoji :: JiraParser Inline-emoji = Emoji <$> icon <* notFollowedBy' letter <?> "emoji"+emoji = try (Emoji <$> icon <* notFollowedBy' letter <?> "emoji") -- | Parses ASCII representation of en-dash or em-dash. dash :: JiraParser Inline@@ -171,7 +171,7 @@ (alias, sep) <- option ([], '|') . try $ (,) <$> many inline <*> oneOf "^|" (linkType, linkURL) <- if sep == '|' then (Email,) <$> email <|>- (External,) <$> url <|>+ (External,) <$> url False <|> (External,) <$> anchorLink <|> (User,) <$> userLink else (Attachment,) . URL . pack <$> many1 urlChar@@ -182,16 +182,17 @@ autolink :: JiraParser Inline autolink = do guard . not . stateInLink =<< getState- AutoLink <$> (email' <|> url) <?> "email or other URL"+ AutoLink <$> (email' <|> url True) <?> "email or other URL" where email' = (\(URL e) -> URL ("mailto:" <> e)) <$> email --- | Parse a URL with scheme @file@, @ftp@, @http@, @https@, @irc@, @nntp@, or--- @news@.-url :: JiraParser URL-url = try $ do+-- | Parse a URL with scheme @file@, @ftp@, @http@, @https@, @irc@,+-- @nntp@, or @news@.+url :: Bool -> JiraParser URL+url isAutoLink = try $ do+ let urlChar' = if isAutoLink then urlChar else urlChar <|> char ' ' urlScheme <- scheme sep <- pack <$> string "://"- rest <- pack <$> many urlChar+ rest <- pack <$> many urlChar' return $ URL (urlScheme `append` sep `append` rest) where scheme = do@@ -217,8 +218,10 @@ -- | Parses a character which is allowed in URLs urlChar :: JiraParser Char-urlChar = satisfy $ \c ->- c `notElem` ("|]" :: String) && ord c >= 32 && ord c <= 127+urlChar = satisfy $ \case+ ']' -> False -- "]"+ '|' -> False -- "|"+ x -> ord x > 32 && ord x <= 126 -- excludes space -- -- Color
src/Text/Jira/Printer.hs view
@@ -141,11 +141,12 @@ , blks , "{color}" ]- BlockQuote [Para xs] -> return $ "bq. " <> prettyInlines xs+ BlockQuote [Para xs] | Linebreak `notElem` xs+ -> return $ "bq. " <> prettyInlines xs BlockQuote blocks -> renderBlocks blocks >>= \blks -> return $ T.concat [ "{quote}\n" , blks- , "\n{quote}"]+ , "{quote}"] Header lvl inlines -> return $ T.concat [ "h", T.pack (show lvl), ". " , prettyInlines inlines
test/Text/Jira/Parser/BlockTests.hs view
@@ -354,6 +354,10 @@ parseJira blockQuote "bq.another test\n" @?= Right (BlockQuote [Para [Str "another", Space, Str "test"]]) + , testCase "multiline block quote" $+ parseJira blockQuote "{quote}\n quote\n me\n{quote}\n" @?=+ Right (BlockQuote [Para [Str "quote", Linebreak, Str "me"]])+ , testCase "multi-paragraph block quote" $ parseJira blockQuote "{quote}\npara1\n\npara2\n{quote}\n" @?= Right (BlockQuote [ Para [Str "para1"]
test/Text/Jira/Parser/InlineTests.hs view
@@ -226,6 +226,10 @@ parseJira autolink "https://example.org/foo" @?= 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"))+ , testCase "email" $ parseJira autolink "mailto:nobody@test.invalid" @?= Right (AutoLink (URL "mailto:nobody@test.invalid"))@@ -362,6 +366,10 @@ parseJira (normalizeInlines <$> many1 inline) "verdict: :D funny" @?= Right [ Str "verdict", SpecialChar ':', Space , Emoji IconSmiling, Space, Str "funny"]++ , testCase "smiley within word" $+ parseJira (normalizeInlines <$> many1 inline) "C:DE" @?=+ Right [ Str "C", SpecialChar ':', Str "DE" ] , testCase "dash with spaces" $ parseJira (many1 inline) "one -- two" @?=
test/Text/Jira/PrinterTests.hs view
@@ -108,6 +108,32 @@ let list = List Enumeration [[Para [Str "boring"]]] para = Para [Str "after", Space, Str "table"] in prettyBlocks [list, para] @?= "# boring\n\nafter table\n"++ , testGroup "block quote"+ [ testCase "single-line block quote" $+ let bq = BlockQuote [Para+ [Str "Errare", Space, Str "humanum", Space, Str "est."]+ ]+ in prettyBlocks [bq] @?= "bq. Errare humanum est."++ , testCase "multi-line block quote" $+ let bq = BlockQuote [Para [Str "Show", Linebreak, Str "me"]]+ in prettyBlocks [bq] @?= "{quote}\nShow\nme\n{quote}"++ , testCase "multi-paragraph block quote" $+ let bq = BlockQuote [Para [Str "Only."], Para [Str "You."]]+ in prettyBlocks [bq] @?= "{quote}\nOnly.\n\nYou.\n{quote}"+ ]++ , testGroup "panel"+ [ testCase "simple panel" $+ let panel = Panel [] [Para [Str "Contents!"]]+ in prettyBlocks [panel] @?= "{panel}\nContents!\n{panel}"++ , testCase "panel with title" $+ let panel = Panel [Parameter "title" "Gimme"] [Para [Str "Contents!"]]+ in prettyBlocks [panel] @?= "{panel:title=Gimme}\nContents!\n{panel}"+ ] ] , testGroup "isolated inline"