commonmark 0.2.4 → 0.2.4.1
raw patch · 6 files changed
+148/−11 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +20/−0
- commonmark.cabal +3/−3
- src/Commonmark/Blocks.hs +11/−3
- src/Commonmark/Html.hs +3/−0
- src/Commonmark/Inlines.hs +23/−5
- test/regression.md +88/−0
changelog.md view
@@ -1,5 +1,25 @@ # Changelog for commonmark +## 0.2.4.1++ * Commonmark.Html: Add `aria-hidden`, `d`, and `viewBox` to allowed attributes list.++ * Correctly merge list blanks with non-list blanks (#133, Michael Howell).++ * Do not look for backslashed hard breaks in link titles (#130, Michael Howell).++ * Work around ghc bug with `-K` RTS options, to set the stack space properly+ for tests (#129). See https://gitlab.haskell.org/ghc/ghc/-/issues/10445.++ * Revert block state completely if lazy line (#126). This fixes an issue with+ lazily-wrapped footnotes.++ * Avoid adding trailing newline to list block if it's already there+ (Michael Howell). This fixes tight/loose classification in a few+ cases.++ * Fix incorrectly parsing links with nested `[]` (Michael Howell).+ ## 0.2.4 * Do not parse hard line breaks in fenced codeblock info (#116,
commonmark.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: commonmark-version: 0.2.4+version: 0.2.4.1 synopsis: Pure Haskell commonmark parser. description: This library provides the core data types and functions@@ -89,7 +89,7 @@ main-is: test-commonmark.hs hs-source-dirs: test- ghc-options: -threaded -rtsopts -with-rtsopts=-K40K+ ghc-options: -threaded -rtsopts -with-rtsopts=-K40K -with-rtsopts=-kc40K if impl(ghc >= 8.10) ghc-options: -Wunused-packages build-depends:@@ -112,7 +112,7 @@ , base >= 4.9 && < 5 , text , tasty-bench- ghc-options: -threaded -rtsopts -with-rtsopts=-K10K+ ghc-options: -threaded -rtsopts -with-rtsopts=-K10K -with-rtsopts=-kc10K if impl(ghc >= 8.10) ghc-options: -Wunused-packages default-language: Haskell2010
src/Commonmark/Blocks.hs view
@@ -70,6 +70,7 @@ import qualified Data.Text.Read as TR import Data.Tree import Text.Parsec+import Data.List (sort) mkBlockParser :: (Monad m, IsBlock il bl)@@ -135,6 +136,8 @@ _ -> False } -- close unmatched blocks+ -- but first save state so we can revert if we have a lazy line+ revertState <- getState if null unmatched then updateState $ \st -> st{ nodeStack = matched } -- this update is needed or we lose startpos information@@ -153,8 +156,9 @@ (do getState >>= guard . maybeLazy -- lazy line sp <- getPosition+ updateState $ const revertState updateState $ \st -> st{ nodeStack =- map (addStartPos sp) (unmatched ++ matched) })+ map (addStartPos sp) (nodeStack st) }) <|> void (try (blockStart paraSpec)) <|>@@ -862,7 +866,7 @@ let lidata = fromDyn (blockData cdata) (ListItemData (BulletList '*') 0 False False)- let allblanks = concat $ blockBlanks cdata :+ let allblanks = reverse . sort . concat $ blockBlanks cdata : map (blockBlanks . rootLabel) (filter ((== "List") . blockType . blockSpec . rootLabel) children)@@ -940,7 +944,11 @@ blockBlanks' <- case childrenData of c:_ | listItemBlanksAtEnd c -> do curline <- sourceLine <$> getPosition- return $! curline - 1 : blockBlanks cdata+ return $! case blockBlanks cdata of+ lb:b | lb == curline - 1 ->+ lb:b+ b ->+ curline - 1 : b _ -> return $! blockBlanks cdata let ldata' = toDyn (ListData lt ls) -- need to transform paragraphs on tight lists
src/Commonmark/Html.hs view
@@ -207,6 +207,7 @@ , "allowpaymentrequest" , "allowusermedia" , "alt"+ , "aria-hidden" , "as" , "async" , "autocapitalize"@@ -225,6 +226,7 @@ , "controls" , "coords" , "crossorigin"+ , "d" , "data" , "datetime" , "decoding"@@ -405,6 +407,7 @@ , "updateviacache" , "usemap" , "value"+ , "viewBox" , "width" , "workertype" , "wrap"
src/Commonmark/Inlines.hs view
@@ -686,6 +686,14 @@ opents /= closets delimsMatch _ _ = False +-- check for balanced `[]` brackets+bracketChunkToNumber :: Chunk a -> Int+bracketChunkToNumber (Chunk Delim{ delimType = '[' } _ _) = 1+bracketChunkToNumber (Chunk Delim{ delimType = ']' } _ _) = -1+bracketChunkToNumber _ = 0+bracketMatchedCount :: [Chunk a] -> Int+bracketMatchedCount chunksinside = sum $ map bracketChunkToNumber chunksinside+ processBrackets :: IsInline a => [BracketedSpec a] -> ReferenceMap -> [Chunk a] -> [Chunk a] processBrackets bracketedSpecs rm xs =@@ -783,7 +791,7 @@ suffixPos = incSourceColumn closePos 1 - in case parse+ in case (bracketMatchedCount chunksinside, parse (withRaw (do setPosition suffixPos (spec, constructor) <- choice $@@ -791,13 +799,13 @@ specs pos <- getPosition return (spec, constructor, pos)))- "" suffixToks of- Left _ -> -- match but no link/image+ "" suffixToks) of+ (0, Left _) -> -- match but no link/image processBs bracketedSpecs st{ leftCursor = moveLeft (leftCursor st) , rightCursor = fixSingleQuote $ moveRight (rightCursor st) }- Right ((spec, constructor, newpos), desttoks) ->+ (0, Right ((spec, constructor, newpos), desttoks)) -> let left' = case bracketedPrefix spec of Just _ -> moveLeft left Nothing -> left@@ -854,6 +862,16 @@ (chunkPos opener) $ stackBottoms st }+ -- Bracket matched count /= 0+ --+ -- Links § 6.3 ¶ 2 • 2+ -- Brackets are allowed in the link text only if (a) they are+ -- backslash-escaped or (b) they appear as a matched pair of+ -- brackets, with an open bracket [, a sequence of zero or more+ -- inlines, and a close bracket ].+ _ ->+ processBs bracketedSpecs+ st{ leftCursor = moveLeft left } (_, Just (Chunk Delim{ delimType = ']' } _ _))@@ -954,7 +972,7 @@ inbetween :: Monad m => Char -> Char -> ParsecT [Tok] s m [Tok] inbetween op cl = try $ between (symbol op) (symbol cl)- (many (pEscaped <|> noneOfToks [Symbol op, Symbol cl]))+ (many (pEscapedSymbol <|> noneOfToks [Symbol op, Symbol cl])) pLinkLabel :: Monad m => ParsecT [Tok] s m Text pLinkLabel = try $ do
test/regression.md view
@@ -219,3 +219,91 @@ <pre><code class="language-\">x </code></pre> ````````````````````````````````++Issue #119+```````````````````````````````` example+[[]](https://haskell.org)++[[][]](https://haskell.org)++[[[][]](https://haskell.org)++[[][][]](https://haskell.org)+.+<p><a href="https://haskell.org">[]</a></p>+<p><a href="https://haskell.org">[][]</a></p>+<p>[<a href="https://haskell.org">[][]</a></p>+<p><a href="https://haskell.org">[][][]</a></p>+````````````````````````````````++Issue #122+```````````````````````````````` example+* x+* -+++Test+.+<ul>+<li>x</li>+<li><ul>+<li></li>+</ul></li>+</ul>+<p>Test</p>+````````````````````````````````++Issue #130+```````````````````````````````` example+[my-link]: https://example.com "\+"+[my-link]+.+<p><a href="https://example.com" title="\+">my-link</a></p>+````````````````````````````````++```````````````````````````````` example+[my-link](https://example.com "\+")+.+<p><a href="https://example.com" title="\+">my-link</a></p>+````````````````````````````````+++Issue #133+```````````````````````````````` example+ * * xx++ * yy++ zz+.+<ul>+<li><ul>+<li><p>xx</p>+<ul>+<li>yy</li>+</ul></li>+</ul>+<p>zz</p></li>+</ul>+````````````````````````````````++```````````````````````````````` example+ * * xx+ * yy++ zz+.+<ul>+<li><ul>+<li>xx+<ul>+<li>yy</li>+</ul></li>+</ul>+<p>zz</p></li>+</ul>+````````````````````````````````