$ python flexibleindent.py flexibleindent.pyhtml
-------------------- script
_buf.extend(('''<html>
  <body>
    <div id="main-content">\n''', ));
if items:
    _buf.extend(('''      <table>
        <tbody>\n''', ));
    i = 0
    for item in items:
        i += 1
        _buf.extend(('''          <tr>
            <td>''', escape(to_str(i)), '''</td>\n''', ));
        if item:
            _buf.extend(('''            <td>''', escape(to_str(item)), '''</td>\n''', ));
        else:
            _buf.extend(('''            <td>-</td>\n''', ));
        #endif
        _buf.extend(('''          </tr>\n''', ));
    #endfor
    _buf.extend(('''        </tbody>
      </table>\n''', ));
#endif
_buf.extend(('''    </div>
  </body>
</html>\n''', ));

-------------------- html
<html>
  <body>
    <div id="main-content">
      <table>
        <tbody>
          <tr>
            <td>1</td>
            <td>AAA</td>
          </tr>
          <tr>
            <td>2</td>
            <td>-</td>
          </tr>
          <tr>
            <td>3</td>
            <td>CCC</td>
          </tr>
        </tbody>
      </table>
    </div>
  </body>
</html>

