marked
marked copied to clipboard
Code blocks must be left intact
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:
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.
Similar to #1559
It looks like this has been fixed since 4.0.14
Not completely, lines in code blocks that start with tabs are still converted to spaces. demo