aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-08-14 14:28:34 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-08-14 14:34:44 -0700
commit79a3449eeb15d2cd3127a1a5910b3f4b37fd2122 (patch)
tree896a9d86405c6f327af3a4a54f082820f4ae2276 /src/Text/Pandoc/Readers/LaTeX
parente85178c32ac78578fb2a6cda24b5cee106ac98af (diff)
downloadpandoc-79a3449eeb15d2cd3127a1a5910b3f4b37fd2122.tar.gz
LaTeX reader: improve withRaw so it can handle cases where...
the token string is modified by a parser (e.g. accent when it only takes part of a Word token). Closes #5686. Still not ideal, because we get the whole `\t0BAR` and not just `\t0` as a raw latex inline command. But I'm willing to let this be an edge case, since you can easily work around this by inserting a space, braces, or raw attribute. The important thing is that we no longer drop the rest of the document after a raw latex inline command that gobbles only part of a Word token!
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index eeebab3e6..b9114d34c 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -677,6 +677,7 @@ withRaw :: PandocMonad m => LP m a -> LP m (a, [Tok])
withRaw parser = do
inp <- getInput
result <- parser
- nxt <- option (Tok (initialPos "source") Word "") (lookAhead anyTok)
- let raw = takeWhile (/= nxt) inp
+ nxtpos <- option Nothing ((\(Tok pos' _ _) -> Just pos') <$> lookAhead anyTok)
+ let raw = takeWhile (\(Tok pos _ _) -> maybe True
+ (\p -> sourceName p /= sourceName pos || pos < p) nxtpos) inp
return (result, raw)