-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
figure shortcode produces unwanted space inside anchor element #8401
Comments
call |
I have no idea what
produces
which is neither a link anchor nor an image. |
@jmooring All the checks in the patch (I have picked one at random)
still contain the problematic whitespace after the closing |
Upon further review I believe this is a solution without a problem. See https://jsfiddle.net/rbw5gL6u/.
Please post an example, using the existing shortcode template, where this is true. |
Will do, will take a bit, though. |
TLDR
The ElaborationI have not been able to shrink this problem to a minimum working example hugo website yet. The following is a screenshot from a test page demonstrating the problem with my blog only partially migrated from jekyll/octopress to hugo. This partially migrated website is not public. Note the horizontal blue line at the left edge of the text column, just above the bottom image: The HTML code being rendered is the following, where the only difference between the first image which is shown properly and the second image which has the weird horizontal line is the absence of whitespace before the
I have just manually edited the old blog page generated by jekyll/octopress (which I am in the middle moving over to hugo) to demonstrate the whitespace problem for anybody who wants to reproduce the weird underlined space rendering in their own browser: http://n-dimensional.de/blog/2015/04/20/cellphone-headset-on-pc-or-mini-mixer/ (that actually uses But Why Exactly?I remember always having had such rendering of whitespace betwheen Weirdly though, my 2021 attempts to find a minimum working example demonstrating the problem by creating a new hugo demo website from scratch have not been able to reproduce the problem yet so far. And now I want to know why my old jekyll/octopress generated blog shows the problem, my far from complete port of my blog to hugo shows the problem, but a simple HTML file written from scratch does not. Maybe the browser is selecting a strict rendering mode for one kind of page, but not for the other, and the whitespace rendering differs? |
Your site behaves this way because of line 331 of http://n-dimensional.de/stylesheets/screen.css.
https://developer.mozilla.org/en-US/docs/Web/CSS/white-space#values
|
Wow. Very good catch. I am so sorry for
I cannot find where I got this impression from, but my brain appears to have rearranged its memories in a way such that to me it appeared to have always been the case that whitespace in HTML anchors outside image elements always leads to weird renderings. I have traced the origin of the
As it is, hugo's Changing the I do not know how widely in use Anyway, FWIW, now that I have signed the CLA, this would be the patch with what I still think is a fix, but not of quite so broad an appeal I originally thought. (I had been unaware earlier that I can signing the CLA electronically and that it does not involve me hiring an attorney to figure out and snail-mail hundreds of pages of legalese.) This patch does not involve any test code, however. For some reason, building hugo from source only works with warnings and "mage check" throws so many warnings even on an unmodified build that I have no idea where to start.
If you do not want to waste more time on this updating the test cases, I would offer to submit a pull request with updated test cases at some time in the future, whenever I get around to make hugo properly build from source here. This involves learning about the whole Go language and language ecosystem, though, so this might take some time. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When used to generate a link like
the
figure
shortcode produces unwanted whitespace inside the anchor tag, and that whitespace will be shown underlined in many cases, which looks confusing to say the least:This applies to both the
hugo-0.80.0-2.fc34.x86_64
package Fedora is shipping,both when using its builtin
figure
shortcode and when using today'smaster
branch (cf the SHA in the link below) copied intothemes/THEME/layouts/shortcodes/figure.html
.Taking a look at the implementation of the
figure
shortcode and playing around a bit, I found that wrapping the newlines and whitespace between the tag beginning the<a>
element and the<img
tag can be commented out with<!-- ... -->
allowing to keep the existing indentation of the source, while stopping generating the unwanted whitespace:An alternative fix would be to "just" remove the whitespace from the source code, which also works, but that makes the code much more difficult to read.
No patch included, as I have not signed any CLA at this time.
The text was updated successfully, but these errors were encountered: