-
Notifications
You must be signed in to change notification settings - Fork 521
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
Fix #4859, #4530: Images in 'li' tags display in inline rather than block mode. #5286
Conversation
@adhiamboperes, PTAL. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Vishwajith-Shettigar!
I am looking for more clarity on the intended solution here - the code added does not appear to directly solve the issue.
utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt
Outdated
Show resolved
Hide resolved
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Vishwajith-Shettigar! PTAL.
utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL @Vishwajith-Shettigar.
|
||
// Images are wrapped inside a <div> tag, because the <div> tag is a block-level element, | ||
// so that all images display in block mode and on a new line." | ||
val modifiedHtmlContent = rawString.replace(regex) { | ||
val oppiaImageTag = it.value | ||
"""<div>$oppiaImageTag</div>""" | ||
} | ||
htmlContent = modifiedHtmlContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the suggested fix was to:
- Instead of wrapping the image in element, we can actually surround it with newlines (\n) at start and end because this is similar to the div implementation. Div is a block-level element, and at this point, we are already handling the image as a block.
- Instead of hardcoding this inside HtmlParser.kt, these new lines should be added before and after setspan in ImageTagHandler.kt. This makes the code less fragile/brittle.
- In the test, we can now remove the spaces assertion.
"""\n
${output.setSpan(
ImageSpan(drawable, source),
startIndex,
endIndex,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)}
\n"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll look at it.
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @Vishwajith-Shettigar, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Explanation
Fixes #4859, wrapped images inside div tag to display images in block mode.
Fixes #4530, passing (maxAvailableWidth - maxContentItemPadding) instead of passing maxAvailableWidth to calculate InitialMargin helps prevent the image from being cut off.
Essential Checklist
For UI-specific PRs only
If your PR includes UI-related changes, then: