git.iko.soy/typeable/pandoc
on master help sign in
RST writer: handle images in figures.
874b574fiddlosopher
src/Text/Pandoc/Writers/RST.hs+6
@@ -145,6 +145,12 @@ blockToRST Null = return empty
145blockToRST (Plain inlines) = do
145blockToRST (Plain inlines) = do
146 opts <- get >>= (return . stOptions)
146 opts <- get >>= (return . stOptions)
147 wrappedRST opts inlines
147 wrappedRST opts inlines
148+blockToRST (Para [Image txt (src,tit)]) = do
149+ capt <- inlineListToRST txt
150+ let fig = text "figure:: " <> text src
151+ let align = text ":align: center"
152+ let alt = text ":alt: " <> if null tit then capt else text tit
153+ return $ (text ".. " <> (fig $$ align $$ alt $$ text "" $$ capt)) $$ text ""
148blockToRST (Para inlines) = do
154blockToRST (Para inlines) = do
149 opts <- get >>= (return . stOptions)
155 opts <- get >>= (return . stOptions)
150 contents <- wrappedRST opts inlines
156 contents <- wrappedRST opts inlines
tests/writer.rst+5−2
@@ -834,7 +834,11 @@ Images
834
834
835From "Voyage dans la Lune" by Georges Melies (1902):
835From "Voyage dans la Lune" by Georges Melies (1902):
836
836
837−|lalune|
837+.. figure:: lalune.jpg
838+ :align: center
839+ :alt: Voyage dans la Lune
840+
841+ lalune
838
842
839Here is a movie |movie| icon.
843Here is a movie |movie| icon.
840
844
@@ -885,6 +889,5 @@ indented.
885 In list.
889 In list.
886
890
887
891
888−.. |lalune| image:: lalune.jpg
889.. |movie| image:: movie.jpg
892.. |movie| image:: movie.jpg
890
893