rst: use CSS for image alignment.
fixes #163
content = File.read('test2.txt') detection = CharlockHolmes::EncodingDetector.detect(content) utf8_encoded_content = CharlockHolmes::Converter.convert content, detection[:encoding], 'UTF-8'
https://github.com/github/markup/commit/9173626
@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 HTML::Pipeline::SanitizationFilter without options:
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 align on all elements, but not style="float: left".
We have to make GitHub parametrize its use of HTML::Pipeline::SanitizationFilter to allow some specific styles. Or update the defaults of that library to allow that: gjtorikian/html-pipeline#302
Regarding you question: alt and target work, those do not:
widthandheightare done as CSS and stripped by sanitation (boo! But we could make this library emitwidthandheightattributes instead)scaleis ignored by the rst2html command in the first place (I assume there’s some option to make it read the image and addwidthandheightwith the correct values, because it was written before CSSscale()existed)
We have to make GitHub parametrize its use of
HTML::Pipeline::SanitizationFilterto allow some specific styles.
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.
This project was started at GitHub. While GitHub still uses a similar design and pattern for rendering content, this gem should be considered standalone and independent from GitHub.
So either way they need to be aware they should not be stripping the inline styles.
From this on the README:
- The HTML is sanitized, aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and class or id attributes.
this fix may never work unless they do allow some inline styles.
Pretty much only this one. width and height are OK as attributes, but align is deprecated in favor of style="float: …".
But we need someone from GitHub providing transparency here.