mmark 0.0.6.0 → 0.0.6.1
raw patch · 12 files changed
+61/−53 lines, 12 filesdep −data-default-class
Dependencies removed: data-default-class
Files
- CHANGELOG.md +4/−0
- README.md +4/−4
- Text/MMark.hs +9/−8
- Text/MMark/Extension.hs +4/−5
- Text/MMark/Parser.hs +2/−3
- Text/MMark/Parser/Internal.hs +3/−4
- Text/MMark/Parser/Internal/Type.hs +27/−20
- Text/MMark/Render.hs +1/−1
- Text/MMark/Trans.hs +1/−1
- Text/MMark/Type.hs +1/−1
- Text/MMark/Util.hs +1/−1
- mmark.cabal +4/−5
CHANGELOG.md view
@@ -1,3 +1,7 @@+## MMark 0.0.6.1++* Dropped `data-default-class` dependency.+ ## MMark 0.0.6.0 * Uses Megaparsec 7. The `parse` function now returns `ParseErrorBundle` on
README.md view
@@ -18,7 +18,7 @@ MMark (read “em-mark”) is a strict markdown processor for writers. “Strict” means that not every input is considered valid markdown document and parse-errors are possible and even desirable, because they allow to spot markup+errors are possible and even desirable, because they allow us to spot markup issues without searching for them in rendered document. If a markdown document passes MMark parser, then it'll likely produce HTML without quirks. This feature makes it a good choice for writers and bloggers.@@ -71,7 +71,7 @@ MMark mostly tries to follow the Common Mark specification as given here: -http://spec.commonmark.org/0.28/+https://spec.commonmark.org/0.28/ However, due to the fact that we do not allow inputs that do not make sense, and also try to guard against common mistakes (like writing `##My header`@@ -298,10 +298,10 @@ Issues, bugs, and questions may be reported in [the GitHub issue tracker for this project](https://github.com/mmark-md/mmark/issues). -Pull requests are also welcome and will be reviewed quickly.+Pull requests are also welcome. ## License -Copyright © 2017–2018 Mark Karpov+Copyright © 2017–2019 Mark Karpov Distributed under BSD 3 clause license.
Text/MMark.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>@@ -9,9 +9,9 @@ -- -- MMark (read “em-mark”) is a strict markdown processor for writers. -- “Strict” means that not every input is considered valid markdown document--- and parse errors are possible and even desirable, because they allow to--- spot markup issues without searching for them in rendered document. If a--- markdown document passes MMark parser, then it'll likely produce HTML+-- and parse errors are possible and even desirable, because they allow us+-- to spot markup issues without searching for them in rendered document. If+-- a markdown document passes MMark parser, then it'll likely produce HTML -- without quirks. This feature makes it a good choice for writers and -- bloggers. --@@ -19,7 +19,7 @@ -- -- MMark mostly tries to follow the Common Mark specification as given here: ----- <http://spec.commonmark.org/0.28/>+-- <https://spec.commonmark.org/0.28/> -- -- However, due to the fact that we do not allow inputs that do not make -- sense, and also try to guard against common mistakes (like writing @##My@@ -75,13 +75,14 @@ -- > import qualified Data.Text.Lazy.IO as TL -- > import qualified Lucid as L -- > import qualified Text.MMark as MMark+-- > import qualified Text.Megaparsec as M -- > -- > main :: IO () -- > main = do -- > let input = "input.md" -- > txt <- T.readFile input -- (1) -- > case MMark.parse input txt of -- (2)--- > Left errs -> putStrLn (MMark.parseErrorsPretty txt errs) -- (3)+-- > Left bundle -> putStrLn (M.errorBundlePretty bundle) -- (3) -- > Right r -> TL.writeFile "output.html" -- (6) -- > . L.renderText -- (5) -- > . MMark.render -- (4)@@ -94,8 +95,8 @@ -- parsing. It can either fail with a collection of parse errors -- or succeed returning a value of the opaque 'MMark' type. -- 3. If parsing fails, we pretty-print the parse errors with--- 'parseErrorsPretty'.--- 4. Then we just render the document with `render` first to Lucid's+-- 'Text.Megaparsec.errorBundlePretty'.+-- 4. Then we just render the document with 'render' first to Lucid's -- @'Lucid.Html' ()@. -- 5. …and then to lazy 'Data.Text.Lazy.Text' with 'Lucid.renderText'. -- 6. Finally we write the result as @\"output.html\"@.
Text/MMark/Extension.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Extension--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>@@ -58,10 +58,9 @@ -- Another limitation by design is that extensions cannot change how the -- parser works. I find endless syntax-changing (or syntax-augmenting, if -- you will) extensions (as implemented by Pandoc for example) ugly, because--- they erode the core familiar markdown syntax and turn it into a--- monstrosity. In MMark we choose a different path of re-purposing existing--- markdown constructs, adding a special meaning to them in certain--- situations.+-- they erode the familiar markdown syntax and turn it into a monstrosity.+-- In MMark we choose a different path of re-purposing existing markdown+-- constructs, adding special meaning to them in certain situations. -- -- === Room for improvement --
Text/MMark/Parser.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Parser--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>@@ -82,8 +82,7 @@ -- Top-level API -- | Parse a markdown document in the form of a strict 'Text' value and--- either report parse errors or return an 'MMark' document. Note that the--- parser has the ability to report multiple parse errors at once.+-- either report parse errors or return an 'MMark' document. parse :: FilePath
Text/MMark/Parser/Internal.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Parser.Internal--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>@@ -42,7 +42,6 @@ import Control.Monad.State.Strict import Data.Bifunctor-import Data.Default.Class import Data.Function ((&)) import Data.HashMap.Strict (HashMap) import Data.Ratio ((%))@@ -76,7 +75,7 @@ -> Either (ParseErrorBundle Text MMarkErr) (a, Defs) -- ^ Result of parsing runBParser p file input =- case runState (snd <$> runParserT' p st) def of+ case runState (snd <$> runParserT' p st) initialBlockState of (Left bundle, _) -> Left bundle (Right x, st') -> Right (x, st' ^. bstDefs) where@@ -150,7 +149,7 @@ runIParser defs p (IspSpan offset input) = first (NE.head . bundleErrors) (snd (runParser' (evalStateT p ist) pst)) where- ist = def & istDefs .~ defs+ ist = initialInlineState & istDefs .~ defs pst = mkInitialState "" input offset -- | Disallow parsing of empty inlines.
Text/MMark/Parser/Internal/Type.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Parser.Internal.Type--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>@@ -18,11 +18,13 @@ module Text.MMark.Parser.Internal.Type ( -- * Block-level parser state BlockState+ , initialBlockState , bstAllowNaked , bstRefLevel , bstDefs -- * Inline-level parser state , InlineState+ , initialInlineState , istLastChar , istAllowEmpty , istAllowLinks@@ -43,7 +45,6 @@ import Control.DeepSeq import Data.CaseInsensitive (CI) import Data.Data (Data)-import Data.Default.Class import Data.HashMap.Strict (HashMap) import Data.Hashable (Hashable) import Data.List (intercalate)@@ -78,13 +79,15 @@ -- ^ Reference and footnote definitions } -instance Default BlockState where- def = BlockState- { _bstAllowNaked = False- , _bstRefLevel = pos1- , _bstDefs = def- }+-- | Initial value for 'BlockState'. +initialBlockState :: BlockState+initialBlockState = BlockState+ { _bstAllowNaked = False+ , _bstRefLevel = pos1+ , _bstDefs = emptyDefs+ }+ ---------------------------------------------------------------------------- -- Inline-level parser state @@ -103,15 +106,17 @@ -- ^ Reference link definitions } -instance Default InlineState where- def = InlineState- { _istLastChar = SpaceChar- , _istAllowEmpty = True- , _istAllowLinks = True- , _istAllowImages = True- , _istDefs = def- }+-- | Initial value for 'InlineState'. +initialInlineState :: InlineState+initialInlineState = InlineState+ { _istLastChar = SpaceChar+ , _istAllowEmpty = True+ , _istAllowLinks = True+ , _istAllowImages = True+ , _istDefs = emptyDefs+ }+ -- | 'Inline' source pending parsing. data Isp@@ -139,10 +144,12 @@ -- ^ Reference definitions containing a 'URI' and optionally title } -instance Default Defs where- def = Defs- { _referenceDefs = HM.empty- }+-- | Empty 'Defs'.++emptyDefs :: Defs+emptyDefs = Defs+ { _referenceDefs = HM.empty+ } -- | An opaque type for definition label.
Text/MMark/Render.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Render--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>
Text/MMark/Trans.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Trans--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>
Text/MMark/Type.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Type--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>
Text/MMark/Util.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.MMark.Util--- Copyright : © 2017–2018 Mark Karpov+-- Copyright : © 2017–2019 Mark Karpov -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov92@gmail.com>
mmark.cabal view
@@ -1,7 +1,7 @@ name: mmark-version: 0.0.6.0+version: 0.0.6.1 cabal-version: 1.18-tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3+tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.3 license: BSD3 license-file: LICENSE.md author: Mark Karpov <markkarpov92@gmail.com>@@ -30,8 +30,7 @@ build-depends: aeson >= 0.11 && < 1.5 , base >= 4.8 && < 5.0 , case-insensitive >= 1.2 && < 1.3- , containers >= 0.5 && < 0.6- , data-default-class+ , containers >= 0.5 && < 0.7 , deepseq >= 1.3 && < 1.5 , dlist >= 0.8 && < 0.9 , email-validate >= 2.2 && < 2.4@@ -48,7 +47,7 @@ , text >= 0.2 && < 1.3 , text-metrics >= 0.3 && < 0.4 , unordered-containers >= 0.2.5 && < 0.3- , yaml >= 0.8.10 && < 0.11+ , yaml >= 0.8.10 && < 0.12 if !impl(ghc >= 8.0) build-depends: semigroups == 0.18.* if !impl(ghc >= 7.10)