aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-09-06 16:02:56 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-09-06 16:02:56 -0700
commite2cc9e7ca1cfc095482c72bee6684b5897e82445 (patch)
tree0c795a7879255aad799c16f50f7bcd98fd282352
parentbc4f3af2c3918cba794698f1dc573cd13958c16b (diff)
downloadpandoc-e2cc9e7ca1cfc095482c72bee6684b5897e82445.tar.gz
LaTeX reader: Use curly quotes for bare straight quotes.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs22
-rw-r--r--tests/latex-reader.native2
2 files changed, 10 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index c3df61307..b9b4e86fc 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -166,10 +166,8 @@ double_quote = (doubleQuoted . mconcat) <$>
(try $ string "``" *> manyTill inline (try $ string "''"))
single_quote :: LP Inlines
-single_quote = char '`' *>
- ( try ((singleQuoted . mconcat) <$>
- manyTill inline (try $ char '\'' >> notFollowedBy letter))
- <|> lit "`")
+single_quote = (singleQuoted . mconcat) <$>
+ (try $ char '`' *> manyTill inline (try $ char '\'' >> notFollowedBy letter))
inline :: LP Inlines
inline = (mempty <$ comment)
@@ -181,6 +179,9 @@ inline = (mempty <$ comment)
((char '-') *> option (str "–") (str "—" <$ char '-')))
<|> double_quote
<|> single_quote
+ <|> (str "“" <$ try (string "``")) -- nb. {``} won't be caught by double_quote
+ <|> (str "”" <$ try (string "''"))
+ <|> (str "‘" <$ char '`') -- nb. {`} won't be caught by single_quote
<|> (str "’" <$ char '\'')
<|> (str "\160" <$ char '~')
<|> (mathDisplay $ string "$$" *> mathChars <* string "$$")
@@ -188,10 +189,9 @@ inline = (mempty <$ comment)
<|> (superscript <$> (char '^' *> tok))
<|> (subscript <$> (char '_' *> tok))
<|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb)
- <|> (str <$> count 1 tildeEscape)
- <|> (str <$> string "]")
- <|> (str <$> string "#") -- TODO print warning?
- <|> (str <$> string "&") -- TODO print warning?
+ <|> (str . (:[]) <$> tildeEscape)
+ <|> (str . (:[]) <$> oneOf "[]")
+ <|> (str . (:[]) <$> oneOf "#&") -- TODO print warning?
-- <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters
inlines :: LP Inlines
@@ -645,11 +645,7 @@ inlineText :: LP Inlines
inlineText = str <$> many1 inlineChar
inlineChar :: LP Char
-inlineChar = satisfy $ \c ->
- not (c == '\\' || c == '$' || c == '%' || c == '^' || c == '_' ||
- c == '&' || c == '~' || c == '#' || c == '{' || c == '}' ||
- c == '^' || c == '\'' || c == '`' || c == '-' || c == ']' ||
- c == ' ' || c == '\t' || c == '\n' )
+inlineChar = noneOf "\\$%^_&~#{}^'`-[] \t\n"
environment :: LP Blocks
environment = do
diff --git a/tests/latex-reader.native b/tests/latex-reader.native
index 2873529ae..2ba7a78f2 100644
--- a/tests/latex-reader.native
+++ b/tests/latex-reader.native
@@ -301,7 +301,7 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
,Para [Str "4",Space,Str "<",Space,Str "5."]
,Para [Str "6",Space,Str ">",Space,Str "5."]
,Para [Str "Backslash:",Space,Str "\\"]
-,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Backtick:",Space,Str "\8216"]
,Para [Str "Asterisk:",Space,Str "*"]
,Para [Str "Underscore:",Space,Str "_"]
,Para [Str "Left",Space,Str "brace:",Space,Str "{"]