rst: use CSS for image alignment.#1222
Conversation
3020bf6 to
7c27fbd
Compare
|
content = File.read('test2.txt') |
|
@flying-sheep do you know if any of the other options are not working? You may want to update the branch so the CI can re-run (it now uses GitHub actions). |
|
Well, you use the https://github.com/github/markup/blob/master/test/markup_test.rb#L44-L47 This means that these defaults are used: https://github.com/gjtorikian/html-pipeline/blob/0e3d84eb13845e0d2521ef0dc13c9c51b88e5087/lib/html/pipeline/sanitization_filter.rb#L133 Changing the config in the tests here won’t change what GitHub does. And the defaults are bad: They allow the obsolete We have to make GitHub parametrize its use of |
|
Regarding you question:
|
Would that be too hard to do? It seems like it must be done in order for the tests to pass. That does point out that it might still end up being stripped by GitHub in their prod pipeline, but as stated in html-pipeline GitHub uses a similar pattern, but not that gem.
So either way they need to be aware they should not be stripping the inline styles. |
|
From this on the README:
this fix may never work unless they do allow some inline styles. |
|
Pretty much only this one. But we need someone from GitHub providing transparency here. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Not my fault that there has been no recent activity |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
oh my god. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
hey @team can you PLEASE pin this or fix this? |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
still no. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
continues to be no. thinking about making a bot to bump this. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Please, anyone help. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
been a month already huh? |
There was a problem hiding this comment.
Pull request overview
Updates the reStructuredText (.rst) renderer to preserve image alignment after sanitization (fixes #163), and adds a fixture-based test case covering right-aligned images.
Changes:
- Override the Docutils HTML translator’s
visit_imageto inject alignment styling into generated<img>tags. - Add an
.. image::example with:align: rightto the RST test document. - Update the expected sanitized HTML fixture to include the aligned
<img>output.
Show a summary per file
| File | Description |
|---|---|
| test/markups/README.rst | Adds an aligned image directive to exercise the alignment behavior. |
| test/markups/README.rst.html | Updates expected sanitized HTML output to include the aligned <img>. |
| lib/github/commands/rest2html | Implements custom visit_image logic to apply alignment via injected styling. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
| self.body.append('</table>\n') | ||
|
|
||
| def visit_image(self, node): | ||
| """Custom visit_image for using the HTML align attribute for |
| if align: | ||
| if ' style="' in self.body[-1]: | ||
| old, new = ' style="', ' style="float: %s; ' % align | ||
| else: | ||
| old, new = ' />', ' style="float: %s" />' % align | ||
| self.body[-1] = self.body[-1].replace(old, new) |
|
Hey @flying-sheep — thanks for putting this together, and sorry it's been sitting for so long without a clear resolution. After taking a close look at this PR with fresh eyes, I believe the core approach here won't work in production due to how GitHub's sanitization pipeline handles the output. Specifically: The
The deprecated HTML There are also a couple of secondary issues:
I think the right move here is to close this PR given how long it's been open and how much rework would be needed. If RST image alignment is something we want to revisit, a fresh issue would be a better starting point — potentially exploring the Thanks again for the contribution and the thoughtful discussion in the thread over the years. 🙏 |
|
Closing per the review above. If RST image alignment is still desired, a fresh issue would be the best path forward. |
fixes #163