jonathantneal/posthtml-md

Indenting logic is not valid with `code` rule

notcodingtoday opened this issue · 0 comments

Input:

` ` `
just_some_text
just_some_text2
` ` `

` ` `
def some_function():
    #some code. Note that there are 4 spaces infront.
` ` `

Expected output:

just_some_text
just_some_text2

def some_function():
    #somecode

Real output:

just_some_text
\t\t\t\tjust_some_text2

def some_function():
\t\t\t\t#somecode

Note that completely unrelated first code block was impacted.

I've made a mitigation by removing space from indents calculation:

var indents = node.match(/^[\t]+(?=\S)/gm);

So that space as a prefix does not contribute to indenting logic.