From ad1a745f725e3fe12d02339b0caf1af6e8b4924f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 21 Oct 2023 18:37:25 -0700 Subject: [PATCH] LaTeX reader: better handle spacing commands... hfill, vfill, hskip, vskip, etc. Closes #9150. --- src/Text/Pandoc/Readers/LaTeX/Parsing.hs | 12 ++++++ test/command/9150.md | 51 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/command/9150.md diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs index fbe4914841f9..c2217f809ae2 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs @@ -983,6 +983,18 @@ getRawCommand name txt = do void (manyTill anyTok braced) <|> void (satisfyTok isPreTok) -- see #7531 _ | isFontSizeCommand name -> return () + | name `elem` ["hfil", "hfill", "vfil", "vfill", + "hfilneg", "vfilneg"] -> return () + | name `elem` ["hskip", "vskip", "mskip"] -> do + dimenarg + skipMany $ try $ do + sp + satisfyTok $ + \case + Tok _ Word "plus" -> True + Tok _ Word "minus" -> True + _ -> False + dimenarg | otherwise -> do skipopts option "" (try dimenarg) diff --git a/test/command/9150.md b/test/command/9150.md new file mode 100644 index 000000000000..a3c38edd8de5 --- /dev/null +++ b/test/command/9150.md @@ -0,0 +1,51 @@ +``` +% pandoc -f latex -t native +\hfill {\Large \textbf{Theoretische Grundlagen der Informatik}} +^D +[ Para + [ Span + ( "" , [] , [] ) + [ Strong + [ Str "Theoretische" + , Space + , Str "Grundlagen" + , Space + , Str "der" + , Space + , Str "Informatik" + ] + ] + ] +] +``` + +``` +% pandoc -f latex+raw_tex -t native +\hfill {\Large \textbf{Theoretische Grundlagen der Informatik}} +^D +[ Para + [ RawInline (Format "latex") "\\hfill " + , Span + ( "" , [] , [] ) + [ RawInline (Format "latex") "\\Large " + , Strong + [ Str "Theoretische" + , Space + , Str "Grundlagen" + , Space + , Str "der" + , Space + , Str "Informatik" + ] + ] + ] +] +``` + +``` +% pandoc -f latex+raw_tex -t native +\hskip 2pt plus 1pt minus 1pt +^D +[ RawBlock (Format "latex") "\\hskip 2pt plus 1pt minus 1pt" +] +```