timothycrosley / jiphy

Your client side done in a jiphy. Python to JavaScript 2-way converter.
MIT License
585 stars 73 forks source link

wrong block groupings #18

Open fabiommendes opened 8 years ago

fabiommendes commented 8 years ago

Jiphy does not group code blocks correctly when going from python to js. The newline to close a block seems silly to me:

if x:
    line_of_code()
    this_is_in_the_same_js_block()

    this_is_not()
i_am_scoped_with_the_previous_line()

You might preserve the same lines in js by closing the block in its last line

if (x){
    line_of_code();
    this_is_in_the_same_js_block();

    this_is_not();}
i_am_scoped_with_the_previous_line();

Python tokenizer takes care of indents, show it should not be so difficult to break the blocks like this