diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index f5d8527dd..5c0279fce 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1765,6 +1765,7 @@ blockCommands = M.fromList
          addMeta "bibliography" . splitBibs . toksToString))
    , ("addbibresource", mempty <$ (skipopts *> braced >>=
          addMeta "bibliography" . splitBibs . toksToString))
+   , ("endinput", mempty <$ skipMany tok)
    -- includes
    , ("lstinputlisting", inputListing)
    , ("inputminted", inputMinted)
diff --git a/test/command/5233.md b/test/command/5233.md
new file mode 100644
index 000000000..0c92e955e
--- /dev/null
+++ b/test/command/5233.md
@@ -0,0 +1,9 @@
+```
+% pandoc -f latex -t plain
+foo
+\endinput
+bar
+^D
+foo
+```
+