commonmark-extensions 0.1.0.0 → 0.2.0.0
raw patch · 5 files changed
+51/−13 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Commonmark.Extensions.Smart: class IsInline il => HasQuoted il
+ Commonmark.Extensions.Smart: doubleQuoted :: HasQuoted il => il -> il
+ Commonmark.Extensions.Smart: instance (Commonmark.Extensions.Smart.HasQuoted i, GHC.Base.Monoid i, GHC.Base.Semigroup i) => Commonmark.Extensions.Smart.HasQuoted (Commonmark.SourceMap.WithSourceMap i)
+ Commonmark.Extensions.Smart: instance Commonmark.Types.Rangeable (Commonmark.Html.Html a) => Commonmark.Extensions.Smart.HasQuoted (Commonmark.Html.Html a)
+ Commonmark.Extensions.Smart: singleQuoted :: HasQuoted il => il -> il
- Commonmark.Extensions.Smart: smartPunctuationSpec :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl
+ Commonmark.Extensions.Smart: smartPunctuationSpec :: (Monad m, IsBlock il bl, IsInline il, HasQuoted il) => SyntaxSpec m il bl
Files
- README.md +2/−0
- changelog.md +19/−1
- commonmark-extensions.cabal +1/−1
- src/Commonmark/Extensions/PipeTable.hs +5/−0
- src/Commonmark/Extensions/Smart.hs +24/−11
README.md view
@@ -1,5 +1,7 @@ # commonmark-extensions +[](http://hackage.haskell.org/package/commonmark-extensions)+ This package provides some syntax extensions for the commonmark package:
changelog.md view
@@ -1,3 +1,21 @@ # Changelog for commonmark-extensions -## Unreleased changes+## 0.2.0.0++- Add HasQuoted class in Smart extension, with singleQuoted+ and doubleQuoted methods. This gives more fleibility in+ supporting smart quotes, and allows us to use pandoc's+ Quoted elements.++- Add advice to haddocks for pipeTableSpec (#52).+ If a line could be a candidate pipe table heading, but the+ following line of separators is not encountered, the line is+ treated as a paragraph, even if it has indications of other+ block-level formatting. Putting the pipeTableSpec AFTER+ parsers for lists, headings, etc. causes the latter to take+ priority.+++## 0.1.0.0++- Initial release
commonmark-extensions.cabal view
@@ -1,5 +1,5 @@ name: commonmark-extensions-version: 0.1.0.0+version: 0.2.0.0 synopsis: Pure Haskell commonmark parser. description: This library provides some useful extensions to core commonmark
src/Commonmark/Extensions/PipeTable.hs view
@@ -128,6 +128,11 @@ skipMany $ satisfyTok (hasType Spaces) return $! align +-- | Syntax for pipe tables. Note that this should generally be+-- placed AFTER the syntax spec for lists, headings, and other block-level+-- constructs, to avoid bad results when non-table lines contain pipe+-- characters: use @defaultSyntaxSpec <> pipeTableSpec@ rather+-- than @pipeTableSpec <> defaultSyntaxSpec@. pipeTableSpec :: (Monad m, IsBlock il bl, IsInline il, HasPipeTable il bl) => SyntaxSpec m il bl pipeTableSpec = mempty
src/Commonmark/Extensions/Smart.hs view
@@ -1,36 +1,49 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-} module Commonmark.Extensions.Smart- ( smartPunctuationSpec )+ ( HasQuoted(..)+ , smartPunctuationSpec ) where import Commonmark.Types import Commonmark.Syntax import Commonmark.Inlines+import Commonmark.Html+import Commonmark.SourceMap import Commonmark.TokParsers (symbol) import Text.Parsec #if !MIN_VERSION_base(4,11,0)-import Data.Monoid+import Data.Monoid (Monoid)+import Data.Semigroup (Semigroup, (<>)) #endif -smartPunctuationSpec :: (Monad m, IsBlock il bl, IsInline il)+class IsInline il => HasQuoted il where+ singleQuoted :: il -> il+ doubleQuoted :: il -> il++instance Rangeable (Html a) => HasQuoted (Html a) where+ singleQuoted x = htmlText "‘" <> x <> htmlText "’"+ doubleQuoted x = htmlText "“" <> x <> htmlText "”"++instance (HasQuoted i, Monoid i, Semigroup i)+ => HasQuoted (WithSourceMap i) where+ singleQuoted x = (singleQuoted <$> x) <* addName "singleQuoted"+ doubleQuoted x = (doubleQuoted <$> x) <* addName "doubleQuoted"++smartPunctuationSpec :: (Monad m, IsBlock il bl, IsInline il, HasQuoted il) => SyntaxSpec m il bl smartPunctuationSpec = mempty { syntaxFormattingSpecs = [singleQuotedSpec, doubleQuotedSpec] , syntaxInlineParsers = [pEllipses, pDash] } -singleQuotedSpec :: IsInline il => FormattingSpec il+singleQuotedSpec :: (IsInline il, HasQuoted il) => FormattingSpec il singleQuotedSpec = FormattingSpec '\'' False False (Just singleQuoted) Nothing '’' -doubleQuotedSpec :: IsInline il => FormattingSpec il+doubleQuotedSpec :: (IsInline il, HasQuoted il) => FormattingSpec il doubleQuotedSpec = FormattingSpec '"' False False (Just doubleQuoted) Nothing '“'--singleQuoted :: IsInline il => il -> il-singleQuoted x = str "‘" <> x <> str "’"--doubleQuoted :: IsInline il => il -> il-doubleQuoted x = str "“" <> x <> str "”" pEllipses :: (Monad m, IsInline a) => InlineParser m a pEllipses = try $ do