donpark / html2jade

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

Syntax error #79

Closed Wolfr closed 10 years ago

Wolfr commented 10 years ago

If I pass the following HTML (split button from Twitter Bootstrap)...

<!-- Split button -->
<div class="btn-group">
  <button type="button" class="btn btn-danger">Action</button>
  <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
    <span class="caret"></span>
    <span class="sr-only">Toggle Dropdown</span>
  </button>
  <ul class="dropdown-menu" role="menu">
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
    <li><a href="#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a></li>
  </ul>
</div>

...through HTML2jade with the following options (using a file called test.html)...

html2jade test.html --nspaces 4 -s --bodyless

...the output contains a syntax error on line 3:

    // Split button
    .btn-group
        button.btn.btn-danger(type='button') Action
        button.btn.btn-danger.dropdown-toggle(type='button' data-toggle='dropdown')
            span.caret
            span.sr-only Toggle Dropdown
        ul.dropdown-menu(role='menu')
            li
                a(href='#') Action
            li
                a(href='#') Another action
            li
                a(href='#') Something else here
            li.divider
            li
                a(href='#') Separated link

The part where it says "(type='button' data-toggle='dropdown')" should have a comma between the attributes.

The http://html2jade.aaron-powell.com/ version also has problems where the comment in the output does not look right:

    //
         Split button 
        .btn-group
          button.btn.btn-danger(type='button') Action
          button.btn.btn-danger.dropdown-toggle(type='button', data-toggle='dropdown')
            span.caret
            span.sr-only Toggle Dropdown
          ul.dropdown-menu(role='menu')
            li
              a(href='#') Action
            li
              a(href='#') Another action
            li
              a(href='#') Something else here
            li.divider
            li
              a(href='#') Separated link
donpark commented 10 years ago

Hi @Wolfr. -s option you've used is a shorthand for --scalate which generates Scalate-variant of Jade syntax which didn't support comma-separated attributes. It's been awhile since I've looked at Scalate so I'm not sure if this is still true or not. Leaving out that option will generate output with comma-separated attributes.

Wolfr commented 10 years ago

Aha OK, thanks so much!