markup icon indicating copy to clipboard operation
markup copied to clipboard

rst: use CSS for image alignment.

Open flying-sheep opened this issue 7 years ago • 20 comments

fixes #163

flying-sheep avatar Aug 10 '18 11:08 flying-sheep

content = File.read('test2.txt') detection = CharlockHolmes::EncodingDetector.detect(content) utf8_encoded_content = CharlockHolmes::Converter.convert content, detection[:encoding], 'UTF-8'

kayyymarieee avatar Oct 20 '18 16:10 kayyymarieee

https://github.com/github/markup/commit/9173626

kayyymarieee avatar Oct 20 '18 16:10 kayyymarieee

@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).

terencehonles avatar Apr 03 '21 01:04 terencehonles

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

flying-sheep avatar Apr 03 '21 10:04 flying-sheep

Regarding you question: alt and target work, those do not:

  • width and height are done as CSS and stripped by sanitation (boo! But we could make this library emit width and height attributes instead)
  • scale is ignored by the rst2html command in the first place (I assume there’s some option to make it read the image and add width and height with the correct values, because it was written before CSS scale() existed)

flying-sheep avatar Apr 03 '21 10:04 flying-sheep

We have to make GitHub parametrize its use of HTML::Pipeline::SanitizationFilter to 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.

terencehonles avatar Apr 03 '21 20:04 terencehonles

From this on the README:

  1. 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.

terencehonles avatar Apr 03 '21 20:04 terencehonles

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.

flying-sheep avatar Apr 05 '21 09:04 flying-sheep