diff --git a/.babelrc b/.babelrc
new file mode 100644
index 0000000..2f01e1d
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,3 @@
+{
+ "presets": ["env"]
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..464232b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+node_modules/
+.DS_Store
+dist/
+.cache/
\ No newline at end of file
diff --git a/CNAME b/CNAME
deleted file mode 100644
index 257717a..0000000
--- a/CNAME
+++ /dev/null
@@ -1 +0,0 @@
-excel2latex.com
\ No newline at end of file
diff --git a/README.md b/README.md
index 2ae24b3..f060ae4 100644
--- a/README.md
+++ b/README.md
@@ -1,25 +1,32 @@
# Excel => LaTeX
-Check out the [demo](http://ericwood.org/excel2latex/).
+Check it out here: [excel2latex.com](http://excel2latex.com).
-A silly Javascript tool for converting Excel spreadsheets into LaTeX tables.
+A silly Javascript tool for converting Excel spreadsheets into LaTeX tables, born out of a desire to write tools to help me work on lab reports instead of actually writing lab reports.
-Right now I don't have any settings for what the resulting table looks like...I want to add this eventually, it's not difficult or anything. Sorry in advance if the formatting isn't what you're looking for, I'll make it more flexible in the future!
+### Local development
-I just whipped this up in a few hours for fun, and haven't really tested it much. Pleasepleaseplease let me know if you manage to break it, I'd really appreciate it.
+excel2latex is a static site built with [parcel](https://parceljs.org). If you're looking to contribute, you can run the site locally using these directions.
-### Compatability
+First, install the packages we need:
-Not completely sure, but most likely newer versions of Chrome, Firefox, and IE 10 will work great with this. Only tested on Chrome...this is just a little experiment ;)
+```bash
+npm install
+```
-### Shout outs
+Once that completes, you can boot up the dev server:
+
+```bash
+npm start
+```
+
+This will boot up an http server that you can access at `http://localhost:1234`. Hooray!
-Thanks to [zip.js](http://gildas-lormeau.github.com/zip.js/) for making this thing possible. It's a badass library.
### License
```
-Copyright (c) 2012, Eric Wood
+Copyright (c) 2018, Eric Wood
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -43,4 +50,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-```
+```
\ No newline at end of file
diff --git a/converter.js b/converter.js
deleted file mode 100644
index f97aced..0000000
--- a/converter.js
+++ /dev/null
@@ -1,226 +0,0 @@
-!(function($) {
- "use strict";
-
- // Global variable with information on current workbooks. Don't judge me.
- var workbooks = {};
-
- // Another global to store LaTeX output. Don't judge me...again...
- var latexOutput = {};
-
- var excelParser = {
- //latexEnvironment: 'tabular',
- latexEnvironment: 'array',
-
- latexEscape: function(text) {
- if(!$('#escape').is(':checked')) return text;
-
- var escapeRegExpr = function(str) {
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
- };
-
- var specials = ['\\', '&', '%', '$', '#', '_', '{', '}', '~', '^'];
- $.each(specials, function() {
- var regexp = new RegExp(escapeRegExpr(this), 'g');
- text = text.replace(regexp, '\\' + this, 'g');
- });
-
- return text;
- },
-
- parseStringTable: function(data) {
- var doc = $(data);
- var stringTags = doc.find('si');
- var strings = $.map(stringTags, function(s,i) {
- return $(s).find('t').text();
- });
-
- return strings;
- },
-
- toLatex: function(table) {
- var max = 0;
- for(var i=0; i < table.length; i++) {
- if(table[i] && table[i].length > max) { max = table[i].length; }
- }
-
- var numCols = max;
- var args = [];
- for(i=0; i < numCols; i++) {
- args[i] = 'l';
- }
- args = ' | ' + args.join(' | ') + ' | ';
- var latex = "\\begin{" + excelParser.latexEnvironment + "}{" + args + "}\n\\hline\n";
- for(i=0; i < table.length; i++) {
- var cols = table[i];
- // TODO: replace "&" with "\&"
- if(cols === undefined) { cols = []; }
- if(cols.length < numCols) {
- for(var x=cols.length; x < max; x++) {
- cols[x] = '\\ ';
- }
- }
-
- latex += "\t" + cols.join(' & ');
- latex += " \\\\ \\hline\n";
- }
-
- latex += "\\end{" + excelParser.latexEnvironment + "}\n";
-
- return latex;
- },
-
- processSheet: function(data, stringTable) {
- // get jQuery object out of the data for accessing stuffs
- var doc = $(data);
-
- var table = [];
-
- var rows = doc.find('sheetdata row');
- $.each(rows, function(i,row) {
- var rowNum = parseInt($(row).attr('r'), 10);
-
- // get columns
- var cols = $(row).find('c');
- var colVals = $.map(cols, function(col,j) {
- col = $(col);
- var val = excelParser.latexEscape(col.find('v').text());
- if(col.attr('t') == 's') {
- return excelParser.latexEscape(stringTable[parseInt(val, 10)]);
- } else {
- return val;
- }
- });
- table[rowNum-1] = colVals;
- });
-
- return table;
- },
-
- handleSheets: function(entries, stringTable) {
- // get the workbook.xml file, which contains the names of all workbooks
- var workbookMeta = entries.filter(function(entry) {
- return entry.filename === 'xl/workbook.xml';
- })[0];
-
- // filter out all files that aren't worksheets
- var sheets = $.grep(entries, function(n,i) {
- var filter1 = /^xl\/worksheets\/.*\.xml$/;
- var filter2 = /^xl\/worksheets\/_rels/;
- return (filter1.test(n.filename)) && (!filter2.test(n.filename));
- });
-
- // read the workbook meta data to get the names and crap
- workbookMeta.getData(new zip.TextWriter(), function(text) {
- var doc = $(text);
-
- // extract the names of the workbooks and their IDs for use later on...
- $.each(doc.find('sheets sheet'), function(i, tag) {
- tag = $(tag);
- var id = tag.attr('sheetId');
- var name = tag.attr('name');
- workbooks[id] = name;
- });
-
- excelParser.updateSelect();
-
- // iterate over all sheets and convert them to LaTeX
- $.each(sheets, function(_, sheet) {
- // the ID of the spreadsheet can only be found in the filename apparently :P
- var id = sheet.filename.match(/(\d)\.xml/)[1];
-
- sheet.getData(new zip.TextWriter(), function(text) {
- var table = excelParser.processSheet(text, stringTable);
- var latex = excelParser.toLatex(table);
- latexOutput[id] = latex;
-
- // I apologize for the hack :(
- if(id === '1') {
- excelParser.showOutput(1);
- }
- });
- });
- });
- },
-
- showOutput: function(id) {
- var latex = latexOutput[id];
- $('#latex-output').val(latex);
- $('#preview').html('$$\n' + latex + '\n$$');
- MathJax.Hub.Typeset("preview");
- },
-
- handleFiles: function(event) {
- // prevent default browser behavior
- event.stopPropagation();
- event.preventDefault();
-
- // get file information
- var files = event.dataTransfer.files;
- if(!files.length) {
- // no files were given somehow...
- $('#latex-output').val('No files were given...try again?');
- return false;
- }
-
- var blob = files[0];
-
- // unzip and process files
- zip.createReader(new zip.BlobReader(blob), function(reader) {
- reader.getEntries(function(entries) {
- if(!entries.length) { return false; }
-
- // get the string table
- var stFile = $.grep(entries, function(n,i) {
- var regexp = /^xl\/sharedStrings\.xml$/;
- return regexp.test(n.filename);
- })[0];
-
- stFile.getData(new zip.TextWriter(), function(text) {
- var stringTable = excelParser.parseStringTable(text);
- excelParser.handleSheets(entries, stringTable);
- });
-
- return undefined;
- });
- });
-
- return undefined;
- },
-
- updateSelect: function() {
- var select = $('#workbook');
-
- // clear existing option tags
- select.empty();
-
- for(var id in workbooks) {
- var tag = $('');
- tag.appendTo(select);
- }
- },
-
- init: function() {
- // hack because of jQuery shenanigans
- jQuery.event.props.push('dataTransfer');
-
- $('body').bind('dragover', function(event) {
- event.stopPropagation();
- event.preventDefault();
- event.dataTransfer.dropEffect = 'copy';
- });
-
- $('body').bind('drop', excelParser.handleFiles);
-
- // when a new workbook is selected, do stuff!
- $('#workbook').change(function(event) {
- var select = $(event.target);
- excelParser.showOutput(select.val());
- });
- }
- };
-
- $(function() {
- zip.workerScriptsPath = 'zip/';
- excelParser.init();
- });
-})(window.jQuery);
diff --git a/index.html b/index.html
index b5a726c..87ca05b 100644
--- a/index.html
+++ b/index.html
@@ -1,53 +1,6 @@
-
-
-
- Excel => LaTeX
-
-
-
-
-
-
-
-
-
excel => LaTeX
-
Drag any .xlsx file onto the page to extract data and convert it into a LaTeX table
-
-
-
-
-
-
-
-
-
-
-
-
Mostly untested, so if you find a bug or have a feature request, let me know!
-
Note: this only works with .xlsx files. That means .xls files will not work.
-
Formatting from the Excel document won't be preserved, only the text will be extracted.