jira-wiki-markup 1.1.0 → 1.1.1
raw patch · 4 files changed
+41/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +15/−1
- jira-wiki-markup.cabal +1/−1
- src/Text/Jira/Parser/Inline.hs +9/−7
- test/Text/Jira/Parser/InlineTests.hs +16/−3
CHANGELOG.md view
@@ -3,6 +3,20 @@ `jira-wiki-markup` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +1.1.1+=====++Released 2020-03-18++* Colon `:` and semicolon `;` are now parsed as special+ characters, since they can be the first characters of an emoji.+* Fixed parsing of words which contain non-special symbol+ characters: word boundaries were not set correctly if a word+ contained a dot `.` or similar chars.+* Fixed incorrect emphasis parsing: digits were erroneously+ allows as the first characters after closing emphasis+ characters.+ 1.1.0 ===== @@ -29,7 +43,7 @@ - blocks of colored text are parsed as `Color`; - interpretation of special characters as markup can be forced by surrounding them with curly braces.-* A parser `plainText` was added available to read markup-less text.+* A parser `plainText` was made available to read markup-less text. * *Inline*-parser `symbol` was renamed to `specialChar`. * Add printer module to render the document AST as Jira markup. * Markup datatype changes:
jira-wiki-markup.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: jira-wiki-markup-version: 1.1.0+version: 1.1.1 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/Inline.hs view
@@ -34,7 +34,7 @@ ) where import Control.Monad (guard, void)-import Data.Char (isLetter, isPunctuation, ord)+import Data.Char (isAlphaNum, isPunctuation, ord) #if !MIN_VERSION_base(4,13,0) import Data.Monoid ((<>), All (..)) #else@@ -69,7 +69,7 @@ -- | Characters which, depending on context, can have a special meaning. specialChars :: String-specialChars = "_+-*^~|[]{}(!&\\"+specialChars = "_+-*^~|[]{}(!&\\:;" -- | Parses an in-paragraph newline as a @Linebreak@ element. Both newline -- characters and double-backslash are recognized as line-breaks.@@ -86,12 +86,14 @@ -- | Parses a simple, markup-less string into a @Str@ element. str :: JiraParser Inline-str = Str . pack <$> (alphaNums <|> otherNonSpecialChars) <?> "string"+str = Str . pack . mconcat+ <$> many1 (alphaNums <|> otherNonSpecialChars)+ <?> "string" where nonStrChars = " \n" ++ specialChars alphaNums = many1 alphaNum <* updateLastStrPos- otherNonSpecialChars = many1 (noneOf nonStrChars)-+ otherNonSpecialChars = many1 . satisfy $ \c ->+ not (isAlphaNum c || c `elem` nonStrChars) -- | Parses an HTML entity into an @'Entity'@ element. entity :: JiraParser Inline@@ -203,7 +205,7 @@ return $ ColorInline (ColorName $ pack name) content where colorName = many1 letter- colorCode = (:) <$> (option '#' (char '#')) <*> count 6 digit+ colorCode = (:) <$> option '#' (char '#') <*> count 6 digit -- -- Markup@@ -259,4 +261,4 @@ opening *> notFollowedBy space *> manyTill parser closing' where closing' = try $ closing <* lookAhead wordBoundary- wordBoundary = void (satisfy (not . isLetter)) <|> eof+ wordBoundary = void (satisfy (not . isAlphaNum)) <|> eof
test/Text/Jira/Parser/InlineTests.hs view
@@ -29,11 +29,14 @@ parseJira str "word" @?= Right (Str "word") , testCase "non-special symbols" $- parseJira str ",.;#%" @?= Right (Str ",.;#%")+ parseJira str ",.#%" @?= Right (Str ",.#%") , testCase "umlauts" $ parseJira str "äéíöüßðå" @?= Right (Str "äéíöüßðå") + , testCase "mix of alphanums and non-special chars" $+ parseJira str "20.09" @?= Right (Str "20.09")+ , testCase "space fails" $ isLeft (parseJira str " ") @? "str should only be parsed into Space"@@ -283,7 +286,8 @@ , testCase "backslash-escaped char" $ parseJira (normalizeInlines <$> many1 inline) "opening brace: \\{" @?=- Right [Str "opening", Space, Str "brace:", Space, SpecialChar '{']+ Right [ Str "opening", Space, Str "brace", SpecialChar ':', Space+ , SpecialChar '{'] , testCase "icon after word" $ parseJira (many1 inline) "checkmark(/)" @?=@@ -299,7 +303,8 @@ , testCase "smiley between words" $ parseJira (normalizeInlines <$> many1 inline) "verdict: :D funny" @?=- Right [Str "verdict:", Space, Emoji IconSmiling, Space, Str "funny"]+ Right [ Str "verdict", SpecialChar ':', Space+ , Emoji IconSmiling, Space, Str "funny"] , testCase "dash with spaces" $ parseJira (many1 inline) "one -- two" @?=@@ -315,5 +320,13 @@ , ColorInline (ColorName "red") [Str "red"] , Str "." ]++ , testCase "hypen between numbers" $+ -- the hypens used to be treated as deletion markers.+ parseJira (many1 inline) "-15 02-3" @?=+ Right [ SpecialChar '-', Str "15" , Space, Str "02"+ , SpecialChar '-', Str "3"+ ]+ ] ]