donpark / html2jade

Converts HTML to Jade template. Not perfect but useful enough for non-daily conversions.
MIT License
1.18k stars 156 forks source link

multiline html attributes should escape the newline with \ to create valid jade. #46

Closed vivainio closed 11 years ago

vivainio commented 11 years ago

I have html like this:

    <img src="img/close_button.png" height="16" width="16" alt="Home"
    onclick="
        mwl.switchClass('#search_title', 'show_title_search', 'show_title_main');
        mwl.setGroupTarget('#navigateToggle', '#home', 'show', 'hide');
        mwl.switchClass('#slider', 'show_miniapp', 'show_main');
        mwl.scrollTo('#main');"/>

It produces jade like this

img(src='img/close_button.png', height='16', width='16', alt='Home', onclick='
mwl.switchClass("#search_title", "show_title_search", "show_title_main");
mwl.setGroupTarget("#navigateToggle", "#home", "show", "hide");
mwl.switchClass("#slider", "show_miniapp", "show_main");
mwl.scrollTo("#main");')

This doesn't pass jade parser. html2jade should prefix the line endings with \ within the attritube value, like this:

img(src='img/close_button.png', height='16', width='16', alt='Home', onclick=' \
mwl.switchClass("#search_title", "show_title_search", "show_title_main"); \
mwl.setGroupTarget("#navigateToggle", "#home", "show", "hide"); \
mwl.switchClass("#slider", "show_miniapp", "show_main"); \
mwl.scrollTo("#main");')
donpark commented 11 years ago

You're absolutely right. I left out the corner case completely. Doh.

vivainio commented 11 years ago

Thanks, works fine with my html document now.