mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-14 03:25:51 +00:00
@@ -343,6 +343,12 @@ inlineCommands = M.unions
|
||||
, biblatexInlineCommands tok
|
||||
, rest ]
|
||||
where
|
||||
disableLigatures p = do
|
||||
oldLigatures <- sLigatures <$> getState
|
||||
updateState (\s -> s{ sLigatures = False })
|
||||
res <- p
|
||||
updateState (\s -> s{ sLigatures = oldLigatures })
|
||||
pure res
|
||||
rest = M.fromList
|
||||
[ ("emph", extractSpaces emph <$> tok)
|
||||
, ("textit", extractSpaces emph <$> tok)
|
||||
@@ -352,7 +358,7 @@ inlineCommands = M.unions
|
||||
, ("textmd", extractSpaces (spanWith ("",["medium"],[])) <$> tok)
|
||||
, ("textrm", extractSpaces (spanWith ("",["roman"],[])) <$> tok)
|
||||
, ("textup", extractSpaces (spanWith ("",["upright"],[])) <$> tok)
|
||||
, ("texttt", formatCode nullAttr <$> tok)
|
||||
, ("texttt", formatCode nullAttr <$> disableLigatures tok)
|
||||
, ("alert", skipopts >> spanWith ("",["alert"],[]) <$> tok) -- beamer
|
||||
, ("textsuperscript", extractSpaces superscript <$> tok)
|
||||
, ("textsubscript", extractSpaces subscript <$> tok)
|
||||
@@ -634,6 +640,7 @@ inline = do
|
||||
do eatOneToken
|
||||
report $ ParsingUnescaped t pos
|
||||
return $ str t
|
||||
ligatures <- sLigatures <$> getState
|
||||
case toktype of
|
||||
Comment -> mempty <$ eatOneToken
|
||||
Spaces -> space <$ eatOneToken
|
||||
@@ -641,14 +648,19 @@ inline = do
|
||||
Word -> str t <$ eatOneToken
|
||||
Symbol ->
|
||||
case t of
|
||||
"-" -> eatOneToken *>
|
||||
"-" | ligatures
|
||||
-> eatOneToken *>
|
||||
option (str "-") (symbol '-' *>
|
||||
option (str "–") (str "—" <$ symbol '-'))
|
||||
"'" -> eatOneToken *>
|
||||
option (str "’") (str "”" <$ symbol '\'')
|
||||
option (str "’") (str "”" <$ (guard ligatures *> symbol '\''))
|
||||
"~" -> str "\160" <$ eatOneToken
|
||||
"`" -> doubleQuote <|> singleQuote <|> symbolAsString
|
||||
"\"" -> doubleQuote <|> singleQuote <|> symbolAsString
|
||||
"`" | ligatures
|
||||
-> doubleQuote <|> singleQuote <|> (str "‘" <$ symbol '`')
|
||||
| otherwise
|
||||
-> str "‘" <$ symbol '`'
|
||||
"\"" | ligatures
|
||||
-> doubleQuote <|> singleQuote <|> symbolAsString
|
||||
"“" -> doubleQuote <|> symbolAsString
|
||||
"‘" -> singleQuote <|> symbolAsString
|
||||
"$" -> dollarsMath <|> unescapedSymbolAsString
|
||||
|
||||
@@ -173,6 +173,7 @@ data LaTeXState = LaTeXState{ sOptions :: ReaderOptions
|
||||
, sFileContents :: M.Map Text Text
|
||||
, sEnableWithRaw :: Bool
|
||||
, sRawTokens :: IntMap.IntMap [Tok]
|
||||
, sLigatures :: Bool
|
||||
}
|
||||
deriving Show
|
||||
|
||||
@@ -201,6 +202,7 @@ defaultLaTeXState = LaTeXState{ sOptions = def
|
||||
, sFileContents = M.empty
|
||||
, sEnableWithRaw = True
|
||||
, sRawTokens = IntMap.empty
|
||||
, sLigatures = True
|
||||
}
|
||||
|
||||
instance PandocMonad m => HasQuoteContext LaTeXState m where
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
```
|
||||
% pandoc -f latex -t markdown --wrap=preserve
|
||||
This is \texttt{--flag} with dashes.
|
||||
This is the same --flag without a code.
|
||||
^D
|
||||
This is `--flag` with dashes.
|
||||
This is the same --flag without a code.
|
||||
```
|
||||
@@ -9,7 +9,7 @@
|
||||
% pandoc -f latex -t native
|
||||
\texttt{``hi''}
|
||||
^D
|
||||
[ Para [ Code ( "" , [] , [] ) "\8220hi\8221" ] ]
|
||||
[ Para [ Code ( "" , [] , [] ) "\8216\8216hi\8217\8217" ] ]
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user