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

Code blocks must be left intact #1668

Open
fredck opened this issue May 8, 2020 · 3 comments
Open

Code blocks must be left intact #1668

fredck opened this issue May 8, 2020 · 3 comments
Labels
category: code blocks L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue

Comments

@fredck
Copy link

fredck commented May 8, 2020

Describe the bug
Code blocks are very controlled content, where the author has intent (and full responsibility) on everything inside it. Right now, tabs inside code blocks are replaced by 4 spaces. This is (probably in most of the cases) semantically incorrect.

To Reproduce
Steps to reproduce the behavior:

  1. Marked Demo
  2. CommonMark Demo

Expected behavior
The contents of the code block should be left intact (tabs untouched).


Many times, code in a document is used as an example or reference to be copied/pasted or used "as is". Marked is not aware of the purpose of the code, so it should not take action on it and leave it intact.

This is a real world example of this problem: ckeditor/github-writer#170. The code block is a suggestion for changes to source code and they can be merged as the author wrote it. Marked is changing the code though and, basically, breaking the author contribution.

I can imagine this being a problem on many other contexts as well.


I've seen similar issues here for the same problem. Most of them are not clear and mainly closed. I wanted to refresh this problem with this issue.

@UziTech UziTech added category: code blocks L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue labels May 8, 2020
@UziTech
Copy link
Member

UziTech commented May 8, 2020

Similar to #1559

@azmy60
Copy link
Contributor

azmy60 commented May 20, 2023

It looks like this has been fixed since 4.0.14

@UziTech
Copy link
Member

UziTech commented May 24, 2023

Not completely, lines in code blocks that start with tabs are still converted to spaces. demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: code blocks L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue
Projects
None yet
Development

No branches or pull requests

3 participants