timber icon indicating copy to clipboard operation
timber copied to clipboard

Explore spaces over tabs in documentation

Open gchtr opened this issue 6 years ago • 1 comments

In code examples, I’ve advocated for using spaces instead of tabs because of inconsistencies that came up when viewing code examples in Markdown files in readme files on GitHub (https://github.com/timber/timber/pull/1955#issuecomment-475418442 or https://github.com/timber/timber/pull/1890#issuecomment-451846607). The downside was that when copying code into your project, you’d have to change it to tabs again.

Recently, I stumbled over an interesting thread about this topic on Reddit: Nobody talks about the real reason to use Tabs over Spaces. The main point is that we should use tabs for accessibility reasons. The are different preferences for the indent size, especially for developer with visual impairment.

In this issue, I want to explore the best option to go forward. Apparently, when you define the indent size in the .editorconfig file, GitHub will respect that. It’s also possible to add ?ts=2 or ?ts=4 to the URL to change the indent size. I’ll have to check if the URL parameters overwrite what’s set in .editorconfig. There’s also the possibility to use the Refined GitHub browser extension, which changes the default tab size from 8 to 4, or a Chrome browser extension that changes the tab size only.

Currently, we only define an indent_style in editorconfig:

[*.md]
indent_style = space

We could add indent_size as well as trim_trailing_whitespace.

For the documentation on https://timber.github.io/docs/, we could make use of the tab-size property.

pre {
	-moz-tab-size: 4;
	tab-size: 4;
}

gchtr avatar Oct 23 '19 07:10 gchtr

What about implementing something like ...

https://github.com/Pickra/copy-code-block

... in the docs? I don't have experience with this particular lib, but I'm sure we could write a JS function in the background that coverts spaces --> tabs when copied

jarednova avatar Oct 31 '19 21:10 jarednova