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

[Page: Editor] Inconsistent tab size. #25

Closed
wischi-chr opened this issue May 21, 2021 · 3 comments · Fixed by exercism/website#1030
Closed

[Page: Editor] Inconsistent tab size. #25

wischi-chr opened this issue May 21, 2021 · 3 comments · Fixed by exercism/website#1030
Assignees

Comments

@wischi-chr
Copy link

I found this accidentally and am not even sure if one consider it a bug.

While solving a rust exercise and playing around with the setting "Tab enabled" I ended up submitting a file with different indentation styles (mixed spaces and tab) in the editor the file looks like this (Line 20 has tab indentation)

image

And in the "Your iterations" tab it looked like this (Line 20):

image

IMHO both options are fine but they should be consistent.

@iHiD
Copy link
Member

iHiD commented May 21, 2021

@ErikSchierboom Probably worth you taking a look at this but you might want @kntsoriano's input too.

@ErikSchierboom
Copy link
Member

I've found that there are two issues here:

  1. The configured language's tab size is not passed on to highlightjs.
  2. Leading spaces or tabs are ignored (stripped).

You can see an example of that by going to https://exercism.lol/tracks/csharp/exercises/annalyns-infiltration/solutions/ErikSchierboom

The first line actually contains four leading spaces, which are not in the output.
The second line contains a tab, which uses a width of 8.

For the tab size, I've found that there is a tabReplace option, but that seems to be global: https://highlightjs.readthedocs.io/en/latest/api.html#configure-options

@joshgoebel Any idea how best to approach these issues?

@joshgoebel
Copy link

For the tab size, I've found that there is a tabReplace option, but that seems to be global:

tabReplace is going away in v11, though it's easy to do via a plugin. Honestly we [Highlight.js] don't care about tab size. The best thing is to normalize the tabs to spaces before asking us to highlight the content. It's possible to do this with a plugin, or it's possible to do this entirely before it reaches us.

There is also CSS tab-size now https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size which might be a quicker solution to some of these problems. IE, one could apply tab-size per language (say with a .language-python selector) to control the tab sizes inside the code using purely CSS.

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 a pull request may close this issue.

5 participants