1.0.1 • Published 7 years ago

htmltabletolatex v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

HtmlTableToLatex

Converter html tables tables in latex

Installation

$ npm install htmltabletolatex --save

Usage

// httl = HtmlTableToLatex 
var httl = require('htmltabletolatex').HTTL;

httl.latex("mytables.html").then(latex => {
	// console.log("Latex tables:", latex);
	httl.save('latex.tex', latex.join('\n'), (err, success) => {});
});

Example

Html input

<table>
    <caption>Table: usuario </caption>        
    <tr>
        <th>Name</th>
        <th>Data Type</th>
        <th>Nullable</th>
        <th>PK</th>
        <th>FK</th>
        <th>Default</th>
        <th>Comment</th>
    </tr>
    <tr>
        <td>user_idUsuario</td>
        <td>VARCHAR(45)</td>
        <td>Yes</td>
        <td>Yes</td>
        <td>No</td>
        <td></td>
        <td></td>
    </tr>        
    <tr>
        <td>user_Correo</td>
        <td>VARCHAR(45)</td>
        <td>Yes</td>
        <td>No</td>
        <td>No</td>
        <td></td>
        <td></td>
    </tr>
</table>

Latex output

\begin{center}
	\caption{tableTableUsuario}
	\label{labelTableUsuario}
	\begin{tabular}{ |l|l|l|l|l|l|l| }
		\hline
		Name & DataType & Nullable & PK & FK & Default & Comment \\
		UserIdUsuario & VARCHAR(45) & Yes & Yes & No &  & \\ \hline
		UserCorreo & VARCHAR(45) & Yes & No & No &  & \\ \hline		
	\end{tabular}
\end{center}

API

constructor(args) -> HtmlTableToLatex

ParamTypeDescriptionDefault
minLengthColumnsByRownumberTake into account only columns by minimum size in text3
separatorstringTable columns size. i.e: l, c, rl
linesbooleanShow linestrue

Example

var HtmlTableToLatex = require('htmltabletolatex').HtmlTableToLatex;

var httl = new HtmlTableToLatex(2, 'l', false);

You can also change the parameters without the need of a constructor:

var httl = require('htmltabletolatex').HTTL;

httl.lines = false;
httl.minLengthColumnsByRow = 2;
httl.separator = 'l';

Colaborate

# Fork it this repo
# Install typescript cli
$ git clone https://github.com/<your-username>/HtmlTableToLatex.git
$ cd HtmlTableToLatex
# Edit & transpile file index.ts
# Commit + push + Pull request

License MIT

This software is released under the MIT License.