LaTeX reader: add warning when parsing unescaped characters
that normally need escaping in LaTeX.
This commit is contained in:
parent
92cc80b58b
commit
f1cec1dd02
1 changed files with 5 additions and 4 deletions
|
@ -55,7 +55,7 @@ import Text.Pandoc.ImageSize (numUnit, showFl)
|
|||
import Text.Pandoc.Error
|
||||
import Control.Monad.Except (throwError, catchError)
|
||||
import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, readFileLazy,
|
||||
warning)
|
||||
warning, warningWithPos)
|
||||
|
||||
-- | Parse LaTeX from string and return 'Pandoc' document.
|
||||
readLaTeX :: PandocMonad m
|
||||
|
@ -236,9 +236,10 @@ inline = (mempty <$ comment)
|
|||
<|> mathInline (char '$' *> mathChars <* char '$')
|
||||
<|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb)
|
||||
<|> (str . (:[]) <$> tildeEscape)
|
||||
<|> (str . (:[]) <$> oneOf "[]")
|
||||
<|> (str . (:[]) <$> oneOf "#&~^'`\"[]") -- TODO print warning?
|
||||
-- <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters
|
||||
<|> (do res <- oneOf "#&~^'`\"[]"
|
||||
pos <- getPosition
|
||||
warningWithPos (Just pos) ("Parsing unescaped '" ++ [res] ++ "'")
|
||||
return $ str [res])
|
||||
|
||||
inlines :: PandocMonad m => LP m Inlines
|
||||
inlines = mconcat <$> many (notFollowedBy (char '}') *> inline)
|
||||
|
|
Loading…
Add table
Reference in a new issue