mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-25 09:47:06 +00:00
RST writer: proper handling of :align: on figures, images.
When the image has the `align-right` (etc.) class, we now use an `:align:` attribute. Closes #4420.
This commit is contained in:
@@ -140,9 +140,12 @@ pictToRST (label, (attr, src, _, mbtarget)) = do
|
||||
label' <- inlineListToRST label
|
||||
dims <- imageDimsToRST attr
|
||||
let (_, cls, _) = attr
|
||||
classes = if null cls
|
||||
then empty
|
||||
else ":class: " <> text (unwords cls)
|
||||
classes = case cls of
|
||||
[] -> empty
|
||||
["align-right"] -> ":align: right"
|
||||
["align-left"] -> ":align: left"
|
||||
["align-center"] -> ":align: center"
|
||||
_ -> ":class: " <> text (unwords cls)
|
||||
return $ nowrap
|
||||
$ ".. |" <> label' <> "| image:: " <> text src $$ hang 3 empty (classes $$ dims)
|
||||
$$ case mbtarget of
|
||||
@@ -218,9 +221,12 @@ blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
|
||||
let fig = "figure:: " <> text src
|
||||
alt = ":alt: " <> if null tit then capt else text tit
|
||||
(_,cls,_) = attr
|
||||
classes = if null cls
|
||||
then empty
|
||||
else ":figclass: " <> text (unwords cls)
|
||||
classes = case cls of
|
||||
[] -> empty
|
||||
["align-right"] -> ":align: right"
|
||||
["align-left"] -> ":align: left"
|
||||
["align-center"] -> ":align: center"
|
||||
_ -> ":figclass: " <> text (unwords cls)
|
||||
return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline
|
||||
blockToRST (Para inlines)
|
||||
| LineBreak `elem` inlines =
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
```
|
||||
% pandoc -f native -t rst
|
||||
[Image ("",["align-right"],[("width","100px")]) [Str "image"] ("foo.png","")]
|
||||
^D
|
||||
|image|
|
||||
|
||||
.. |image| image:: foo.png
|
||||
:align: right
|
||||
:width: 100px
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f native -t rst
|
||||
[Para [Image ("",["align-right"],[("width","100px")]) [Str "image"] ("foo.png","fig:test")]]
|
||||
^D
|
||||
.. figure:: foo.png
|
||||
:alt: test
|
||||
:align: right
|
||||
:width: 100px
|
||||
|
||||
image
|
||||
```
|
||||
Reference in New Issue
Block a user