From 9046dbadb1147a4d9e2b114a2afc1a0292ef7762 Mon Sep 17 00:00:00 2001 From: Ben Firshman Date: Fri, 13 Oct 2017 16:49:00 +0300 Subject: Latex reader: Skip spaces in image options --- src/Text/Pandoc/Readers/LaTeX.hs | 2 ++ test/Tests/Readers/LaTeX.hs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 8c6c7d0ff..b3c637748 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -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 diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs index 8fedc0978..ba9b8e289 100644 --- a/test/Tests/Readers/LaTeX.hs +++ b/test/Tests/Readers/LaTeX.hs @@ -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 -- cgit v1.2.3