function generateTable() {
    var $text = '';
    var $header = '| ';
    var $separator = '|';
    $("#table").find('tr').each(function () {

        $(this).find('td').each(function () {
            $text += '| ' + $(this).find('textarea').val() + ' ';
        });

        if ($(this).find('td').length != 0) {
            $text += '|\n'; //add pipe to end of line
        }

        $(this).find('th').each(function () { // header of table
            var $cell = $(this).find('textarea').val();
            $header += $cell + ' | ';
            for (var i = 0; i < $cell.length + 2; i++) {
                $separator += '-';
            }
            $separator += '|';
        });
    });
    putChar($header + '\n' + $separator + '\n' + $text, false); //put table in #editor
    $('#dialog').dialog('close');
}
/**
 * Found html table with id #table, convert it to Markdown table and put it in #editor.
 */
Found html table with id #table, convert it to Markdown table and put it in #editor.
Found html table with id #table convert it to Markdown table and put it in #editor .
function generateTable() {
    var $text = '';
    var $header = '| ';
    var $separator = '|';
    $("#table").find('tr').each(function () {
        $(this).find('td').each(function () {
            $text += '| ' + $(this).find('textarea').val() + ' ';
        });
        if ($(this).find('td').length != 0) {
            $text += '|\n'; 
        }
        $(this).find('th').each(function () { 
            var $cell = $(this).find('textarea').val();
            $header += $cell + ' | ';
            for (var i = 0; i < $cell.length + 2; i++) {
                $separator += '-';
            }
            $separator += '|';
        });
    });
    putChar($header + '\n' + $separator + '\n' + $text, false); 
    $('#dialog').dialog('close');
}
function generateTable ( ) { var $text = '' ; var $header = '| ' ; var $separator = '|' ; $ ( "#table" ) . find ( 'tr' ) . each ( function ( ) { $ ( this ) . find ( 'td' ) . each ( function ( ) { $text += '| ' + $ ( this ) . find ( 'textarea' ) . val ( ) + ' ' ; } ) ; if ( $ ( this ) . find ( 'td' ) . length != 0 ) { $text += '|\n' ; } $ ( this ) . find ( 'th' ) . each ( function ( ) { var $cell = $ ( this ) . find ( 'textarea' ) . val ( ) ; $header += $cell + ' | ' ; for ( var i = 0 ; i < $cell . length + 2 ; i ++ ) { $separator += '-' ; } $separator += '|' ; } ) ; } ) ; putChar ( $header + '\n' + $separator + '\n' + $text , false ) ; $ ( '#dialog' ) . dialog ( 'close' ) ; }
Found html table with id #table, convert it to Markdown table and put it in #editor.
Found html table with id #table convert it to Markdown table and put it in #editor .
//add pipe to end of line // header of table //put table in #editor