Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rst: use align-attribute for images #179

Closed
wants to merge 1 commit into from
Closed

Conversation

jone
Copy link

@jone jone commented Jan 3, 2013

At the moment it is impossible to change the image alignment when using restructured text on github (see #163).

The docutils HTMLTranslator is using css-classes for alignment, which are stripped by github later.
Using the HTML align attribute would be more appropriate, I think.

This pull-request adds the alignment value from restructured text in figure and image statements as align value to the HTML img tag.

I'm not sure whether this is the way it should be for github, but I think it should work well.

docutils uses css-classes (e.g. align-right) but css-classes are stripped later on,
which breaks image alignment.
Using the HTML align-attribute the alignment works without css too.
@artob
Copy link

artob commented Mar 13, 2013

+1. This would be great to have supported.

@russkel
Copy link

russkel commented Jul 20, 2013

In HTML5 the align attribute has been deprecated.

@gjtorikian
Copy link
Contributor

@jone jone closed this Jan 12, 2014
@Bengt
Copy link

Bengt commented Jun 4, 2014

Wouldn't it be better to translate RST's :align: attribute to an CSS attribute that is equivalent to HTML's deprecated align attribute instead of dropping it altogether?

Using CSS is the way advised by the W3Schools:

The align attribute of is not supported in HTML5. Use CSS instead.
For the image to align middle, top, or bottom use the CSS property vertical-align.
For the image to align left or right use the CSS property float.

So for example this RST

.. image :: http://example.com/favicon.ico
   :align: right

could become this HTML

<img src="http://example.com/favicon.ico" style="float:right" />

and this RST

.. image :: http://example.com/favicon.ico
   :align: top

would become this HTML

<img src="http://example.com/favicon.ico" style="vertical-align:top" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants