-
-
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
Markdownify and .Summary sometimes produce an unclosed <p> tag #7372
Comments
I found the problematic function: // TrimShortHTML removes the <p>/</p> tags from HTML input in the situation
// where said tags are the only <p> tags in the input and enclose the content
// of the input (whitespace excluded).
func (c *ContentSpec) TrimShortHTML(input []byte) []byte {
firstOpeningP := bytes.Index(input, paragraphIndicator)
lastOpeningP := bytes.LastIndex(input, paragraphIndicator)
lastClosingP := bytes.LastIndex(input, closingPTag)
lastClosing := bytes.LastIndex(input, closingIndicator)
if firstOpeningP == lastOpeningP && lastClosingP == lastClosing {
input = bytes.TrimSpace(input)
input = bytes.TrimPrefix(input, openingPTag)
input = bytes.TrimSuffix(input, closingPTag)
input = bytes.TrimSpace(input)
}
return input
} Commit history:
But before we think about fixing the |
Curiously, I noticed that |
for mardownify I ended up with this systematic code in order to get valid HTML syntax and consistent css behaviour. I guess you can adapt for summary.
I do that |
also see #7069 |
One of the problem is that But when we have one line in .Content or in .Summary, there is no |
Clearly I am not the only one frustrated by See also: The average person expects a function named As a parallel, imagine if you ran this code: Having |
Replicate this issue consistently with When feeding the following with
I got a missing
I'm on:
|
Running
I confirm markdownify on a single line text parameter will not wrap the content into Having following in front-matter:
On the layout I'm doing the following:
The result is: Lorem <em>ipsum</em> dolor sit amet Expected result would be: <p>Lorem <em>ipsum</em> dolor sit amet</p> note: if there are multiple lines, the tags are being added correctly. The problem occurs only when there's a single line of content. |
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. |
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. |
What version of Hugo are you using?
To reproduce:
Expected result:
Actual result:
The closing
</p>
tag for the paragraph is missing.Additional bug?
When a single line summary is provided, no
<p></p>
tag is rendered at all. It's possible that this is the expected behavior, but it feels incorrect to me. A user could very easily make the following mistake, thinking that paragraph tags would be added in both examples.If that is the expected behavior, is there at least a way to ensure that the summary is always processed by markdown?
The text was updated successfully, but these errors were encountered: