diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-29 23:44:12 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-29 23:44:12 -0800 |
commit | 925a4c5164026bfda25bf50b552bacec074fdf3f (patch) | |
tree | 2ddf5a2cd3530789434697d19c0bf8fd892d0f9f /src/Text/Pandoc/Readers/RST.hs | |
parent | 600c22e7bf57b219467794cd8e37c19571988462 (diff) | |
download | pandoc-925a4c5164026bfda25bf50b552bacec074fdf3f.tar.gz |
Better smart quote parsing.
* Added stateLastStrPos to ParserState. This lets us keep track
of whether we're parsing the position immediately after a 'str'.
If we encounter a ' in such a location, it must be an apostrophe,
and can't be a single quote start.
* Set this in the markdown, textile, html, and rst str parsers.
* Closes #360.
Diffstat (limited to 'src/Text/Pandoc/Readers/RST.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 3dcfe47d0..d8704d8c9 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -791,7 +791,11 @@ whitespace :: GenParser Char ParserState Inline whitespace = many1 spaceChar >> return Space <?> "whitespace" str :: GenParser Char ParserState Inline -str = many1 (noneOf (specialChars ++ "\t\n ")) >>= return . Str +str = do + result <- many1 (noneOf (specialChars ++ "\t\n ")) + pos <- getPosition + updateState $ \s -> s{ stateLastStrPos = Just pos } + return $ Str result -- an endline character that can be treated as a space, not a structural break endline :: GenParser Char ParserState Inline |