Skip to content

Commit

Permalink
More tests…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Oct 17, 2017
1 parent 76adf84 commit a6a8667
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Text/MMark/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pInlines allowEmpty allowLinks =
where
stuff = NE.some . label "inline content" . choice $
[ pCodeSpan ] <>
[pInlineLink | allowLinks] <>
[ pInlineLink | allowLinks ] <>
[ pEnclosedInline
, try pHardLineBreak
, pPlain ]
Expand Down Expand Up @@ -333,9 +333,11 @@ pInlineLink = do
pEnclosedInline :: IParser Inline
pEnclosedInline = do
st <- choice
[ pLfdr (DoubleFrame StrongFrame EmphasisFrame)
[ pLfdr (DoubleFrame StrongFrame StrongFrame)
, pLfdr (DoubleFrame StrongFrame EmphasisFrame)
, pLfdr (SingleFrame StrongFrame)
, pLfdr (SingleFrame EmphasisFrame)
, pLfdr (DoubleFrame StrongFrame_ StrongFrame_)
, pLfdr (DoubleFrame StrongFrame_ EmphasisFrame_)
, pLfdr (SingleFrame StrongFrame_)
, pLfdr (SingleFrame EmphasisFrame_)
Expand Down Expand Up @@ -417,7 +419,7 @@ pPlain = Plain . T.pack <$> some
pNewline = hidden . try $
'\n' <$ sc' <* eol <* sc' <* put SpaceChar
pNonEscapedChar = label "unescaped non-markup character" . choice $
[ try (char '\\' <* notFollowedBy eol <* put OtherChar) -- TODO try remove
[ try (char '\\' <* notFollowedBy eol <* put OtherChar)
, spaceChar <* put SpaceChar
, satisfy isTransparentPunctuation <* put SpaceChar
, satisfy isOther <* put OtherChar ]
Expand Down
118 changes: 118 additions & 0 deletions tests/Text/MMarkSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,124 @@ spec = parallel $ do
it "CM396" $
let s = "**** is not an empty strong emphasis\n"
in s ~-> [ errFancy (posN 3 s) (nonFlanking "*") ]
it "CM397" $
"**foo [bar](/url)**" ==->
"<p><strong>foo <a href=\"/url\">bar</a></strong></p>\n"
it "CM398" $
"**foo\nbar**" ==->
"<p><strong>foo\nbar</strong></p>\n"
it "CM399" $
"__foo _bar_ baz__" ==->
"<p><strong>foo <em>bar</em> baz</strong></p>\n"
it "CM400" $
"__foo __bar__ baz__" ==->
"<p><strong>foo <strong>bar</strong> baz</strong></p>\n"
it "CM401" $
"____foo__ bar__" ==->
"<p><strong><strong>foo</strong> bar</strong></p>\n"
it "CM402" $
"**foo **bar****" ==->
"<p><strong>foo <strong>bar</strong></strong></p>\n"
it "CM403" $
"**foo *bar* baz**" ==->
"<p><strong>foo <em>bar</em> baz</strong></p>\n"
it "CM404" $
let s = "**foo*bar*baz**\n"
in s ~-> [ err (posN 5 s) (utoks "*b" <> etoks "**" <> eric) ]
it "CM405" $
"***foo* bar**" ==->
"<p><strong><em>foo</em> bar</strong></p>\n"
it "CM406" $
"**foo *bar***" ==->
"<p><strong>foo <em>bar</em></strong></p>\n"
it "CM407" $
"**foo *bar **baz**\nbim* bop**" ==->
"<p><strong>foo <em>bar <strong>baz</strong>\nbim</em> bop</strong></p>\n"
it "CM408" $
"**foo [*bar*](/url)**" ==->
"<p><strong>foo <a href=\"/url\"><em>bar</em></a></strong></p>\n"
it "CM409" $
let s = "__ is not an empty emphasis\n"
in s ~-> [ errFancy (posN 1 s) (nonFlanking "_") ]
it "CM410" $
let s = "____ is not an empty strong emphasis\n"
in s ~-> [ errFancy (posN 3 s) (nonFlanking "_") ]
it "CM411" $
let s = "foo ***\n"
in s ~-> [ errFancy (posN 6 s) (nonFlanking "*") ]
it "CM412" $
"foo *\\**" ==-> "<p>foo <em>*</em></p>\n"
it "CM413" $
"foo *\\_*\n" ==-> "<p>foo <em>_</em></p>\n"
it "CM414" $
let s = "foo *****\n"
in s ~-> [ errFancy (posN 8 s) (nonFlanking "*") ]
it "CM415" $
"foo **\\***" ==-> "<p>foo <strong>*</strong></p>\n"
it "CM416" $
"foo **\\_**\n" ==-> "<p>foo <strong>_</strong></p>\n"
it "CM417" $
let s = "**foo*\n"
in s ~-> [ err (posN 5 s) (utok '*' <> etoks "**" <> eric) ]
it "CM418" $
let s = "*foo**\n"
in s ~-> [ err (posN 5 s) (utok '*' <> eeib) ]
it "CM419" $
let s = "***foo**\n"
in s ~-> [ err (posN 8 s) (ueib <> etok '*' <> elabel "inline content") ]
it "CM420" $
let s = "****foo*\n"
in s ~-> [ err (posN 7 s) (utok '*' <> etoks "**" <> eric) ]
it "CM421" $
let s = "**foo***\n"
in s ~-> [ err (posN 7 s) (utok '*' <> eeib) ]
it "CM422" $
let s = "*foo****\n"
in s ~-> [ err (posN 5 s) (utok '*' <> eeib) ]
it "CM423" $
let s = "foo ___\n"
in s ~-> [ errFancy (posN 6 s) (nonFlanking "_") ]
it "CM424" $
"foo _\\__" ==-> "<p>foo <em>_</em></p>\n"
it "CM425" $
"foo _\\*_" ==-> "<p>foo <em>*</em></p>\n"
it "CM426" $
let s = "foo _____\n"
in s ~-> [ errFancy (posN 8 s) (nonFlanking "_") ]
it "CM427" $
"foo __\\___" ==-> "<p>foo <strong>_</strong></p>\n"
it "CM428" $
"foo __\\*__" ==-> "<p>foo <strong>*</strong></p>\n"
it "CM429" $
let s = "__foo_\n"
in s ~-> [ err (posN 5 s) (utok '_' <> etoks "__" <> eric) ]
it "CM430" $
let s = "_foo__\n"
in s ~-> [ err (posN 5 s) (utok '_' <> eeib) ]
it "CM431" $
let s = "___foo__\n"
in s ~-> [ err (posN 8 s) (ueib <> etok '_' <> elabel "inline content") ]
it "CM432" $
let s = "____foo_\n"
in s ~-> [ err (posN 7 s) (utok '_' <> etoks "__" <> eric) ]
it "CM433" $
let s = "__foo___\n"
in s ~-> [ err (posN 7 s) (utok '_' <> eeib) ]
it "CM434" $
let s = "_foo____\n"
in s ~-> [ err (posN 5 s) (utok '_' <> eeib) ]
it "CM435" $
"**foo**" ==-> "<p><strong>foo</strong></p>\n"
it "CM436" $
"*_foo_*" ==-> "<p><em><em>foo</em></em></p>\n"
it "CM437" $
"__foo__" ==-> "<p><strong>foo</strong></p>\n"
it "CM438" $
"_*foo*_" ==-> "<p><em><em>foo</em></em></p>\n"
it "CM439" $
"****foo****" ==-> "<p><strong><strong>foo</strong></strong></p>\n"
it "CM440" $
"____foo____" ==-> "<p><strong><strong>foo</strong></strong></p>\n"
context "6.5 Links" $ do
it "CM457" $
"[link](/uri \"title\")" ==->
Expand Down

0 comments on commit a6a8667

Please sign in to comment.