Make input escaping optional. Fixes #11

This commit is contained in:
Eric Wood 2017-01-04 18:24:24 -05:00
parent 6495006a0f
commit d01d0c3cb6
No known key found for this signature in database
GPG Key ID: 645B0CD779EED3B5
2 changed files with 12 additions and 4 deletions

View File

@ -12,6 +12,8 @@
latexEnvironment: 'array',
latexEscape: function(text) {
if(!$('#escape').is(':checked')) return text;
var escapeRegExpr = function(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
@ -63,7 +65,7 @@
}
latex += "\\end{" + excelParser.latexEnvironment + "}\n";
return latex;
},
@ -110,7 +112,7 @@
// 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);
@ -125,12 +127,12 @@
$.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);

View File

@ -29,6 +29,12 @@
<select id="workbook" name="workbook"></select>
<textarea id="latex-output" readonly="readonly" onclick="this.select();"></textarea>
<div class="settings">
<input type="checkbox" name="escape" id="escape" checked="checked">
<label for="escape">Escape input text</label>
</div>
<p>Mostly untested, so if you find a bug or have a feature request, <a href="https://github.com/eric-wood/excel2latex/issues">let me know!</a>
<p class="disclaimer">Note: this only works with .xlsx files. That means .xls files will <b>not</b> work.</p>
<p>Formatting from the Excel document won't be preserved, only the text will be extracted.</p>