Skip to content

render: fix center image test #3880

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

Merged
merged 1 commit into from
Sep 7, 2021
Merged

render: fix center image test #3880

merged 1 commit into from
Sep 7, 2021

Conversation

gagath
Copy link
Contributor

@gagath gagath commented Aug 31, 2021

The image test is actually not representative and will not center the image. This fix helps users discover how to center images and proves that they will be centered on crates.io.

Note: I am the original author of this testcase from PR #3862

@rust-highfive
Copy link

r? @carols10cents

(rust-highfive has picked a reviewer for you, use r? to override)

let result = markdown_to_html(text, None);
assert_eq!(
result,
"<img src=\"https://img.shields.io/crates/v/clap.svg\" alt=\"\" align=\"center\">\n"
"<p align=\"center\"><img src=\"https://img.shields.io/crates/v/clap.svg\" alt=\"\"></p>\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't these cases already sufficiently tested by the text_alignment test above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text_alignment test guarantees that the align attribute can be set for <h1> and <h5> HTML tags. By being explicit in this other test, we make sure that centering images will always be supported by catching any possible future regression. Testing is cheap, finding regressions is hard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be renamed to paragraph_alignment then? I guess the <p> doesn't care whether a <img> is inside or not 😅

Copy link
Contributor Author

@gagath gagath Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right that the <p> does not care currently. But maybe in a future release the <p> will care because of implementation changes. The usecase I want to cover is centering images in README.md on crates.io, so I make sure that this particular usecase is tested and will continue to work in the future.

It also as a side effect documents how to center images on crates.io for users.

@Turbo87
Copy link
Member

Turbo87 commented Sep 7, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Sep 7, 2021

📌 Commit 34191ae has been approved by Turbo87

@Turbo87 Turbo87 added A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear labels Sep 7, 2021
@bors
Copy link
Contributor

bors commented Sep 7, 2021

⌛ Testing commit 34191ae with merge ab8f24b...

@bors
Copy link
Contributor

bors commented Sep 7, 2021

☀️ Test successful - checks-actions
Approved by: Turbo87
Pushing ab8f24b to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants