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

Incomplete HTML in .AlertTitle and .Text of Blockquote render hooks #12913

Closed
Lruihao opened this issue Oct 8, 2024 · 1 comment · Fixed by #13122
Closed

Incomplete HTML in .AlertTitle and .Text of Blockquote render hooks #12913

Lruihao opened this issue Oct 8, 2024 · 1 comment · Fixed by #13122

Comments

@Lruihao
Copy link

Lruihao commented Oct 8, 2024

Reproduce Steps

Given the following Markdown:

> [!NOTE] Hugo

> [!NOTE] _Hugo_
> The world’s fastest framework for building websites

> [!NOTE] **Hugo**

> [!TIP] **Hugo** FixIt

and the following render-blockquote-alert.html

{{ warnf "%s\t%s" .AlertTitle .Text }}

Actual results is .AlertTitle lost the trailing > and .Text in a start <p> without a closing tag:

WARN  Hugo      <p>
WARN  <em>Hugo</em      <p>The world’s fastest framework for building websites</p>
WARN  <strong>Hugo</strong      <p>
WARN  <strong>Hugo</strong> FixIt       <p>

Expected results (complete .AlertTitle and .Text):

WARN  Hugo      <p></p>
WARN  <em>Hugo</em>      <p>The world’s fastest framework for building websites</p>
WARN  <strong>Hugo</strong>      <p></p>
WARN  <strong>Hugo</strong> FixIt       <p></p>

BTW, if content body of alert is empty, .Text return nil seems better.

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

hugo v0.135.0+extended darwin/arm64 BuildDate=2024-09-27T13:17:08Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes

@Lruihao
Copy link
Author

Lruihao commented Oct 9, 2024

@bep Excuse me, could you take a look at this issue, please! 🙏

I think these problems should be in the following two places, but I am not familiar with go and don't know how to correct them. Can anyone help me?

if typ == typeAlert {
// Trim preamble: <p>[!NOTE]<br>\n but preserve leading paragraph.
// We could possibly complicate this by moving this to the parser, but
// keep it simple for now.
text = "<p>" + text[strings.Index(text, "\n")+1:]
}

var blockQuoteAlertRe = regexp.MustCompile(`^<p>\[!([a-zA-Z]+)\](-|\+)?[^\S\r\n]?([^\n]*)\n?`)
func resolveBlockQuoteAlert(s string) blockQuoteAlert {
m := blockQuoteAlertRe.FindStringSubmatch(s)
if len(m) == 4 {
title := strings.TrimSpace(m[3])
title = strings.TrimRight(title, "</p>")
return blockQuoteAlert{
typ: strings.ToLower(m[1]),
sign: m[2],
title: title,
}
}
return blockQuoteAlert{}
}

@bep bep removed the NeedsTriage label Oct 13, 2024
@bep bep added this to the Unscheduled milestone Oct 13, 2024
@jmooring jmooring self-assigned this Dec 9, 2024
jmooring added a commit to jmooring/hugo that referenced this issue Dec 9, 2024
jmooring added a commit to jmooring/hugo-admonitions that referenced this issue Dec 14, 2024
- Remove workaround
- Set minimum required version

gohugoio/hugo#12913 was resolved with
the release of v0.140.0.
jmooring added a commit to jmooring/hugo-admonitions that referenced this issue Dec 14, 2024
- Remove workaround
- Set minimum required version

gohugoio/hugo#12913 was resolved with
the release of v0.140.0.
jmooring added a commit to jmooring/hugo-admonitions that referenced this issue Dec 14, 2024
- Remove workaround
- Set minimum required version

gohugoio/hugo#12913 was resolved with
the release of v0.140.0.
jmooring added a commit to jmooring/hugo-admonitions that referenced this issue Dec 14, 2024
- Remove workaround
- Set minimum required version

gohugoio/hugo#12913 was resolved with
the release of v0.140.0.
jmooring added a commit to jmooring/hugo-admonitions that referenced this issue Dec 14, 2024
- Remove workaround
- Set minimum required version

gohugoio/hugo#12913 was resolved with
the release of v0.140.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@jmooring @bep @Lruihao and others