Skip to content

Image alignment not respected in reStructuredText #163

Description

@jkleint

If I try to right-align an image in reStructuredText:

.. image:: https://travis-ci.org/jkleint/blamethrower.png
  :align: right

It comes out left-aligned: https://github.com/jkleint/blamethrower/blob/master/README.rst

Activity

  1. jone commented on Jan 3, 2013

    @jone

    python-creole, which seems to be used for rest2html, does not support it at the moment.
    I've made a fix & pull-request to jedie/python-creole#11 for fixing it.

  2. jone commented on Jan 3, 2013

    @jone

    oh, my bad. I assumed it is used here.
    I'm gonna look into it.

  3. gjtorikian commented on Sep 30, 2013

    @gjtorikian
    Contributor
  4. added a commit that references this issue on Nov 28, 2013
  5. flying-sheep commented on Aug 10, 2018

    @flying-sheep
    Contributor

    This bug is not fixed, :align: right has no impact on the emitted HTML, which is wrong. please reopen

  6. bmorris3 commented on Aug 27, 2020

    @bmorris3

    I think this is still an issue. Any help?

  7. Gallaecio commented on Sep 16, 2020

    @Gallaecio

    Align is deprecated in HTML5: http://stackoverflow.com/questions/14551305/align-attribute-deprecated

    @gjtorikian reStructuredText’s align is not HTML, is reStructuredText syntax. And it is not deprecated (emphasis mine):

    The alignment of the image, equivalent to the HTML tag's deprecated "align" attribute or the corresponding "vertical-align" and "text-align" CSS properties. The values "top", "middle", and "bottom" control an image's vertical alignment (relative to the text baseline); they are only useful for inline images (substitutions). The values "left", "center", and "right" control an image's horizontal alignment, allowing the image to float and have the text flow around it. The specific behavior depends upon the browser or rendering software used.

  8. gjtorikian commented on Sep 16, 2020

    @gjtorikian
    Contributor

    I don’t work at GitHub anymore, please contact their support.

  9. Gallaecio commented on Sep 16, 2020

    @Gallaecio

    @kivikakk Any chance you could reopen this issue?

  10. flying-sheep commented on Sep 16, 2020

    @flying-sheep
    Contributor

    #1222 is an old attempt by me to fix this, and I assume it didn’t fix this because of gjtorikian/html-pipeline#302. Not entirely sure if that’s still the case.

    We just need someone at GitHub to start caring at some point.

  11. kivikakk commented on Sep 16, 2020

    @kivikakk
    Contributor

    I also don't work at GitHub anymore, sorry; contacting support remains your best option.

  12. Gallaecio commented on Sep 17, 2020

    @Gallaecio

    @kivikakk Sorry, I saw your commits were the most recent, I did not realize they were from more than 1 year ago.

    I wonder if GitHub is even maintaining this anymore.

  13. Gallaecio commented on Feb 22, 2021

    @Gallaecio

    @aharpole Could we reopen this issue?

  14. StefanBogdan commented on Apr 16, 2021

    @StefanBogdan

    I am experiencing the same problem. The README.rst does not take into account the :align: or :width: for me. But if I use the same README.rst as a long description for PyPI it is rendered exactly as I want. I think this should be reopened too.

  15. trevorld commented on May 24, 2021

    @trevorld

    In case people aren't aware of this workaround note Github does however respect align="right" within an html <img> tag contained within a restructuredText raw:: html directive e.g.

    .. raw:: html
    
       <img src="figures/logo.png" align="right" width="300px" alt="right-aligned logo in README">
    

    does work even if the equivalent rst image directive unfortunately does not:

    .. image:: figures/logo.png
      :align: right
      :width: 300
      :alt: right-aligned logo in README
    
  16. bmorris3 commented on Oct 18, 2022

    @bmorris3

    The align feature in rst seems to be working now! See example here.

  17. waldyrious commented on Oct 19, 2022

    @waldyrious

    The align feature in rst seems to be working now! See example here.

    At last! I assume this was fixed by #1452.

  18. omixann commented on Nov 17, 2022

    @omixann

    The align feature in rst seems to be working now! See example here.

    It doesn't work for me using a PNG file, either a local one or an URL.

  19. flying-sheep commented on Nov 19, 2022

    @flying-sheep
    Contributor

    Does work for us: https://github.com/scverse/anndata#readme

    It's a SVG, but I'm unsure how this could be relevant.

  20. Gallaecio commented on Nov 19, 2022

    @Gallaecio

    Both the linked examples work on my browsers (latest Firefox, latest Chromium).

    Captura de pantalla o 2022-11-19 ás 13 32 20
    Captura de pantalla o 2022-11-19 ás 13 32 06

  21. omixann commented on Nov 19, 2022

    @omixann

    Here you have a gist showcasing both cases https://gist.github.com/jmi2k/f422df7d4a67dde9c19e74d091c3582e.

  22. Gallaecio commented on Nov 21, 2022

    @Gallaecio

    Here you have a gist showcasing both cases https://gist.github.com/jmi2k/f422df7d4a67dde9c19e74d091c3582e.

    Interesting, the PNG one does not seem to get align="right" there.

  23. akkana commented on May 11, 2026

    @akkana

    Align still doesn't work in README.rst: see https://github.com/akkana/metapho/blob/master/README.rst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions