Smart quotes: handle '...hi' properly.

Also added test case.
This commit is contained in:
John MacFarlane 2011-07-25 23:49:45 -07:00
parent 499d1257ca
commit 0f0c1579f8
2 changed files with 11 additions and 1 deletions

View file

@ -8,10 +8,14 @@ import Tests.Arbitrary()
import Text.Pandoc.Builder
-- import Text.Pandoc.Shared ( normalize )
import Text.Pandoc
import Data.Sequence (singleton)
markdown :: String -> Pandoc
markdown = readMarkdown defaultParserState{ stateStandalone = True }
markdownSmart :: String -> Pandoc
markdownSmart = readMarkdown defaultParserState{ stateSmart = True }
infix 5 =:
(=:) :: ToString c
=> String -> (String, c) -> Test
@ -40,6 +44,11 @@ tests = [ testGroup "inline code"
"`*` {.haskell .special x=\"7\"}"
=?> para (codeWith ("",["haskell","special"],[("x","7")]) "*")
]
, testGroup "smart punctuation"
[ test markdownSmart "quote before ellipses"
("'...hi'"
=?> para (singleQuoted (singleton Ellipses +++ "hi")))
]
, testGroup "mixed emphasis and strong"
[ "emph and strong emph alternating" =:
"*xxx* ***xxx*** xxx\n*xxx* ***xxx*** xxx"

View file

@ -759,7 +759,8 @@ singleQuoteStart :: GenParser Char ParserState ()
singleQuoteStart = do
failIfInQuoteContext InSingleQuote
try $ do charOrRef "'\8216\145"
notFollowedBy (oneOf ")!],.;:-? \t\n")
notFollowedBy (oneOf ")!],;:-? \t\n")
notFollowedBy (char '.') <|> lookAhead (string "..." >> return ())
notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >>
satisfy (not . isAlphaNum)))
-- possess/contraction