commonmark-extensions 0.2.7.3 → 0.2.8
raw patch · 8 files changed
+253/−1 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +27/−0
- commonmark-extensions.cabal +1/−1
- src/Commonmark/Extensions/Footnote.hs +18/−0
- src/Commonmark/Extensions/Math.hs +5/−0
- test/fancy_lists.md +12/−0
- test/math.md +171/−0
- test/strikethrough.md +15/−0
- test/test-commonmark-extensions.hs +4/−0
changelog.md view
@@ -1,5 +1,32 @@ # Changelog for commonmark-extensions +## 0.2.8++ * Footnotes: don't add footnote list twice.+ If footnoteSpec was included more than once in a SyntaxSpec+ (e.g. `gfmExtensions <> footnoteSpec`, or `-x gfm -x footnotes`+ on the command line), the addFootnoteList final parser ran more+ than once, re-rendering every note and emitting a second+ footnotes section. We now record in `counters` that the list has+ been added and make subsequent runs no-ops.++ * Replace duplicate block specs in place (#180). When several+ block specs have the same blockType,+ removeDuplicateBlockSpecs still keeps the first, but now puts+ it in the position of the last. So an extension that+ overrides a default spec (e.g. fancy_lists' ListItem) takes+ the default's slot, instead of moving ahead of other+ extensions' specs and of the remaining default specs. This+ makes task_lists work regardless of whether it is combined+ before or after fancy_lists, and it fixes thematic breaks+ like `* * *` being parsed as nested lists when fancy_lists is+ enabled.++ * `delimsMatch`: disallow match for 1-length delims when there is+ no single-delim contsructor defined (e.g., with strikeout) (#181).++ * Math: respect TeX percent comments (Erik Demaine).+ ## 0.2.7.3 * Depend on commonmark 0.3.1, for the `getPrecedingTokType` export.
commonmark-extensions.cabal view
@@ -1,5 +1,5 @@ name: commonmark-extensions-version: 0.2.7.3+version: 0.2.8 synopsis: Pure Haskell commonmark parser. description: This library provides some useful extensions to core commonmark
src/Commonmark/Extensions/Footnote.hs view
@@ -172,6 +172,24 @@ (Monad m, Typeable m, Typeable bl, HasFootnote il bl, IsBlock il bl) => BlockParser m il bl bl addFootnoteList = do+ -- If footnoteSpec is included more than once in a SyntaxSpec,+ -- this final parser will run more than once; only the first run+ -- should produce a footnote list.+ alreadyAdded <- M.member footnoteListKey . counters <$> getState+ if alreadyAdded+ then return mempty+ else do+ updateState $ \s -> s{ counters = M.insert footnoteListKey+ (toDyn ()) (counters s) }+ addFootnoteList'++footnoteListKey :: Text+footnoteListKey = "footnote:listAdded"++addFootnoteList' :: forall m il bl.+ (Monad m, Typeable m, Typeable bl, HasFootnote il bl,+ IsBlock il bl) => BlockParser m il bl bl+addFootnoteList' = do rm <- referenceMap <$> getState let keys = M.keys . unReferenceMap $ rm let getNote key = lookupReference key rm :: Maybe (FootnoteDef bl m)
src/Commonmark/Extensions/Math.hs view
@@ -73,6 +73,11 @@ Symbol '\\' -> do tk' <- anyTok (tk :) . (tk' :) <$> pDollarsMath display n+ Symbol '%' -> do+ -- Preserve comments, including the newline, without interpreting+ -- their braces, dollars, or backslashes.+ comment <- restOfLine+ (tk :) . (comment ++) <$> pDollarsMath display n Symbol '{' -> (tk :) <$> pDollarsMath display (n+1) Symbol '}' | n > 0 -> (tk :) <$> pDollarsMath display (n-1) | otherwise -> mzero
test/fancy_lists.md view
@@ -296,3 +296,15 @@ <li>a list</li> </ol> ````````````````````````````````++Thematic breaks take precedence over list items, as in+standard commonmark (#180):++```````````````````````````````` example+* * *++- - -+.+<hr />+<hr />+````````````````````````````````
test/math.md view
@@ -120,3 +120,174 @@ <p><span class="math display">\[1\]</span>2<span class="math display">\[3\]</span></p> <p><span class="math display">\[1{$$2$$}3\]</span></p> ````````````````````````````````++## TeX comments++Unescaped percent signs start comments through the next newline.+Comment text is preserved, but its braces and dollars do not affect+math boundaries. Escaped percent signs stay literal, and backslashes+inside comments do not escape the newline.++```````````````````````````````` example+$a%$ ignored++b$+.+<p><span class="math inline">\(a%$ ignored++b\)</span></p>+````````````````````````````````++```````````````````````````````` example+${a%} $+b}$+.+<p><span class="math inline">\({a%} $+b}\)</span></p>+````````````````````````````````++```````````````````````````````` example+${a%{+b}$+.+<p><span class="math inline">\({a%{+b}\)</span></p>+````````````````````````````````++```````````````````````````````` example+$a\%$+.+<p><span class="math inline">\(a\%\)</span></p>+````````````````````````````````++```````````````````````````````` example+${a\%}$+.+<p><span class="math inline">\({a\%}\)</span></p>+````````````````````````````````++```````````````````````````````` example+$a\%{b$c$}$+.+<p><span class="math inline">\(a\%{b$c$}\)</span></p>+````````````````````````````````++```````````````````````````````` example+$a\\%$+b$+.+<p><span class="math inline">\(a\\%$+b\)</span></p>+````````````````````````````````++```````````````````````````````` example+${a\\%}+b}$+.+<p><span class="math inline">\({a\\%}+b}\)</span></p>+````````````````````````````````++```````````````````````````````` example+$a\\\%$+.+<p><span class="math inline">\(a\\\%\)</span></p>+````````````````````````````````++```````````````````````````````` example+$a%+% } $ \+b$+.+<p><span class="math inline">\(a%+% } $ \+b\)</span></p>+````````````````````````````````++A delimiter inside a final comment cannot close the equation.++```````````````````````````````` example+$a%$+.+<p>$a%$</p>+````````````````````````````````++```````````````````````````````` example+$$a%$$ ignored++b$$+.+<p><span class="math display">\[a%$$ ignored++b\]</span></p>+````````````````````````````````++```````````````````````````````` example+$${a%} $$+b}$$+.+<p><span class="math display">\[{a%} $$+b}\]</span></p>+````````````````````````````````++```````````````````````````````` example+$${a%{+b}$$+.+<p><span class="math display">\[{a%{+b}\]</span></p>+````````````````````````````````++```````````````````````````````` example+$$a\%$$+.+<p><span class="math display">\[a\%\]</span></p>+````````````````````````````````++```````````````````````````````` example+$${a\%}$$+.+<p><span class="math display">\[{a\%}\]</span></p>+````````````````````````````````++```````````````````````````````` example+$$a\%{b$$c$$}$$+.+<p><span class="math display">\[a\%{b$$c$$}\]</span></p>+````````````````````````````````++```````````````````````````````` example+$$a\\%$$+b$$+.+<p><span class="math display">\[a\\%$$+b\]</span></p>+````````````````````````````````++```````````````````````````````` example+$${a\\%}+b}$$+.+<p><span class="math display">\[{a\\%}+b}\]</span></p>+````````````````````````````````++```````````````````````````````` example+$$a\\\%$$+.+<p><span class="math display">\[a\\\%\]</span></p>+````````````````````````````````++```````````````````````````````` example+$$a%+% } $$ \+b$$+.+<p><span class="math display">\[a%+% } $$ \+b\]</span></p>+````````````````````````````````++A delimiter inside a final comment cannot close the equation.++```````````````````````````````` example+$$a%$$+.+<p>$$a%$$</p>+````````````````````````````````
test/strikethrough.md view
@@ -48,3 +48,18 @@ ```````````````````````````````` ++Single tildes that can't produce strikethrough should not+swallow intervening delimiters (#181):++```````````````````````````````` example+~4 **~75 GB.**+.+<p>~4 <strong>~75 GB.</strong></p>+````````````````````````````````++```````````````````````````````` example+~~a~ ~b~~+.+<p><del>a~ ~b</del></p>+````````````````````````````````
test/test-commonmark-extensions.hs view
@@ -34,12 +34,16 @@ , ("test/subscript.md", subscriptSpec) , ("test/pipe_tables.md", pipeTableSpec) , ("test/footnotes.md", footnoteSpec)+ -- including the extension twice should be harmless:+ , ("test/footnotes.md", footnoteSpec <> footnoteSpec) , ("test/math.md", mathSpec) , ("test/emoji.md", emojiSpec) , ("test/autolinks.md", autolinkSpec) , ("test/definition_lists.md", definitionListSpec) , ("test/fancy_lists.md", fancyListSpec) , ("test/task_lists.md", taskListSpec)+ -- order should not matter (#180):+ , ("test/task_lists.md", fancyListSpec <> taskListSpec) , ("test/attributes.md", attributesSpec) , ("test/raw_attribute.md", rawAttributeSpec) , ("test/bracketed_spans.md", bracketedSpanSpec)