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

Templates for inline code don't remove leading and trailing whitespace #7309

Closed
Traumflug opened this issue May 23, 2020 · 9 comments
Closed

Comments

@Traumflug
Copy link

What version of Hugo are you using?

0.71.0, the currently latest release.


This is a followup to #6832, which didn't receive a solution.

Regarding newlines at EOF

Having a newline at end of file isn't exactly strange, but Unix standard. On Unix, text without a newline isn't a line, a text file without a newline inside is considered empty by many tools.

  • Github agrees on this, it renders this red error mark at EOF without newline (e.g. here).
  • Command line Git agrees on this, it complains about the missing newlines at EOF.
  • CLI tools like wc don't count text without newline.
  • ...

That's why code editors usually add newlines at EOF automatically.

Regarding whitespace at BOF

Similar for leading whitespace: many code projects add copyright headers and similar stuff early in every file (e.g. Hugo). Hugo nicely supports this and removes comments for rendering, but this usually leaves some leading whitespace behind.

In short ...

Hugo should really remove whitespace at start and end of templates used inline. Just as if the whole file was wrapped in {{- and -}}.

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Sep 20, 2020
@nekr0z
Copy link
Contributor

nekr0z commented Sep 21, 2020

Still an issue to consider, I suppose.

@stale stale bot removed the Stale label Sep 21, 2020
@bep
Copy link
Member

bep commented Sep 21, 2020

Still an issue to consider, I suppose.

Maybe, but you need to take this upstream in the Go project.

@nekr0z
Copy link
Contributor

nekr0z commented Sep 21, 2020

Maybe, but you need to take this upstream in the Go project.

Ah, I see. Then we should indeed not attempt to solve it as a part of Hugo. Is there a way to label it as an upstream issue, just for the sake of documentation and clarity?

@bep bep added the Upstream label Sep 21, 2020
@bep
Copy link
Member

bep commented Sep 21, 2020

But also note that I have seen many "template whitespace discussions" on that issue tracker, and I would not be too optimistic. T

@github-actions
Copy link

github-actions bot commented Mar 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Mar 8, 2022
@nekr0z
Copy link
Contributor

nekr0z commented Mar 8, 2022

I'd keep this one open, but I don't insist.

@github-actions github-actions bot removed the Stale label Mar 9, 2022
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Mar 9, 2023
@github-actions github-actions bot closed this as completed May 5, 2023
@github-actions
Copy link

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 May 26, 2023
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

3 participants