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

hugo_stats.json: bad tag if html element contains tab character #8417

Closed
yaaax opened this issue Apr 14, 2021 · 4 comments
Closed

hugo_stats.json: bad tag if html element contains tab character #8417

yaaax opened this issue Apr 14, 2021 · 4 comments
Milestone

Comments

@yaaax
Copy link

yaaax commented Apr 14, 2021

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.82.0+extended darwin/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes

Description

Steps to reproduce

  1. One markdown file needs to contain an HTML element (e.g. form) declared on several lines, with tabs for indentation, as this example:
<form
	action="[URL]"
	method="post"
>

## Random markdown content
Foo bar
  1. Run hugo server -e production

Expected:

Tag "form" should be added within the list of tags within hugo_stats.jsonfile.

Actual:

Tag "form\n\taction=\"[URL]\"\n\tmethod=\"post\"" is added within the list of tags in hugo_stats.json file.

Note:

The issue does not happen if the form is declared in one line :

<form action="[URL]" method="POST">

Similar issue already raised here: #7958
Maybe also related to #8396

@jmooring
Copy link
Member

jmooring commented Apr 14, 2021

I am unable to reproduce the problem.

git clone --single-branch -b hugo-github-issue-8417 https://github.com/jmooring/hugo-testing hugo-github-issue-8417
cd hugo-github-issue-8417
hugo
cat hugo_stats.json

Also, according to the CommonMark specification, an HTML block must be followed by a blank line. That is why the page renders incorrectly. You can try it here.

@yaaax
Copy link
Author

yaaax commented Apr 15, 2021

Thanks @jmooring for your advice regarding the blank line.

I've managed to reproduce the issue with tabs instead of spaces for indentation.

Note: I'm not sure if it's a good practice or not 🤔
I personally prefer tab vs spaces for indentation, in general, that's why I've set up prettier to format my files that way.. but there might by something wrong here?

@jmooring jmooring changed the title hugo_stats.json: bad tag if html element is written on several lines hugo_stats.json: bad tag if html element contains tab character Apr 15, 2021
@jmooring
Copy link
Member

Thank you. I've update the minimal reproducible example, and the title of this issue. The simplest failing example is:

<hr[TAB]id=a>

The CommonMark specification provides many examples of using tabs for indentation, so your preference is technically sound.

@bep bep added the Bug label Apr 15, 2021
@bep bep added this to the v0.83 milestone Apr 15, 2021
dirkolbrich added a commit to dirkolbrich/hugo that referenced this issue Apr 17, 2021
- Reorder code blocks
- Rename cssClassCollectorWriter to htmlElementCollectorWriter, as it just collect html element information
- Expand benchmark to test for minified and unminified content

Fixes gohugoio#8396, Fixes gohugoio#8417
dirkolbrich added a commit to dirkolbrich/hugo that referenced this issue Apr 20, 2021
- Reorder code blocks
- Rename cssClassCollectorWriter to htmlElementCollectorWriter, as it just collect html element information
- Expand benchmark to test for minified and unminified content

Fixes gohugoio#8396, Fixes gohugoio#8417
@bep bep closed this as completed in bc80022 Apr 20, 2021
@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 Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants