From c72277e98683544759d966fc88012b4f6d0fa8ec Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sun, 10 Oct 2021 11:24:28 -0700
Subject: [PATCH] LaTeX reader: Properly handle `\^` followed by group closing.

Closes #7615.
---
 src/Text/Pandoc/Readers/LaTeX/Inline.hs | 6 +++---
 test/command/7615.md                    | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 test/command/7615.md

diff --git a/src/Text/Pandoc/Readers/LaTeX/Inline.hs b/src/Text/Pandoc/Readers/LaTeX/Inline.hs
index 7b8bca4af..0fd14017b 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Inline.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Inline.hs
@@ -35,7 +35,7 @@ import Text.Pandoc.Readers.LaTeX.Parsing
 import Text.Pandoc.Extensions (extensionEnabled, Extension(..))
 import Text.Pandoc.Parsing (getOption, updateState, getState, notFollowedBy,
                             manyTill, getInput, setInput, incSourceColumn,
-                            option, many1, try)
+                            option, many1)
 import Data.Char (isDigit)
 import Text.Pandoc.Highlighting (fromListingsLanguage,)
 import Data.Maybe (maybeToList, fromMaybe)
@@ -160,8 +160,8 @@ romanNumeralArg = spaces *> (parser <|> inBraces)
 
 accentWith :: PandocMonad m
            => LP m Inlines -> Char -> Maybe Char -> LP m Inlines
-accentWith tok combiningAccent fallBack = try $ do
-  ils <- tok
+accentWith tok combiningAccent fallBack = do
+  ils <- option mempty tok
   case toList ils of
        (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $
          -- try to normalize to the combined character:
diff --git a/test/command/7615.md b/test/command/7615.md
new file mode 100644
index 000000000..9235b0a17
--- /dev/null
+++ b/test/command/7615.md
@@ -0,0 +1,6 @@
+```
+% pandoc -f latex -t native
+\texttt{\^}
+^D
+[ Para [ Code ( "" , [] , [] ) "^" ] ]
+```