Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
My tabs are converted into spaces #36
All whitespace is normalized to spaces prior to parsing a document based on the value assigned to
I should note that if you are using the current code in the repo,
i don’t quite understand why they are converted at all. To normalize it? then tabs would be more sensible (1 tab = 1level of indentation, ¾ less bytes used)
Either way, it should support
First, this is a Python implementation of the original perl implementation by John Gruber. It is noteworthy that John's implementation replaces tabs with spaces as well. We are copying that behavior and are not likely to change unless he does (very unlikely).
That said, here are my responses to your specific comments:
If you could guarantee that every document author consistently always used either one of spaces or tabs, there would be no need for normalizing whitespace. However, that would be an unrealistic expectation. Especially on documents edited by multiple people (wiki pages?). By normalizing whitespace to use all spaces, we eliminate a lot of potential edge case bugs (in those inconsistent documents).
True, we could normalize to tabs, but there are actually a number of peculiarities to the Markdown syntax which makes spaces easier to work with (we often find
we could do this easily by converting the first tab of each line into x spaces (while retaining the following ones) and then using the current code-block-finding code. this would even work for aforementioned abominations. afaik there aren’t nested code blocks in markdown.
PS: i only found tab_length being used in blockprocessors.py, where else is it used?
so, what’s going on?
i really want my code to be retained as it is and not changed. e.g. when coding in genie, converting tabs to spaces introduces syntax errors (you have to specify in this languages how many spaces one indentation level should have. without this specification, it’s 1 tab per indentation level)
everything inside a code block shouldn’t be touched.
referenced this issue
Oct 19, 2012
I am trying to put code from a Makefile into a Markdown preformatted block and the normalization makes the resulting code invalid, since tabs are semantic in Makefiles.
It is impossible to fix this in a post-processing step because I also often include code snippets - in Make any other languages - that have eight or more spaces in a row.
In fact the Markdown "standard" says:
I'd count whitespace folding/normalize as "regular Markdown syntax". It shouldn't be happening - code blocks should deindent and HTML entity escape, and nothing else.