Spaces / tabs / code blocks, spec 0.28


#1

I cannot figure out how to get processing right. Specifically, I can’t figure out how to agree with examples, 2, 5 and 85 in Spec 0.28. The question is about the number of spaces on the first line of a code block. Why does example 2 start with 6 spaces, and have no leading spaces after processing, where as example 5, which also starts with 6 spaces (in effect) does include 2 spaces. Example 85 is explicit about this, and consistent with example 5… so why is example 2 different?


#2

Example 6 further muddies the water for me - why does 8 spaces turn into 6 not 7? the grounds for removing 2 instead of 1 are not really explained?


#3

so why is example 2 different?

From the specs (the emphasis is mine):

Tabs in lines are not expanded to spaces. However, in contexts where whitespace helps to define block structure, tabs behave as if they were replaced by spaces with a tab stop of 4 characters.

Note it does not say “replaced with 4 spaces”. It uses the term tab stop. Your implementation must track offset since start of the line and, when it encounters a tab character, replace it with as many spaces as needed to reach next number divisible by four.

The logic is exactly the same as in any sane text editor, when you configure to use spaces instead of tab (with tab width set to 4).


#4

ah - stupid me. thanks.