git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3980 from bfirsh/skip-spaces-in-image-options
8aa972dJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+2
@@ -758,8 +758,10 @@ keyval = try $ do
758 Tok _ Word key <- satisfyTok isWordTok
758 Tok _ Word key <- satisfyTok isWordTok
759 let isSpecSym (Tok _ Symbol t) = t `elem` [".",":","-","|","\\"]
759 let isSpecSym (Tok _ Symbol t) = t `elem` [".",":","-","|","\\"]
760 isSpecSym _ = False
760 isSpecSym _ = False
761+ optional sp
761 val <- option [] $ do
762 val <- option [] $ do
762 symbol '='
763 symbol '='
764+ optional sp
763 braced <|> (many1 (satisfyTok isWordTok <|> satisfyTok isSpecSym
765 braced <|> (many1 (satisfyTok isWordTok <|> satisfyTok isSpecSym
764 <|> anyControlSeq))
766 <|> anyControlSeq))
765 optional sp
767 optional sp
test/Tests/Readers/LaTeX.hs+27
@@ -108,6 +108,33 @@ tests = [ testGroup "basic"
108 , biblatexCitations
108 , biblatexCitations
109 ]
109 ]
110
110
111+ , testGroup "images"
112+ [ "Basic image" =:
113+ "\\includegraphics{foo.png}" =?>
114+ para (image "foo.png" "" (text "image"))
115+ , "Basic image with blank options" =:
116+ "\\includegraphics[]{foo.png}" =?>
117+ para (image "foo.png" "" (text "image"))
118+ , "Image with both width and height" =:
119+ "\\includegraphics[width=17cm,height=5cm]{foo.png}" =?>
120+ para (imageWith ("", [], [("width", "17cm"), ("height", "5cm")]) "foo.png" "" "image")
121+ , "Image with width and height and a bunch of other options" =:
122+ "\\includegraphics[width=17cm,height=5cm,clip,keepaspectratio]{foo.png}" =?>
123+ para (imageWith ("", [], [("width", "17cm"), ("height", "5cm")]) "foo.png" "" "image")
124+ , "Image with just width" =:
125+ "\\includegraphics[width=17cm]{foo.png}" =?>
126+ para (imageWith ("", [], [("width", "17cm")]) "foo.png" "" "image")
127+ , "Image with just height" =:
128+ "\\includegraphics[height=17cm]{foo.png}" =?>
129+ para (imageWith ("", [], [("height", "17cm")]) "foo.png" "" "image")
130+ , "Image width relative to textsize" =:
131+ "\\includegraphics[width=0.6\\textwidth]{foo.png}" =?>
132+ para (imageWith ("", [], [("width", "60%")]) "foo.png" "" "image")
133+ , "Image with options with spaces" =:
134+ "\\includegraphics[width=12cm, height = 5cm]{foo.png}" =?>
135+ para (imageWith ("", [], [("width", "12cm"), ("height", "5cm")]) "foo.png" "" "image")
136+ ]
137+
111 , let hex = ['0'..'9']++['a'..'f'] in
138 , let hex = ['0'..'9']++['a'..'f'] in
112 testGroup "Character Escapes"
139 testGroup "Character Escapes"
113 [ "Two-character escapes" =:
140 [ "Two-character escapes" =: