Skip to content

strip blank line from examples in <pre> #1398

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

Merged
merged 1 commit into from
May 13, 2021
Merged

Conversation

ratijas
Copy link
Contributor

@ratijas ratijas commented May 9, 2021

There is a special parsing rule for the <pre> tag itself which forces to
ignore the leading line breaks to be removed1. But it does not work on a
nested <code> tag.


I am sure there should be a better way to do it. Heck, I'm not even sure if this would be rendered correctly! But for now, pointing out a problem, and providing you with such PR is the best I can do.

There is a special parsing rule for the <pre> tag itself which forces to
ignore the leading line breaks to be removed[1]. But it does not work on a
nested <code> tag.

[1]: https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody
Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ratijas thank you for this :)

I tested it manually:

before:
grafik

after:
grafik

Since my frontend knowledge is limited I would love to have another pair of eyes on this change.

@Nemo157
Copy link
Member

Nemo157 commented May 10, 2021

Looks like an ok hack for now, it'd be nice if tera had some better way to do this.

@syphar
Copy link
Member

syphar commented May 11, 2021

Looks like an ok hack for now, it'd be nice if tera had some better way to do this.

Do you know any way to do this with tera? I think even the jinja2 trim_blocks and lstrip_blocks wouldn't help here, because it's about whitespace between HTML tags, and not jinja tags.

@syphar
Copy link
Member

syphar commented May 13, 2021

I checked if other template had the same problem and didn't find any other occurrences.

Also a quick search didn't find any nicer way of doing this with tera without too much complexity.

@syphar syphar added the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label May 13, 2021
@syphar syphar merged commit 0236fab into rust-lang:master May 13, 2021
@ratijas ratijas deleted the patch-1 branch May 13, 2021 10:12
@ratijas
Copy link
Contributor Author

ratijas commented May 13, 2021

Also a quick search didn't find any nicer way of doing this with tera without too much complexity.

That's because pages are stored as half-rendered HTML. Wouldn't have been a problem with markdown + syntax highlighted triple-backtick code blocks.

@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Nov 30, 2021
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

Successfully merging this pull request may close these issues.

3 participants