From 681afbfaac1589dbcd4149c185657b10b7df1d47 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sun, 18 Nov 2018 23:32:02 -0800
Subject: [PATCH] LaTeX reader: improve parsing of `\tiny`, `scriptsize`, etc.

Parse as raw, but know that these font changing commands
take no arguments.
---
 src/Text/Pandoc/Readers/LaTeX.hs | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 1d35cd662..7d2d62762 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1297,12 +1297,26 @@ getRawCommand name txt = do
              void $ count 4 braced
            "def" ->
              void $ manyTill anyTok braced
-           _ -> do
-             skipopts
-             option "" (try (optional sp *> dimenarg))
-             void $ many braced
+           _ | isFontSizeCommand name -> return ()
+             | otherwise -> do
+               skipopts
+               option "" (try (optional sp *> dimenarg))
+               void $ many braced
   return $ T.unpack (txt <> untokenize rawargs)
 
+isFontSizeCommand :: Text -> Bool
+isFontSizeCommand "tiny" = True
+isFontSizeCommand "scriptsize" = True
+isFontSizeCommand "footnotesize" = True
+isFontSizeCommand "small" = True
+isFontSizeCommand "normalsize" = True
+isFontSizeCommand "large" = True
+isFontSizeCommand "Large" = True
+isFontSizeCommand "LARGE" = True
+isFontSizeCommand "huge" = True
+isFontSizeCommand "Huge" = True
+isFontSizeCommand _ = False
+
 isBlockCommand :: Text -> Bool
 isBlockCommand s =
   s `M.member` (blockCommands :: M.Map Text (LP PandocPure Blocks))