packages feed

commonmark-extensions 0.2.6 → 0.2.7

raw patch · 6 files changed

+136/−11 lines, 6 filesdep ~commonmarkPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: commonmark

API changes (from Hackage documentation)

- Commonmark.Extensions: gfmExtensions :: (Monad m, Typeable m, Typeable il, Typeable bl, IsBlock il bl, IsInline il, HasFootnote il bl, HasEmoji il, HasStrikethrough il, HasPipeTable il bl, HasTaskList il bl, ToPlainText il, HasAlerts il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions: gfmExtensions :: forall (m :: Type -> Type) il bl. (Monad m, Typeable m, Typeable il, Typeable bl, IsBlock il bl, IsInline il, HasFootnote il bl, HasEmoji il, HasStrikethrough il, HasPipeTable il bl, HasTaskList il bl, ToPlainText il, HasAlerts il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.Alerts: alertSpec :: (Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasAlerts il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.Alerts: alertSpec :: forall (m :: Type -> Type) il bl. (Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasAlerts il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.Attributes: attributesSpec :: (Monad m, IsInline il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Attributes: attributesSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsInline il) => SyntaxSpec m il bl
- Commonmark.Extensions.Attributes: bracketedSpanSpec :: (Monad m, IsInline il, HasSpan il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Attributes: bracketedSpanSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsInline il, HasSpan il) => SyntaxSpec m il bl
- Commonmark.Extensions.Attributes: fencedDivSpec :: (Monad m, IsInline il, IsBlock il bl, HasDiv bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.Attributes: fencedDivSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsInline il, IsBlock il bl, HasDiv bl) => SyntaxSpec m il bl
- Commonmark.Extensions.Attributes: pAttributes :: forall u m. Monad m => ParsecT [Tok] u m Attributes
+ Commonmark.Extensions.Attributes: pAttributes :: forall u (m :: Type -> Type). Monad m => ParsecT [Tok] u m Attributes
- Commonmark.Extensions.Attributes: rawAttributeSpec :: (Monad m, IsBlock il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.Attributes: rawAttributeSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.AutoIdentifiers: autoIdentifiersAsciiSpec :: (Monad m, IsBlock il bl, IsInline il, ToPlainText il) => SyntaxSpec m il bl
+ Commonmark.Extensions.AutoIdentifiers: autoIdentifiersAsciiSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, ToPlainText il) => SyntaxSpec m il bl
- Commonmark.Extensions.AutoIdentifiers: autoIdentifiersSpec :: (Monad m, IsBlock il bl, IsInline il, ToPlainText il) => SyntaxSpec m il bl
+ Commonmark.Extensions.AutoIdentifiers: autoIdentifiersSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, ToPlainText il) => SyntaxSpec m il bl
- Commonmark.Extensions.Autolink: autolinkSpec :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Autolink: autolinkSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
- Commonmark.Extensions.DefinitionList: definitionListSpec :: (Monad m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasDefinitionList il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.DefinitionList: definitionListSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasDefinitionList il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.Emoji: emojiSpec :: (Monad m, IsBlock il bl, IsInline il, HasEmoji il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Emoji: emojiSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasEmoji il) => SyntaxSpec m il bl
- Commonmark.Extensions.FancyList: fancyListSpec :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
+ Commonmark.Extensions.FancyList: fancyListSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
- Commonmark.Extensions.Footnote: footnoteSpec :: (Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasFootnote il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.Footnote: footnoteSpec :: forall (m :: Type -> Type) il bl. (Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il, Typeable bl, HasFootnote il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.HardLineBreaks: hardLineBreaksSpec :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
+ Commonmark.Extensions.HardLineBreaks: hardLineBreaksSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
- Commonmark.Extensions.ImplicitHeadingReferences: implicitHeadingReferencesSpec :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
+ Commonmark.Extensions.ImplicitHeadingReferences: implicitHeadingReferencesSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
- Commonmark.Extensions.Math: mathSpec :: (Monad m, IsBlock il bl, IsInline il, HasMath il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Math: mathSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasMath il) => SyntaxSpec m il bl
- Commonmark.Extensions.PipeTable: pipeTableSpec :: (Monad m, IsBlock il bl, IsInline il, HasPipeTable il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.PipeTable: pipeTableSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasPipeTable il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.RebaseRelativePaths: rebaseRelativePathsSpec :: forall m bl il. (Monad m, IsInline il, IsBlock il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.RebaseRelativePaths: rebaseRelativePathsSpec :: forall (m :: Type -> Type) bl il. (Monad m, IsInline il, IsBlock il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.Smart: smartPunctuationSpec :: (Monad m, IsBlock il bl, IsInline il, HasQuoted il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Smart: smartPunctuationSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasQuoted il) => SyntaxSpec m il bl
- Commonmark.Extensions.Strikethrough: strikethroughSpec :: (Monad m, IsBlock il bl, IsInline il, HasStrikethrough il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Strikethrough: strikethroughSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasStrikethrough il) => SyntaxSpec m il bl
- Commonmark.Extensions.Subscript: subscriptSpec :: (Monad m, IsBlock il bl, IsInline il, HasSubscript il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Subscript: subscriptSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasSubscript il) => SyntaxSpec m il bl
- Commonmark.Extensions.Superscript: superscriptSpec :: (Monad m, IsBlock il bl, IsInline il, HasSuperscript il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Superscript: superscriptSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasSuperscript il) => SyntaxSpec m il bl
- Commonmark.Extensions.TaskList: taskListSpec :: (Monad m, IsBlock il bl, IsInline il, HasTaskList il bl) => SyntaxSpec m il bl
+ Commonmark.Extensions.TaskList: taskListSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsBlock il bl, IsInline il, HasTaskList il bl) => SyntaxSpec m il bl
- Commonmark.Extensions.Wikilinks: wikilinksSpec :: (Monad m, IsInline il, HasWikilinks il) => TitlePosition -> SyntaxSpec m il bl
+ Commonmark.Extensions.Wikilinks: wikilinksSpec :: forall (m :: Type -> Type) il bl. (Monad m, IsInline il, HasWikilinks il) => TitlePosition -> SyntaxSpec m il bl

Files

changelog.md view
@@ -1,5 +1,25 @@ # Changelog for commonmark-extensions +## 0.2.7++  * Math extension: bail out on pathological nestings.+    This means we can't handle TeX math with more than 1000 levels of+    `{..}` nesting, but no real formula will go this far.++  * Math extension: do not allow math closer followed by digit (#167,+    Michael Howell). With this change, closing `$` cannot be+    followed by a decimal digit. For example, `$1$` is fine, but+    `$1$2` is not. This avoids some false positives like `Current+    conversion rate makes US$99 about A$137`.++  * Fix the blank line scanner after the `]` (Michael Howell).++  * Fix disagreement with GitHub about block nesting in tasklists+    (Michael Howell). Text on the same line as the task marker can't+    start a block. It has to be paragraph text.++  * Fix incorrectly computed indent on `task_list` (Michael Howell).+ ## 0.2.6    * Track wikilinks with a class instead of the title (Evan
commonmark-extensions.cabal view
@@ -1,5 +1,5 @@ name:           commonmark-extensions-version:        0.2.6+version:        0.2.7 synopsis:       Pure Haskell commonmark parser. description:    This library provides some useful extensions to core commonmark@@ -60,7 +60,7 @@     , transformers     , filepath     , network-uri-    , commonmark >= 0.2.4.1 && < 0.3+    , commonmark >= 0.2.4.1 && < 0.4     -- for extensions:     , emojis >= 0.1.4.1 && < 0.2   exposed-modules:@@ -101,7 +101,7 @@   ghc-options: -threaded -rtsopts -with-rtsopts=-K40K   build-depends:       base >= 4.9 && <5-    , commonmark >= 0.2.4.1 && < 0.3+    , commonmark >= 0.2.4.1 && < 0.4     , commonmark-extensions     , text     , tasty@@ -114,7 +114,7 @@   main-is:         benchmark.hs   hs-source-dirs:  benchmark   build-depends:-       commonmark >= 0.2.4.1 && < 0.3+       commonmark >= 0.2.4.1 && < 0.4      , commonmark-extensions      , base >= 4.9 && < 5      , text
src/Commonmark/Extensions/Math.hs view
@@ -4,7 +4,7 @@   ( HasMath(..)   , mathSpec ) where-import Control.Monad (mzero)+import Control.Monad (guard, mzero) import Commonmark.Types import Commonmark.Tokens import Commonmark.Syntax@@ -15,6 +15,7 @@ import Text.Parsec import Data.Text (Text) import qualified Data.Text as T+import Data.Char (isDigit)  mathSpec :: (Monad m, IsBlock il bl, IsInline il, HasMath il)          => SyntaxSpec m il bl@@ -44,14 +45,20 @@   let isWs c = c == ' ' || c == '\t' || c == '\r' || c == '\n'   if display      then displayMath contents <$ symbol '$'-     else if T.null contents || isWs (T.last contents)-             -- don't allow math to end with SPACE + $-             then mzero-             else return $ inlineMath contents+     else do+             -- don't allow empty inline math+             guard $ not $ T.null contents+             -- don't allow inline math to end with SPACE + $+             guard $ not $ isWs $ T.last contents+             -- don't allow the closer followed by numbers ($5)+             let startsWithDigit = maybe False (isDigit . fst) . T.uncons+             notFollowedBy $ satisfyWord startsWithDigit+             pure $ inlineMath contents  -- Int is number of embedded groupings pDollarsMath :: Monad m => Int -> InlineParser m [Tok] pDollarsMath n = do+  guard (n <= 1000) -- bail on pathological inputs   tk@(Tok toktype _ _) <- anyTok   case toktype of        Symbol '$'
src/Commonmark/Extensions/TaskList.hs view
@@ -133,6 +133,17 @@                                listItemType lidata                     -> addNodeToStack linode                   _ -> addNodeToStack listnode >> addNodeToStack linode+             blankAfterMarker <- optionMaybe blankLine+             pos' <- getPosition+             case blankAfterMarker of+                  Just _ -> return ()+                  Nothing -> do+                    toks <- many (satisfyTok (not . hasType LineEnd))+                    addNodeToStack $+                        Node (defBlockData paraSpec){+                              blockStartPos = [pos']+                            , blockLines = [toks] }+                        []              return BlockStartMatch      , blockCanContain     = const True      , blockContainsLines  = False@@ -184,11 +195,11 @@   pos <- getPosition   ty <- bulletListMarker   aftercol <- sourceColumn <$> getPosition-  checked <- parseCheckbox   lookAhead whitespace   numspaces <- try (gobbleUpToSpaces 4 <* notFollowedBy whitespace)            <|> gobbleSpaces 1-           <|> 1 <$ lookAhead lineEnd+  checked <- parseCheckbox+  lookAhead whitespace   return $! (pos, ListItemData{             listItemType = ty           , listItemChecked = checked
test/math.md view
@@ -87,3 +87,27 @@ . <p><span class="math inline">\(b&lt;a&gt;c\)</span></p> ````````````````````````````````++The inline math closer cannot be immediately followed by a digit.+The opener can be, though.+Display math isn't subject to this rule.+```````````````````````````````` example+$1$2$3++$1$2$3$++$1{$2$}3$++$$1$$2$$3++$$1$$2$$3$$++$$1{$$2$$}3$$+.+<p>$1$2$3</p>+<p>$1$2<span class="math inline">\(3\)</span></p>+<p><span class="math inline">\(1{$2$}3\)</span></p>+<p><span class="math display">\[1\]</span>2$$3</p>+<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>+````````````````````````````````
test/task_lists.md view
@@ -28,3 +28,66 @@ </ul> ```````````````````````````````` ++```````````````````````````````` example+- [x]unreal+.+<ul>+<li>[x]unreal</li>+</ul>+````````````````````````````````+++```````````````````````````````` example+-  [x] real++  not indented enough+.+<ul class="task-list">+<li><input type="checkbox" disabled="" checked="" />real</li>+</ul>+<p>not indented enough</p>+````````````````````````````````+++```````````````````````````````` example+- [x] * some text+- [ ] > some text+- [x]+  * some text+- [ ]+  > some text+.+<ul class="task-list">+<li><input type="checkbox" disabled="" checked="" />* some text</li>+<li><input type="checkbox" disabled="" />&gt; some text</li>+<li><input type="checkbox" disabled="" checked="" /><ul>+<li>some text</li>+</ul></li>+<li><input type="checkbox" disabled="" /><blockquote>+<p>some text</p>+</blockquote></li>+</ul>+````````````````````````````````++There is no empty paragraph after the `]`.++```````````````````````````````` example+- [x] * some text++- [x]++  some text++- [x]→++  some text+.+<ul class="task-list">+<li><input type="checkbox" disabled="" checked="" /><p>* some text</p></li>+<li><input type="checkbox" disabled="" checked="" /><p>some text</p>+</li>+<li><input type="checkbox" disabled="" checked="" /><p>some text</p>+</li>+</ul>+````````````````````````````````