packages feed

jira-wiki-markup 1.1.4 → 1.2.0

raw patch · 7 files changed

+84/−9 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Jira.Parser.Core: [stateLastSpcPos] :: ParserState -> Maybe SourcePos
+ Text.Jira.Parser.Core: afterSpace :: JiraParser Bool
+ Text.Jira.Parser.Core: afterString :: JiraParser Bool
+ Text.Jira.Parser.Core: updateLastSpcPos :: JiraParser ()
- Text.Jira.Parser.Core: ParserState :: Bool -> Bool -> Bool -> Maybe SourcePos -> ParserState
+ Text.Jira.Parser.Core: ParserState :: Bool -> Bool -> Bool -> Maybe SourcePos -> Maybe SourcePos -> ParserState

Files

CHANGELOG.md view
@@ -4,12 +4,33 @@ `jira-wiki-markup` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +1.2.0+-----++Released 2020-03-28++* Added check that a closing markup char is not preceeded by a+  whitespace character. Previously, plain text was still+  incorrectly treated as markup. E.g., the dashes in `-> step ->`+  used to be interpreted as delimiters marking deleted text.++* Allows empty table cells; table parsing failed if one of the+  cells did not contain any content.++* Changes to module `Text.Jira.Parser.Core`:++    - A field `stateLastSpcPos` was added to data type+      `ParserState` to keep track of spaces.+    - Function `updateLastSpcPos` was added to update the+      aforementioned field.+    - Function `afterSpace` was added to test the field.+ 1.1.4 -----  Released 2020-03-27 -* Fix parsing of image parameters. Thumbnails and images with+* Fixed parsing of image parameters. Thumbnails and images with   parameters were previously not recognized as images.  1.1.3
jira-wiki-markup.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.0 name:                jira-wiki-markup-version:             1.1.4+version:             1.2.0 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
@@ -138,7 +138,7 @@ cell :: JiraParser Cell cell = try $ do   mkCell <- cellStart-  bs     <- many1 block+  bs     <- many block   return $ mkCell bs  -- | Parses the beginning of a table cell and returns a function which
src/Text/Jira/Parser/Core.hs view
@@ -19,7 +19,10 @@   , withStateFlag   -- * String position tracking   , updateLastStrPos+  , updateLastSpcPos   , notAfterString+  , afterString+  , afterSpace   -- * Parsing helpers   , endOfPara   , notFollowedBy'@@ -42,6 +45,7 @@   { stateInLink      :: Bool            -- ^ whether the parser is within a link   , stateInList      :: Bool            -- ^ whether the parser is within a list   , stateInTable     :: Bool            -- ^ whether the parser is within a table+  , stateLastSpcPos  :: Maybe SourcePos -- ^ most recent space char position   , stateLastStrPos  :: Maybe SourcePos -- ^ position at which the last string                                         --   ended   }@@ -52,6 +56,7 @@   { stateInLink      = False   , stateInList      = False   , stateInTable     = False+  , stateLastSpcPos  = Nothing   , stateLastStrPos  = Nothing   } @@ -71,12 +76,35 @@   pos <- getPosition   modifyState $ \st -> st { stateLastStrPos = Just pos } --- | Checks whether the parser is directly after a string.-notAfterString :: JiraParser Bool-notAfterString = do+-- | Updates the state, marking the current input position as the end of a+-- string.+updateLastSpcPos :: JiraParser ()+updateLastSpcPos = do+  pos <- getPosition+  modifyState $ \st -> st { stateLastSpcPos = Just pos }++-- | Returns @'True'@ if the current parser position is directly+-- after a word/string. Returns @'False'@ if the parser is+-- looking at the first character of the input.+afterString :: JiraParser Bool+afterString = do   curPos <- getPosition   prevPos <- stateLastStrPos <$> getState-  return (Just curPos /= prevPos)+  return (Just curPos == prevPos)++-- | Returns true when the current parser position is either at+-- the beginning of the document or if the preceding characters+-- did not belong to a string.+notAfterString :: JiraParser Bool+notAfterString = not <$> afterString++-- | Returns @'True'@ iff the character before the current parser+-- position was a space.+afterSpace :: JiraParser Bool+afterSpace = do+  curPos <- getPosition+  lastSpacePos <- stateLastSpcPos <$> getState+  return (Just curPos == lastSpacePos)  -- | Parses a string with the given Jira parser. parseJira :: JiraParser a -> Text -> Either ParseError a
src/Text/Jira/Parser/Inline.hs view
@@ -77,11 +77,13 @@   choice [ void $ newline <* notFollowedBy' endOfPara          , void $ string "\\\\" <* notFollowedBy' (char '\\')          ]+    <* updateLastSpcPos   ) <?> "linebreak"  -- | Parses whitespace and return a @Space@ element. whitespace :: JiraParser Inline-whitespace = Space <$ skipMany1 (char ' ') <?> "whitespace"+whitespace = Space <$ skipMany1 (char ' ') <* updateLastSpcPos+  <?> "whitespace"  -- | Parses a simple, markup-less string into a @Str@ element. str :: JiraParser Inline@@ -265,5 +267,7 @@   guard =<< notAfterString   opening *> notFollowedBy space *> manyTill parser closing'   where-    closing' = try $ closing <* lookAhead wordBoundary+    closing' = try $ do+      guard . not =<< afterSpace+      closing <* lookAhead wordBoundary     wordBoundary = void (satisfy (not . isAlphaNum)) <|> eof
test/Text/Jira/Parser/BlockTests.hs view
@@ -263,6 +263,18 @@         parseJira table "| * foo\n- bar\n" @?=         Right (Table [Row [BodyCell [ List CircleBullets [[Para [Str "foo"]]]                                     , List SquareBullets [[Para [Str "bar"]]]]]])++      , testCase "empty cell in row" $+        parseJira table (Text.unlines+                         [ "|a|b|"+                         , "| |b|"+                         , "|a| |"+                         ]) @?=+        Right (Table+               [ Row [BodyCell [Para [Str "a"]], BodyCell [Para [Str "b"]]]+               , Row [BodyCell [],               BodyCell [Para [Str "b"]]]+               , Row [BodyCell [Para [Str "a"]], BodyCell []]+               ])       ]      , testGroup "code"
test/Text/Jira/Parser/InlineTests.hs view
@@ -135,6 +135,10 @@         parseJira styled "-far-fetched-" @?=         Right (Styled Strikeout [Str "far", SpecialChar '-', Str "fetched"]) +      , testCase "symbol before closing char" $+        parseJira styled "-backwards<-" @?=+        Right (Styled Strikeout [Str "backwards<"])+       , testGroup "emphasis"         [ testCase "single word" $           parseJira styled "_single_" @?= Right (Styled Emphasis [Str "single"])@@ -339,5 +343,11 @@             , SpecialChar '-', Str "3"             ] +    , testCase "ascii arrows" $+      -- the hypens used to be treated as deletion markers.+      parseJira (many1 inline) "-> step ->" @?=+      Right [ SpecialChar '-', Str ">" , Space, Str "step", Space+            , SpecialChar '-', Str ">"+            ]     ]   ]