Skip to content

Commit

Permalink
LaTeX reader: better handle spacing commands...
Browse files Browse the repository at this point in the history
hfill, vfill, hskip, vskip, etc.

Closes #9150.
  • Loading branch information
jgm committed Oct 22, 2023
1 parent a67223c commit ad1a745
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Text/Pandoc/Readers/LaTeX/Parsing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
51 changes: 51 additions & 0 deletions test/command/9150.md
Original file line number Diff line number Diff line change
@@ -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"
]
```

0 comments on commit ad1a745

Please sign in to comment.