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

Improve the shortcode whitespace situation #9946

Closed
bep opened this issue May 28, 2022 · 1 comment
Closed

Improve the shortcode whitespace situation #9946

bep opened this issue May 28, 2022 · 1 comment
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented May 28, 2022

We have had some discussion in this area, which reminded me of how it can be to get the indentation/leading whitespace for shortcodes, especially shortcodes that outputs Markdown.

Some problem areas are nested Markdown lists, code blocks that's not clode blocks...

One example.

Shortcodes:

mark1.md:

{{ .Inner }}

mark2.md:

1. Item 1
1. Item 2
1. Item 3

And then, the Markdown file:

1. List 1
    {{% mark1 %}}
    1. Item 1
    1. Item 2
        {{% mark2 %}}
    {{% /mark1 %}}
    {{% mark2 %}}

With the above I would expect something like:

image

What I actually get is:

image

Proposed solution

  • If we record the leading whitespace before the shortcode when parsing the page (e.g tabs/spaces).
  • And then apply that indentation to the rendered result of shortcodes without inner content (where the user will apply indentation).
@bep bep added this to the v0.100.0 milestone May 28, 2022
@bep bep self-assigned this May 28, 2022
bep added a commit to bep/hugo that referenced this issue May 29, 2022
* Record the leading whitespace (tabs, spaces) before the shortcode when parsing the page.
* Apply that indentation to the rendered result of shortcodes without inner content (where the user will apply indentation).

Fixes gohugoio#9946
bep added a commit to bep/hugo that referenced this issue May 29, 2022
* Record the leading whitespace (tabs, spaces) before the shortcode when parsing the page.
* Apply that indentation to the rendered result of shortcodes without inner content (where the user will apply indentation).

Fixes gohugoio#9946
bep added a commit to bep/hugo that referenced this issue May 29, 2022
* Record the leading whitespace (tabs, spaces) before the shortcode when parsing the page.
* Apply that indentation to the rendered result of shortcodes without inner content (where the user will apply indentation).

Fixes gohugoio#9946
bep added a commit to bep/hugo that referenced this issue May 30, 2022
* Record the leading whitespace (tabs, spaces) before the shortcode when parsing the page.
* Apply that indentation to the rendered result of shortcodes without inner content (where the user will apply indentation).

Fixes gohugoio#9946
@bep bep closed this as completed in d2cfaed May 30, 2022
@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 Jun 21, 2022
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

1 participant