Fix markdown image with link#4675
Conversation
techknowlogick
left a comment
There was a problem hiding this comment.
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
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
will be put inside a link to itself, unless it's already inside a link, which is[](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.