mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-26 10:16:32 +00:00
LaTeX reader: Parse contents of curly quotes or matched " as quotes.
This commit is contained in:
@@ -163,13 +163,23 @@ mathChars = concat <$>
|
||||
<|> (\c -> ['\\',c]) <$> (try $ char '\\' *> anyChar)
|
||||
)
|
||||
|
||||
quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
|
||||
quoted' f starter ender = do
|
||||
startchs <- starter
|
||||
try ((f . mconcat) <$> manyTill inline ender) <|> lit startchs
|
||||
|
||||
double_quote :: LP Inlines
|
||||
double_quote = (doubleQuoted . mconcat) <$>
|
||||
(try $ string "``" *> manyTill inline (try $ string "''"))
|
||||
double_quote =
|
||||
( quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
|
||||
<|> quoted' doubleQuoted (string "“") (void $ char '”')
|
||||
<|> quoted' doubleQuoted (string "\"") (void $ char '"')
|
||||
)
|
||||
|
||||
single_quote :: LP Inlines
|
||||
single_quote = (singleQuoted . mconcat) <$>
|
||||
(try $ char '`' *> manyTill inline (try $ char '\'' >> notFollowedBy letter))
|
||||
single_quote =
|
||||
( quoted' singleQuoted (string "`") (try $ char '\'' >> notFollowedBy letter)
|
||||
<|> quoted' singleQuoted (string "‘") (try $ char '’' >> notFollowedBy letter)
|
||||
)
|
||||
|
||||
inline :: LP Inlines
|
||||
inline = (mempty <$ comment)
|
||||
@@ -181,10 +191,10 @@ 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 "’" <$ char '\'')
|
||||
<|> (str "’" <$ char '’')
|
||||
<|> (str "\160" <$ char '~')
|
||||
<|> (mathDisplay $ string "$$" *> mathChars <* string "$$")
|
||||
<|> (mathInline $ char '$' *> mathChars <* char '$')
|
||||
@@ -755,7 +765,7 @@ inlineText :: LP Inlines
|
||||
inlineText = str <$> many1 inlineChar
|
||||
|
||||
inlineChar :: LP Char
|
||||
inlineChar = noneOf "\\$%^_&~#{}^'`-[] \t\n"
|
||||
inlineChar = noneOf "\\$%^_&~#{}^'`\"‘’“”-[] \t\n"
|
||||
|
||||
environment :: LP Blocks
|
||||
environment = do
|
||||
|
||||
@@ -302,7 +302,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
|
||||
,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 "\8216"]
|
||||
,Para [Str "Backtick:",Space,Str "`"]
|
||||
,Para [Str "Asterisk:",Space,Str "*"]
|
||||
,Para [Str "Underscore:",Space,Str "_"]
|
||||
,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
|
||||
|
||||
Reference in New Issue
Block a user