-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 markdown image with link #4675
Conversation
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.
Can you add the Gitea copyright at the top of the file?
@techknowlogick , what do you mean? This is not a new file, and the copyright is already there markdown.go |
Needs to be added under the Gogs copyright |
I see, fixed in fdd8ceb . |
Codecov Report
@@ Coverage Diff @@
## master #4675 +/- ##
==========================================
+ Coverage 37.47% 37.49% +0.02%
==========================================
Files 310 310
Lines 45921 45922 +1
==========================================
+ Hits 17207 17217 +10
+ Misses 26239 26231 -8
+ Partials 2475 2474 -1
Continue to review full report at Codecov.
|
@LER0ever Thanks 😄 |
Tests would be needed for this |
@lafriks Tests added for images with links. Meanwhile, although this implementation is definitely gonna work, I still find this character locating approach a little bit dirty. |
* Fix markdown image with link * Add gitea copyright notice * add a test for markdown image with link * remove svg related variables
This PR fixes the image with link rendering. And therefore resolves #4569 and resolves #5207
Original Behavior
Images with
![alt](imgurl)
will be put inside a link to itself, unless it's an svg-file.The problem is that it hardcoded the svg filetype to be directly rendered in
<img>
tag, and other file types are rendered like<a><img></a>
which causes #4569 and #5207 .New Behavior in this PR
Images with
![alt](imgurl)
will be put inside a link to itself, unless it's already inside a link, which is[![alt](imgurl)](url)
.So we don't need to infer from filetype whether the image is a CI image or not.
Also, this matches the Github-Flavored Markdown's behavior on images with links.