Skip to content
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

Single whitespace character after custom link template for Goldmark #6832

Closed
jsonmaur opened this issue Jan 31, 2020 · 10 comments
Closed

Single whitespace character after custom link template for Goldmark #6832

jsonmaur opened this issue Jan 31, 2020 · 10 comments

Comments

@jsonmaur
Copy link

Hugo Static Site Generator v0.62.1/extended darwin/amd64 BuildDate: unknown

I needed a way to make markdown links open in a new tab with target="_blank". Was able to do this in Blackfriday with the hrefTargetBlank config option, but for Goldmark I followed the instructions exactly as outlined here. This works, but for some reason it produces a single space character directly after the link. I've ensured render-link.html doesn't have any trailing spaces or lines.

Let me know if this issue would be better filed under the Goldmark library.

Source:
Screen Shot 2020-01-30 at 19 41 39

Rendered:
Screen Shot 2020-01-30 at 19 42 32

Console:
Screen Shot 2020-01-30 at 19 40 38

bep added a commit that referenced this issue Jan 31, 2020
@bep
Copy link
Member

bep commented Jan 31, 2020

I've ensured render-link.html doesn't have any trailing spaces or lines.

I have added another test for this, to be sure, and that passes (no whitespace added) -- so I'm pretty sure the problem must live in your template, which I don't see.

@jsonmaur
Copy link
Author

I've created a sample repo that re-creates the problem, and here's the built and deployed site.

After further investigation, it only seems to happen if the link is directly followed by something other than whitespace. If it's directly followed by whitespace, it doesn't add an additional character.

bep added a commit to bep/hugo-issue-6832 that referenced this issue Jan 31, 2020
@bep
Copy link
Member

bep commented Jan 31, 2020

@jakejarvis
Copy link
Contributor

What code editor are you using? I had the same issue — was positive I didn't put a newline at the end but VS Code was adding one automatically every time I saved. Easy fix was to remove the newline with something like nano. :)

@bep
Copy link
Member

bep commented Jan 31, 2020

I used VS Code for this. I suspect there is a setting somewhere "to add newline automatic". In many situations it makes sense, not this.

@bep bep closed this as completed Jan 31, 2020
@jsonmaur
Copy link
Author

Wait so how did you remove the trailing whitespace in that PR? I can't even tell it's there and am unable to get it removed in sublime, vim, or nano. You can't even see it in GitHub. Really strange--I've never had this issue before.

Thanks so much for taking the time to look into this.

@bep
Copy link
Member

bep commented Jan 31, 2020

Wait so how did you remove the trailing whitespace in that PR?

I ... deleted it. None of my editors inserts auto-newlines into HTML files. As an added note, I use Bud Parr's Hugo extension in VS Code, but I don't think that has anything to do with this.

@dirkkelly
Copy link

Thanks @bep, can confirm it was the trailing whitespace in our render-link file.

@jsonmaur if you want to fix it in sublime you need to change your settings to disable the automatic newline

image

When there is no new line in a file on Github, it will show the red circle cross saying so, eg:
image

@jsonmaur
Copy link
Author

Yeah, what's really strange is it was happening in other editors as well. Not just Sublime. But good to know the issue is on my end. I'll figure it out. Thanks for the help everyone.

@github-actions
Copy link

github-actions bot commented Feb 7, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants