Skip to content

Rendered Markdown discards hard TABs #1368

@roxwize

Description

@roxwize

Describe the bug(?)

When creating a Markdown file that uses hard TABs (0x9) in code blocks instead of spaces, the Markdown renderer forcibly coerces them to four spaces.

To Reproduce

Create a Markdown file, and add a code block with tabs in it.

ˋˋˋc
int main() {
	return 0;
}
ˋˋˋ

Here, GitHub appears to keep the TABs intact. This is what I expect from the Copyparty client, but this does not seem to happen.

Expected behavior

The renderer shouldn't mangle the text, and should just leave the TABs as-is, including them inside of code blocks as just the TAB character by itself.

The tab-size CSS property is already widely supported across all major browsers and getting Stylus or similar to create a global style that sets this property to 8, 4, 2, or similar on all websites is trivial. Expanding them into spaces when rendering defeats the purpose of using TABs and is a pretty useless "feature". It is bound to mess with the layout of some text files, especially TSV files.

A better way to deal with this would be to just keep them as TABs and allow the user to change this tab-size property themself, or make it a configuration option on the client.

Screenshots

Image

Client details

  • OS version: NixOS 25.05
  • browser version: Firefox 145

Additional context

I understand that hard TABs vs spaces are a rather contentious issue and it may be easier to take the opinionated route and leave this as it is now, but fixing it instead of disregarding it as intentional would hurt nobody. Many people use spaces because they are happy with it, and they will never take issue with TABs being rendered verbatim... why would they?

This may be an issue with some Markdown renderer upstream if this project uses one, but I'm not sure if it does (and if it does, I wouldn't be surprised if there's some configuration option not being passed to it that would allow this behavior to happen as expected).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions