mmark 0.0.7.3 → 0.0.7.4
raw patch · 10 files changed
+59/−54 lines, 10 filesdep ~hashabledep ~luciddep ~text
Dependency ranges changed: hashable, lucid, text
Files
- CHANGELOG.md +4/−0
- README.md +12/−11
- Text/MMark.hs +3/−3
- Text/MMark/Extension.hs +3/−3
- Text/MMark/Parser.hs +1/−1
- Text/MMark/Parser/Internal.hs +3/−3
- Text/MMark/Parser/Internal/Type.hs +2/−2
- mmark.cabal +7/−7
- tests/Text/MMark/TestUtils.hs +2/−2
- tests/Text/MMarkSpec.hs +22/−22
CHANGELOG.md view
@@ -1,3 +1,7 @@+## MMark 0.0.7.4++* The test suite has been fixed again and for good.+ ## MMark 0.0.7.3 * The test suite passes with `modern-uri-0.3.4` and later.
README.md view
@@ -20,16 +20,17 @@ means that not every input is considered valid markdown document 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.+document passes the MMark parser, then it is likely to produce an HTML+output without quirks. This feature makes it a good choice for writers and+bloggers. MMark in its current state features: * A parser that produces high-quality error messages and does not choke on- first parse error. It is capable of reporting many parse errors where- makes sense.+ the first parse error. It is capable of reporting several parse errors+ simultaneously. -* An extension system allowing to create extensions that alter parsed+* An extension system that allows us to create extensions that alter parsed markdown document in some way. * A [`lucid`](https://hackage.haskell.org/package/lucid)-based render.@@ -96,9 +97,9 @@ ### Differences in inline parsing Emphasis and strong emphasis is an especially hairy topic in the Common Mark-specification. There are 17 ad-hoc rules defining interaction between `*`-and `_` -based emphasis and more than an half of all Common Mark examples-(that's about 300) test just this tricky logic.+specification. There are 17 ad-hoc rules defining the interaction between+`*` and `_` -based emphasis and more than an half of all Common Mark+examples (that's about 300) test just this. Not only it is hard to implement, it's hard to understand for humans too. For example, this input:@@ -122,8 +123,8 @@ ``` Well, why not? Without remembering those 17 ad-hoc rules, there going to be-a lot of tricky cases when a user won't be able to tell how markdown will be-parsed.+a lot of tricky cases when the user won't be able to tell how markdown will+be parsed. I decided to make parsing of emphasis, strong emphasis, and similar constructs like strikethrough, subscript, and superscript more symmetric and@@ -192,7 +193,7 @@ __foo__bar ``` -This means that inter-word emphasis is not supported by this approach.+This means that inter-word emphasis is not supported. The next example is OK because `s` is an **other character** and `.` is a **punctuation character**, so `level('s') > level('.')`.
Text/MMark.hs view
@@ -13,8 +13,8 @@ -- “Strict” means that not every input is considered valid markdown document -- 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+-- a markdown document passes the MMark parser, then it'll likely produce+-- HTML without quirks. This feature makes it a good choice for writers and -- bloggers. -- -- === MMark and Common Mark@@ -179,7 +179,7 @@ a runScanner MMark {..} f = L.fold f mmarkBlocks --- | Like 'runScanner', but allows to run scanners with monadic context.+-- | Like 'runScanner', but allows us to run scanners with monadic context. -- -- To bring 'L.Fold' and 'L.FoldM' types to the “least common denominator” -- use 'L.generalize' and 'L.simplify'.
Text/MMark/Extension.hs view
@@ -9,14 +9,14 @@ -- Stability : experimental -- Portability : portable ----- This module provides building blocks for extension creation.+-- This module provides building blocks for creation of extensions. -- -- We suggest using a qualified import, like this: -- -- > import Text.MMark.Extension (Bni, Block (..), Inline (..)) -- > import qualified Text.MMark.Extension as Ext ----- === Philosophy of MMark extensions+-- === The philosophy of MMark extensions -- -- The extension system is guided by the following goals: --@@ -51,7 +51,7 @@ -- -- One could note that the current design does not allow prepending or -- appending new elements to the AST. This is a limitation by design because--- we try to make the order in which extensions are applied not important+-- we try to make the order in which extensions are applied unimportant -- (it's not always possible, though). Thus, if we want to e.g. insert a -- table of contents into a document, we need to do so by transforming an -- already existing element, such as code block with a special info string
Text/MMark/Parser.hs view
@@ -520,7 +520,7 @@ (endOfTable >>= guard) <* sc --- | Parse a paragraph or naked text (is some cases).+-- | Parse a paragraph or naked text (in some cases). pParagraph :: BParser (Block Isp) pParagraph = do startOffset <- getOffset
Text/MMark/Parser/Internal.hs view
@@ -9,8 +9,8 @@ -- Stability : experimental -- Portability : portable ----- An internal module that builds a framework on which the--- "Text.MMark.Parser" module is built.+-- An internal module that builds a framework that the "Text.MMark.Parser"+-- module uses. module Text.MMark.Parser.Internal ( -- * Block-level parser monad BParser,@@ -227,7 +227,7 @@ ---------------------------------------------------------------------------- -- Helpers --- | Setup initial parser state.+-- | Setup an initial parser state. mkInitialState :: -- | File name to use FilePath ->
Text/MMark/Parser/Internal/Type.hs view
@@ -70,8 +70,8 @@ -- | Block-level parser state. data BlockState = BlockState { -- | Should we consider a paragraph that does not end with a blank line- -- 'Naked'? It does not make sense to do so for top-level document, but- -- in lists, 'Naked' text is pretty common.+ -- 'Naked'? It does not make sense to do so in the top-level document,+ -- but in lists, 'Naked' text is pretty common. _bstAllowNaked :: Bool, -- | Current reference level: 1 column for top-level of document, column -- where content starts for block quotes and lists.
mmark.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.18 name: mmark-version: 0.0.7.3+version: 0.0.7.4 license: BSD3 license-file: LICENSE.md maintainer: Mark Karpov <markkarpov92@gmail.com> author: Mark Karpov <markkarpov92@gmail.com>-tested-with: ghc ==8.8.4 ghc ==8.10.4 ghc ==9.0.1+tested-with: ghc ==8.8.4 ghc ==8.10.5 ghc ==9.0.1 homepage: https://github.com/mmark-md/mmark bug-reports: https://github.com/mmark-md/mmark/issues synopsis: Strict markdown processor for writers@@ -45,7 +45,7 @@ default-language: Haskell2010 build-depends:- aeson >=0.11 && <1.6,+ aeson >=0.11 && <3, base >=4.13 && <5.0, case-insensitive >=1.2 && <1.3, containers >=0.5 && <0.7,@@ -53,9 +53,9 @@ dlist >=0.8 && <2.0, email-validate >=2.2 && <2.4, foldl >=1.2 && <1.5,- hashable >=1.0.1.1 && <1.4,+ hashable >=1 && <1.4, html-entity-map >=0.1 && <0.2,- lucid >=2.6 && <3.0,+ lucid >=2.9.13 && <3.0, megaparsec >=8.0 && <10.0, microlens >=0.4 && <0.5, microlens-th >=0.4 && <0.5,@@ -95,12 +95,12 @@ default-language: Haskell2010 build-depends: QuickCheck >=2.4 && <3.0,- aeson >=0.11 && <1.6,+ aeson >=0.11 && <3, base >=4.13 && <5.0, foldl >=1.2 && <1.5, hspec >=2.0 && <3.0, hspec-megaparsec >=2.0 && <3.0,- lucid >=2.6 && <3.0,+ lucid >=2.9.13 && <3.0, megaparsec >=8.0 && <10.0, mmark, modern-uri >=0.3 && <0.4,
tests/Text/MMark/TestUtils.hs view
@@ -27,8 +27,8 @@ ---------------------------------------------------------------------------- -- Document creation and rendering --- | Create an 'MMark' document from given input reporting an expectation--- failure if it cannot be parsed.+-- | Create an 'MMark' document from the given input reporting an+-- expectation failure if it cannot be parsed. mkDoc :: Text -> IO MMark mkDoc input = case MMark.parse "" input of
tests/Text/MMarkSpec.hs view
@@ -1624,10 +1624,10 @@ context "6.6 Images" $ do it "CM543" $ ""- ==-> "<p><img alt=\"foo\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"foo\" src=\"/url\" title=\"title\"></p>\n" it "CM544" $ ""- ==-> "<p><img alt=\"foo bar\" title=\"train & tracks\" src=\"train.jpg\"></p>\n"+ ==-> "<p><img alt=\"foo bar\" src=\"train.jpg\" title=\"train & tracks\"></p>\n" it "CM545" $ let s = "](/url2)\n" in s ~-> err 6 (utok '!' <> etok ']' <> eic)@@ -1639,13 +1639,13 @@ in s ~-> errFancy 2 (couldNotMatchRef "foo bar" ["foo *bar*"]) it "CM548" $ "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\""- ==-> "<p><img alt=\"foo bar\" title=\"train & tracks\" src=\"train.jpg\"></p>\n"+ ==-> "<p><img alt=\"foo bar\" src=\"train.jpg\" title=\"train & tracks\"></p>\n" it "CM549" $ "" ==-> "<p><img alt=\"foo\" src=\"train.jpg\"></p>\n" it "CM550" $ "My "- ==-> "<p>My <img alt=\"foo bar\" title=\"title\" src=\"/path/to/train.jpg\"></p>\n"+ ==-> "<p>My <img alt=\"foo bar\" src=\"/path/to/train.jpg\" title=\"title\"></p>\n" it "CM551" $ "" ==-> "<p><img alt=\"foo\" src=\"url\"></p>\n"@@ -1659,22 +1659,22 @@ ==-> "<p><img alt=\"foo\" src=\"/url\"></p>\n" it "CM555" $ "![foo][]\n\n[foo]: /url \"title\""- ==-> "<p><img alt=\"foo\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"foo\" src=\"/url\" title=\"title\"></p>\n" it "CM556" $ "![foo bar][]\n\n[foo bar]: /url \"title\""- ==-> "<p><img alt=\"foo bar\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"foo bar\" src=\"/url\" title=\"title\"></p>\n" it "CM557" $ "![Foo][]\n\n[foo]: /url \"title\""- ==-> "<p><img alt=\"Foo\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"Foo\" src=\"/url\" title=\"title\"></p>\n" it "CM558" $ let s = "![foo] \n[]\n\n[foo]: /url \"title\"" in s ~-> err 9 (utok ']' <> eic) it "CM559" $ "![foo]\n\n[foo]: /url \"title\""- ==-> "<p><img alt=\"foo\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"foo\" src=\"/url\" title=\"title\"></p>\n" it "CM560" $ "![*foo* bar]\n\n[foo bar]: /url \"title\"\n"- ==-> "<p><img alt=\"foo bar\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"foo bar\" src=\"/url\" title=\"title\"></p>\n" it "CM561" $ let s = "![[foo]]\n\n[[foo]]: /url \"title\"" in s@@ -1683,7 +1683,7 @@ ] it "CM562" $ "![Foo]\n\n[foo]: /url \"title\""- ==-> "<p><img alt=\"Foo\" title=\"title\" src=\"/url\"></p>\n"+ ==-> "<p><img alt=\"Foo\" src=\"/url\" title=\"title\"></p>\n" it "CM563" $ "!\\[foo\\]\n\n[foo]: /url \"title\"" ==-> "<p>![foo]</p>\n"@@ -2064,7 +2064,7 @@ context "when it is invalid" $ do let mappingErr = fancy . ErrorCustom . YamlParseError $ "mapping values are not allowed in this context"- it "signal correct parse error" $+ it "signals correct parse error" $ let s = "---\nx: 100\ny: x:\n---\nHere we go." in s ~-> errFancy 15 mappingErr it "does not choke and can report more parse errors" $@@ -2100,7 +2100,7 @@ -- For testing with documents loaded externally -- | Load a complete markdown document from an external file and compare the--- final HTML rendering with contents of another file.+-- final HTML rendering with the contents of another file. withFiles :: -- | Markdown document FilePath ->@@ -2153,37 +2153,37 @@ elabel "unreserved character" ] --- | Error component complaining that the given 'Text' is not in left- or--- right- flanking position.+-- | The error component complaining that the given 'Text' is not in left-+-- or right- flanking position. nonFlanking :: Text -> EF MMarkErr nonFlanking = fancy . ErrorCustom . NonFlankingDelimiterRun . NE.fromList . T.unpack --- | Error component complaining that the given starting index of an ordered--- list is too big.+-- | The error component complaining that the given starting index of an+-- ordered list is too big. indexTooBig :: Word -> EF MMarkErr indexTooBig = fancy . ErrorCustom . ListStartIndexTooBig --- | Error component complaining about non-consecutive indices in an ordered--- list.+-- | The error component complaining about non-consecutive indices in an+-- ordered list. indexNonCons :: Word -> Word -> EF MMarkErr indexNonCons actual expected = fancy . ErrorCustom $ ListIndexOutOfOrder actual expected --- | Error component complaining about a missing link\/image reference.+-- | The error component complaining about a missing link\/image reference. couldNotMatchRef :: Text -> [Text] -> EF MMarkErr couldNotMatchRef name names = fancy . ErrorCustom $ CouldNotFindReferenceDefinition name names --- | Error component complaining about a duplicate reference definition.+-- | The error component complaining about a duplicate reference definition. duplicateRef :: Text -> EF MMarkErr duplicateRef = fancy . ErrorCustom . DuplicateReferenceDefinition --- | Error component complaining about an invalid numeric character.+-- | The error component complaining about an invalid numeric character. invalidNumChar :: Int -> EF MMarkErr invalidNumChar = fancy . ErrorCustom . InvalidNumericCharacter --- | Error component complaining about an unknown HTML5 entity name.+-- | The error component complaining about an unknown HTML5 entity name. unknownEntity :: Text -> EF MMarkErr unknownEntity = fancy . ErrorCustom . UnknownHtmlEntityName