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
x/website: inconsistent tabs in code snippets #52255
Comments
Change https://go.dev/cl/399374 mentions this issue: |
Change https://go.dev/cl/399394 mentions this issue: |
Go code uses real tabs, so perhaps the web pages should as well. I admit that I don't know the advantages or disadvantages of either choice. |
@ianlancetaylor most of the code on the website is written with tabs which are equal to 4 real spaces, that’s why I assumed it as the correct choice. The reason behind this likely that all major modern browsers render tab 8 characters wide. In editors and IDEs one can choose whatever width she wants. Since the only purpose of tab indentation is readability, I think 4-characters width performs its role well because code snippets have both small height and nesting. But I would happily turn them into real tabs, consistency is the only concern I have |
any updates? |
CC @jamalc |
any updates? |
Let's stick with tabs for code snippets. This keeps the snippets consistent with actual Go code and the Go playground. Doc authors won't have to worry about converting snippets and readers can copy correct code from docs. |
anyway
only until authors decide to use markdown instead of HTML as a file extension. Consider this case in _content/doc/tutorial/workspaces.md on lines 80–81. It has 3-space indentation because it’s a part of a list item
and rendered like this
If one puts 3 spaces and then adds a tab, he will see in browser
edit: grammar |
Fair enough. Spaces then. |
thank you! I abandoned my another PR included in this issue after your reply because it rendered the PR irrelevant. Now it is restored and located at https://go.dev/cl/399394 Can I kindly ask you to review that one as well, please? |
Fixes #52255 Change-Id: Ibb518cf2f6bac9e1ffc426a014afe80cc4c0df5e Reviewed-on: https://go-review.googlesource.com/c/go/+/399394 Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
visited go.dev/doc/articles/wiki, go.dev/doc/effective_go, go.dev/doc/code, go.dev/doc/faq, go.dev/ref/mem, and https://go.dev/ref/spec. In some places, real tabs are used instead of 4 spaces. The problem is that the former case is equal to 8 spaces in browsers, but the majority of code on go.dev are rendered using the latter representation, so indentation is not consistent. The following screenshot is taken from go.dev/doc/articles/wiki and contains the first Go code snippet. You can copy the first tab to search for it on other pages
I made 2 PRs because some pages are not in x/website but in this repo instead. To prevent this in future, maybe I can create a test checking contents inside every
<pre>
tag for tabs. I could suggest to create a replacer instead, but there are some cases when it will result in messed indentation, e.g. in the spec. What do you think?What did you expect to see?
consistent indentation
What did you see instead?
inconsistent one
The text was updated successfully, but these errors were encountered: