Latex reader: Skip spaces in image options

This commit is contained in:
Ben Firshman 2017-10-13 16:49:00 +03:00
parent d73fdbf895
commit 9046dbadb1
No known key found for this signature in database
GPG key ID: 18296449E36D2F1E
2 changed files with 5 additions and 0 deletions

View file

@ -758,8 +758,10 @@ keyval = try $ do
Tok _ Word key <- satisfyTok isWordTok
let isSpecSym (Tok _ Symbol t) = t `elem` [".",":","-","|","\\"]
isSpecSym _ = False
optional sp
val <- option [] $ do
symbol '='
optional sp
braced <|> (many1 (satisfyTok isWordTok <|> satisfyTok isSpecSym
<|> anyControlSeq))
optional sp

View file

@ -130,6 +130,9 @@ tests = [ testGroup "basic"
, "Image width relative to textsize" =:
"\\includegraphics[width=0.6\\textwidth]{foo.png}" =?>
para (imageWith ("", [], [("width", "60%")]) "foo.png" "" "image")
, "Image with options with spaces" =:
"\\includegraphics[width=12cm, height = 5cm]{foo.png}" =?>
para (imageWith ("", [], [("width", "12cm"), ("height", "5cm")]) "foo.png" "" "image")
]
, let hex = ['0'..'9']++['a'..'f'] in