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

youtube in tab broken #626

Open
aCuria opened this issue Jun 9, 2024 · 4 comments
Open

youtube in tab broken #626

aCuria opened this issue Jun 9, 2024 · 4 comments

Comments

@aCuria
Copy link

aCuria commented Jun 9, 2024

I realized that using {{< youtube ...>}} inside a {{< tab ... >}} does not work for some reason.

It does work outside the tab.

@alex-shpak
Copy link
Owner

Hi! Unfortunately I don't think I can fix it on theme side.
Looks like youtube shortcode generates whitespaces (indentation) and markdown renderer turn it into blockquote

@pasabanov
Copy link

I couldn't reproduce the issue using the {{< >}} syntax:

{{< tabs >}}
  {{< tab 123 >}}
    {{< youtube 0RKpf3rK57I >}}
  {{< /tab >}}
  {{< tab 234 >}}
    {{< youtube 0RKpf3rK57I >}}
  {{< /tab >}}
{{< /tabs >}}

, but I've managed to reproduce it using the {{% %}} syntax either in tab or tabs:

{{< tabs >}}
{{< tab 123 >}}
{{< youtube 0RKpf3rK57I >}}
{{< /tab >}}
{{% tab 234 %}}
{{< youtube 0RKpf3rK57I >}} <!-- broken -->
{{% /tab %}}
{{< /tabs >}}

{{% tabs %}}
{{< tab 123 >}}
{{< youtube 0RKpf3rK57I >}} <!-- broken -->
{{< /tab >}}
{{< tab 234 >}}
{{< youtube 0RKpf3rK57I >}} <!-- broken -->
{{< /tab >}}
{{% /tabs %}}

Removing the indentation in layouts/shortcodes/tab.html doesn't solve the issue.

It is possible to copy the builtin youtube.html file and modify it by removing the indentation. I verified that this solves the problem.
It may be worth creating an issue in the Hugo repository.

@pasabanov
Copy link

The issue can also be solved by replacing {{- .Inner -}} in layouts/shortcodes/tab.html by {{- .Inner | strings.TrimSpace | .Page.RenderString -}}, but it may break the formatting of other content that depends on indentation.

@alex-shpak
Copy link
Owner

Hello!
Yes, .Page.RenderString will help with rendering youtube shortcode, but it will lead to issues,
.Page.RenderString will render markdown in new context, so headers and footnotes would not be carried into page,

A bit of time ago I changed from RenderString here
925dbd3

To have better support for ToC and Footnotes, tho, you can add editer or alternative shortcode in your site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants