packages feed

jira-wiki-markup 1.0.0 → 1.1.0

raw patch · 16 files changed

+90/−20 lines, 16 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Jira.Markup: ColorInline :: ColorName -> [Inline] -> Inline
+ Text.Jira.Parser.Inline: colorInline :: JiraParser Inline

Files

CHANGELOG.md view
@@ -3,6 +3,16 @@ `jira-wiki-markup` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +1.1.0+=====++Released 2020-03-13.++* Lists are now allowed to be indented; i.e., lists are still recognized+  if list markers are preceded by spaces.+* Support for colored inlines has been added.+* New constructor `ColorInline` for type `Inline` (API change).+ 1.0.0 ===== 
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Albert Krewinkel+Copyright © 2019–2020 Albert Krewinkel  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
jira-wiki-markup.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.0 name:                jira-wiki-markup-version:             1.0.0+version:             1.1.0 synopsis:            Handle Jira wiki markup description:         Parse jira wiki text into an abstract syntax tree for easy                      transformation to other formats.@@ -10,7 +10,7 @@ license-file:        LICENSE author:              Albert Krewinkel maintainer:          tarleb@zeitkraut.de-copyright:           © 2019 Albert Krewinkel+copyright:           © 2019–2020 Albert Krewinkel category:            Text build-type:          Simple extra-doc-files:     README.md
src/Text/Jira/Markup.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-| Module      : Text.Jira.Markup-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -37,6 +37,7 @@ data Inline   = Anchor Text                         -- ^ anchor for internal links   | AutoLink URL                        -- ^ URL which is also a link+  | ColorInline ColorName [Inline]      -- ^ colored inline text   | Emoji Icon                          -- ^ emoticon   | Entity Text                         -- ^ named or numeric HTML entity   | Image [Parameter] URL               -- ^ an image
src/Text/Jira/Parser.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.Parser-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
src/Text/Jira/Parser/Block.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.Parser.Block-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -88,7 +88,7 @@       _   -> error ("the impossible happened: unknown style for bullet " ++ [c])      atDepth :: Int -> JiraParser ()-    atDepth depth = try . void $ count depth anyBulletMarker+    atDepth depth = try $ skipSpaces <* count depth anyBulletMarker      firstItemAtDepth :: Int -> JiraParser [Block]     firstItemAtDepth depth = try $ listContent (depth + 1) <|>@@ -113,7 +113,9 @@      nonListContent :: Int -> JiraParser [Block]     nonListContent depth = try $-      let nonListBlock = notFollowedBy' (many1 (oneOf "#-*")) *> block+      let nonListBlock = do+            notFollowedBy' (skipSpaces *> many1 (oneOf "#-*"))+            block       in char ' ' *> do         first   <- block         nonList <- many nonListBlock
src/Text/Jira/Parser/Core.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.Parser.Core-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -114,7 +114,7 @@   <|> lookAhead panelStart   where     headerStart    = void $ char 'h' *> oneOf "123456" <* char '.'-    listItemStart  = void $ many1 (oneOf "#*-") <* char ' '+    listItemStart  = void $ skipSpaces *> many1 (oneOf "#*-") <* char ' '     tableStart     = void $ skipSpaces *> many1 (char '|') *> char ' '     panelStart     = void $ char '{' *> choice (map (try . string) blockNames)     horizontalRule = void $ try (string "----") *> blankline
src/Text/Jira/Parser/Inline.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE LambdaCase #-} {-| Module      : Text.Jira.Parser.Inline-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -17,6 +17,7 @@     -- * Inline component parsers   , anchor   , autolink+  , colorInline   , dash   , emoji   , entity@@ -57,6 +58,7 @@   , link   , image   , styled+  , colorInline   , monospaced   , anchor   , entity@@ -189,6 +191,19 @@ urlChar = satisfy $ \c ->   c `notElem` ("|]" :: String) && ord c >= 32 && ord c <= 127 +--+-- Color+--++-- | Text in a different color.+colorInline :: JiraParser Inline+colorInline = try $ do+  name <- string "{color:" *> (colorName <|> colorCode) <* char '}'+  content <- inline `manyTill` try (string "{color}")+  return $ ColorInline (ColorName $ pack name) content+  where+    colorName = many1 letter+    colorCode = (:) <$> (option '#' (char '#')) <*> count 6 digit  -- -- Markup
src/Text/Jira/Parser/PlainText.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.Parser.PlainText-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
src/Text/Jira/Parser/Shared.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-| Module      : Text.Jira.Parser.Shared-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
src/Text/Jira/Printer.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE LambdaCase #-} {-| Module      : Text.Jira.Parser-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -213,6 +213,8 @@ renderInline = \case   Anchor name            -> "{anchor:" <> name <> "}"   AutoLink url           -> urlText url+  ColorInline color ils  -> "{color:" <> colorText color <> "}" <>+                            prettyInlines ils <> "{color}"   Emoji icon             -> iconText icon   Entity entity          -> "&" <> entity <> ";"   Image params url       -> "!" <> urlText url <>
test/Text/Jira/Parser/BlockTests.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.Parser.BlockTests-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -193,6 +193,21 @@                     , List CircleBullets [[Para [Str "drei"]]]                     ]                   ])++      , testCase "indentation is ignored" $+        let text = Text.unlines+                   [ "        * One"+                   , "        * Two"+                   , "        ** Two.One"+                   , "    * Three"+                   ]+        in parseJira list text @?=+           Right (List CircleBullets+                 [ [ Para [Str "One"] ]+                 , [ Para [Str "Two"]+                   , List CircleBullets [[Para [Str "Two.One"]]]]+                 , [ Para [Str "Three"] ]+                 ])       ]      , testGroup "Table"
test/Text/Jira/Parser/InlineTests.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.Parser.InlineTests-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -250,6 +250,20 @@         isLeft (parseJira image "!hello\nworld.png!") @?         "no newlines in image names"       ]++    , testGroup "color"+      [ testCase "colored word" $+        parseJira colorInline "{color:red}red{color}" @?=+        Right (ColorInline (ColorName "red") [Str "red"])++      , testCase "hex color" $+        parseJira colorInline "{color:#526487}blueish{color}" @?=+        Right (ColorInline (ColorName "#526487") [Str "blueish"])++      , testCase "hex color without hash" $+        parseJira colorInline "{color:526487}blueish{color}" @?=+        Right (ColorInline (ColorName "#526487") [Str "blueish"])+      ]     ]    , testGroup "inline parser"@@ -291,9 +305,15 @@       parseJira (many1 inline) "one  -- two" @?=       Right [Str "one", Space, Str "–", Space, Str "two"] -     , testCase "forced markup" $       parseJira (many1 inline) "H{~}2{~}O" @?=       Right [Str "H", Styled Subscript [Str "2"], Str "O"]++    , testCase "color in sentence" $+      parseJira (many1 inline) "This is {color:red}red{color}." @?=+      Right [ Str "This", Space, Str "is", Space+            , ColorInline (ColorName "red") [Str "red"]+            , Str "."+            ]     ]   ]
test/Text/Jira/ParserTests.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.ParserTests-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
test/Text/Jira/PrinterTests.hs view
@@ -1,6 +1,6 @@ {-| Module      : Text.Jira.PrinterTests-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>@@ -126,6 +126,11 @@     , testCase "Styled Strong" $       renderInline (Styled Strong [Str "Hello,", Space, Str "World!"]) @?=       "*Hello, World!*"++    , testCase "Colored inlines" $+      renderInline (ColorInline (ColorName "red")+                    [Str "This", Space, Str "is", Space, Str "red."]) @?=+      "{color:red}This is red.{color}"     ]    , testGroup "combined inlines"
test/jira-wiki-markup-test.hs view
@@ -1,6 +1,6 @@ {-| Module      : Main-Copyright   : © 2019 Albert Krewinkel+Copyright   : © 2019–2020 Albert Krewinkel License     : MIT  Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>