html - How are tabs interpreted in CommonMark? -


see description before example 6 in commonmark spec at: http://spec.commonmark.org/0.27/#example-5

i trying understand how following code leads code-block starting 2 spaces.

>→→foo 

example 6 shows translate following.

<blockquote> <pre><code>  foo </code></pre> </blockquote> 

but section 2.2 states:

however, in contexts whitespace helps define block structure, tabs behave if replaced spaces tab stop of 4 characters.

so per understanding, above markdown behaves following (i denote space dot).

>........foo 

since, 1 optional space allowed after >, , 4 spaces used indent code block, left with,

>...foo 

that's code-block starting 3 spaces. how commonmark claim should lead code-block starting 2 spaces? missing?

the key in first paragraph of tabs section (emphasis added):

tabs in lines not expanded spaces. however, in contexts whitespace helps define block structure, tabs behave if replaced spaces tab stop of 4 characters.

notice says "4 characters" not 4 spaces.

if configure text editor use tab stop of length 4 , replace tabs spaces (any text editor should offer setting), text editor use columns 4 characters wide. when press tab key, forward cursor next column, every 4 characters wide. if column contains characters, many spaces added total 4 characters, which, in case less 4 spaces.

for example, if type angle bracket (>) character in editor , press tab, following (when configured replace tabs spaces):

>··· 

therefore angle bracket plus tab moves forward end of column (four characters) total of three spaces. @ beginning of next column, pressing tab second time move next column (4 more spaces) total of 7 spaces:

>······· 

we can confirm correct interpretation more recent change spec committed in 3bc01c5dc (which apparently hasn't made it release yet). commit comment suggests, clarification helps math make more sense (emphasis added):

normally > begins block quote may followed optionally space, not considered part of content. in following case > followed tab, treated if expanded three spaces. since 1 of these spaces considered part of delimiter, foo considered indented 6 spaces inside block quote context, indented code block starting 2 spaces.

notice added sentence (in bold) confirms first tab adds "three spaces".

therefore, have established, start angle bracket plus 7 spaces. first break off blockquote deliminator, consists of angle bracket , first space (in following examples | used indicate parser breaks string , should not counted characters):

>·|······ 

the text contained in blockquote indented six spaces. 4 of them code block deliminator:

>·|····|·· 

which leaves two spaces @ start of code block.

of course, stated @ beginning (of section in spec), tabs aren't replaced spaces, behaves if were. , can confusing @ times. may configure text editor replace tabs spaces , can avoid confusion.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -