diff options
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 30 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 104b75343..1b206e4c7 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -730,10 +730,16 @@ failIfInQuoteContext context = do then fail "already inside quotes" else return () +charOrRef :: [Char] -> GenParser Char st Char +charOrRef cs = + oneOf cs <|> try (do c <- characterReference + guard (c `elem` cs) + return c) + singleQuoteStart :: GenParser Char ParserState () singleQuoteStart = do failIfInQuoteContext InSingleQuote - try $ do oneOf "'\8216" + try $ do charOrRef "'\8216" notFollowedBy (oneOf ")!],.;:-? \t\n") notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >> satisfy (not . isAlphaNum))) @@ -742,28 +748,36 @@ singleQuoteStart = do singleQuoteEnd :: GenParser Char st () singleQuoteEnd = try $ do - oneOf "'\8217" + charOrRef "'\8217" notFollowedBy alphaNum doubleQuoteStart :: GenParser Char ParserState () doubleQuoteStart = do failIfInQuoteContext InDoubleQuote - try $ do oneOf "\"\8220" + try $ do charOrRef "\"\8220" notFollowedBy (oneOf " \t\n") doubleQuoteEnd :: GenParser Char st () -doubleQuoteEnd = oneOf "\"\8221" >> return () +doubleQuoteEnd = do + charOrRef "\"\8221" + return () ellipses :: GenParser Char st Inline -ellipses = try $ string "..." >> return Ellipses +ellipses = do + try (charOrRef "…") <|> try (string "..." >> return '…') + return Ellipses dash :: GenParser Char st Inline dash = enDash <|> emDash enDash :: GenParser Char st Inline -enDash = try $ char '-' >> notFollowedBy (noneOf "0123456789") >> return EnDash +enDash = do + try (charOrRef "–") <|> + try (char '-' >> notFollowedBy (noneOf "0123456789") >> return '–') + return EnDash emDash :: GenParser Char st Inline -emDash = oneOfStrings ["---", "--"] >> return EmDash - +emDash = do + try (charOrRef "—") <|> (oneOfStrings ["---", "--"] >> return '—') + return EmDash diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index c9f6adcb3..41eea16c5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -900,7 +900,6 @@ inlineParsers = [ str , whitespace , endline , code - , charRef , (fourOrMore '*' <|> fourOrMore '_') , strong , emph @@ -919,6 +918,7 @@ inlineParsers = [ str , escapedChar , exampleRef , smartPunctuation inline + , charRef , symbol , ltSign ] |