web/js/export.js
/**
 * Exports a list of tables into LaTeX
 * @param {list} table - List of tables to be exported
 * @returns {string} The list of tables converted into LaTeX
 */
Exports a list of tables into LaTeX
@param {list} table - List of tables to be exported
@returns {string} The list of tables converted into LaTeX
Exports a list of tables into LaTeX @param { list } table - List of tables to be exported @returns { string } The list of tables converted into LaTeX
function exportTableToLaTeX($table) {
    switch ($table.length) {
        case 0:
            return '';
            break;
        case 1:
            String.prototype.repeat = function (n, d) {
                return --n ? this + (d || "") + this.repeat(n, d) : "" + this;
            };
            var $firstrow = $table.find('tr:has(th)'),
                tmpColDelim = String.fromCharCode(11), 
                tmpRowDelim = String.fromCharCode(0), 
                colDelim = "&",
                rowDelim = "\\\\\n",
                latex = "\\begin{tabular}{"+"c".repeat($firstrow.find('th').length,"|")+"}\n",
                latex = latex + $firstrow.map(function (i, row) {
                    var $row = $(row),
                        $cols = $row.find('th');
                    return $cols.map(function (j, col) {
                        var $col = $(col),
                            text = $col.text();
                        return text;
                    }).get().join(tmpColDelim);
                }).get().join(tmpRowDelim)
                        .split(tmpRowDelim).join(rowDelim)
                        .split(tmpColDelim).join(colDelim);
                latex = latex + "\\\\\n\\hline\n",
                $rows = $table.find('tr:has(td)'),
                latex = latex + $rows.map(function (i, row) {
                    var $row = $(row),
                        $cols = $row.find('td');
                    return $cols.map(function (j, col) {
                        var $col = $(col),
                            text = $col.text();
                        return text;
                    }).get().join(tmpColDelim);
                }).get().join(tmpRowDelim)
                        .split(tmpRowDelim).join(rowDelim)
                        .split(tmpColDelim).join(colDelim);
                latex = latex + "\n\\end{tabular}";
            return latex;
            break;
        default:
            return $.map($table, function(v) {
                    return exportTableToLaTeX($(v));
                }).join('\n\n');
    }
}
function exportTableToLaTeX ( $table ) { switch ( $table . length ) { case 0 : return '' ; break ; case 1 : String . prototype . repeat = function ( n , d ) { return -- n ? this + ( d || "" ) + this . repeat ( n , d ) : "" + this ; } ; var $firstrow = $table . find ( 'tr:has(th)' ) , tmpColDelim = String . fromCharCode ( 11 ) , tmpRowDelim = String . fromCharCode ( 0 ) , colDelim = "&" , rowDelim = "\\\\\n" , latex = "\\begin{tabular}{" + "c" . repeat ( $firstrow . find ( 'th' ) . length , "|" ) + "}\n" , latex = latex + $firstrow . map ( function ( i , row ) { var $row = $ ( row ) , $cols = $row . find ( 'th' ) ; return $cols . map ( function ( j , col ) { var $col = $ ( col ) , text = $col . text ( ) ; return text ; } ) . get ( ) . join ( tmpColDelim ) ; } ) . get ( ) . join ( tmpRowDelim ) . split ( tmpRowDelim ) . join ( rowDelim ) . split ( tmpColDelim ) . join ( colDelim ) ; latex = latex + "\\\\\n\\hline\n" , $rows = $table . find ( 'tr:has(td)' ) , latex = latex + $rows . map ( function ( i , row ) { var $row = $ ( row ) , $cols = $row . find ( 'td' ) ; return $cols . map ( function ( j , col ) { var $col = $ ( col ) , text = $col . text ( ) ; return text ; } ) . get ( ) . join ( tmpColDelim ) ; } ) . get ( ) . join ( tmpRowDelim ) . split ( tmpRowDelim ) . join ( rowDelim ) . split ( tmpColDelim ) . join ( colDelim ) ; latex = latex + "\n\\end{tabular}" ; return latex ; break ; default : return $ . map ( $table , function ( v ) { return exportTableToLaTeX ( $ ( v ) ) ; } ) . join ( '\n\n' ) ; } }
Exports a list of tables into LaTeX
 @param {list} table - List of tables to be exported
 @returns {string} The list of tables converted into LaTeX
Exports a list of tables into LaTeX @param { list } table - List of tables to be exported @returns { string } The list of tables converted into LaTeX
/*Función para repetir un string un determinado número de veces.*/ // Temporary delimiter characters unlikely to be typed by keyboard // This is to avoid accidentally splitting the actual contents // vertical tab character // null character // Actual delimiter characters for LaTeX format /*Primera línea de la tabla LaTeX.*/ /*Resto de líneas de la tabla LaTeX.*/ /*Última línea de la tabla LaTeX.*/