From 12b43eac031660c8a0aec1a3285db41dcc2346c8 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Wed, 5 Feb 2014 08:42:22 -0500 Subject: [PATCH] updating to 0.5.1 --- xlsx.js | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/xlsx.js b/xlsx.js index f9f20c8..c019471 100644 --- a/xlsx.js +++ b/xlsx.js @@ -420,7 +420,7 @@ SSF.load_table = function(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i]) SSF.loa make_ssf(SSF); var XLSX = {}; (function(XLSX){ -XLSX.version = '0.5.0'; +XLSX.version = '0.5.1'; var current_codepage, current_cptable, cptable; if(typeof module !== "undefined" && typeof require !== 'undefined') { if(typeof cptable === 'undefined') cptable = require('codepage'); @@ -460,12 +460,14 @@ if (typeof exports !== 'undefined') { _fs = require('fs'); } } +var attregexg=/(\w+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g; +var attregex=/(\w+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/; function parsexmltag(tag) { var words = tag.split(/\s+/); var z = {'0': words[0]}; if(words.length === 1) return z; - (tag.match(/(\w+)="([^"]*)"/g) || []).map( - function(x){var y=x.match(/(\w+)="([^"]*)"/); z[y[1]] = y[2]; }); + (tag.match(attregexg) || []).map( + function(x){var y=x.match(attregex); z[y[1]] = y[2].substr(1,y[2].length-2); }); return z; } @@ -674,26 +676,11 @@ function ReadShift(size, t) { this.l+=size; return o; } -function CheckField(hexstr, fld) { - var b = this.slice(this.l, this.l+hexstr.length/2); - var m = b.hexlify ? b.hexlify() : __hexlify(b); - if(m !== hexstr) throw (fld||"") + 'Expected ' + hexstr + ' saw ' + m; - this.l += hexstr.length/2; -} - -function WarnField(hexstr, fld) { - var b = this.slice(this.l, this.l+hexstr.length/2); - var m = b.hexlify ? b.hexlify() : __hexlify(b); - if(m !== hexstr) console.error((fld||"") + 'Expected ' + hexstr +' saw ' + m); - this.l += hexstr.length/2; -} - function prep_blob(blob, pos) { blob.read_shift = ReadShift.bind(blob); - blob.chk = CheckField; blob.l = pos || 0; - var read = ReadShift.bind(blob), chk = CheckField.bind(blob); - return [read, chk]; + var read = ReadShift.bind(blob); + return [read]; } function parsenoop(blob, length) { blob.l += length; } @@ -719,8 +706,8 @@ var parse_RichStr = function(data, length) { var str = parse_XLWideString(data); var z = { t: str, - raw:"" + escapexml(str) + "", - r: str + r:"" + escapexml(str) + "", + h: str }; if(fRichStr) { /* TODO: formatted string */ @@ -911,15 +898,15 @@ var parse_si = function(x) { /* 18.4.12 t ST_Xstring (Plaintext String) */ if(x[1] === 't') { z.t = utf8read(unescapexml(x.substr(x.indexOf(">")+1).split(/<\/t>/)[0])); - z.raw = x; - z.r = z.t; + z.r = x; + z.h = z.t; } /* 18.4.4 r CT_RElt (Rich Text Run) */ else if((y = x.match(//))) { - z.raw = x; + z.r = x; /* TODO: properly parse (note: no other valid child can have body text) */ z.t = utf8read(unescapexml(x.replace(/<[^>]*>/gm,""))); - z.r = parse_rs(x); + z.h = parse_rs(x); } /* 18.4.3 phoneticPr CT_PhoneticPr (TODO: needed for Asian support) */ /* 18.4.6 rPh CT_PhoneticRun (TODO: needed for Asian support) */ @@ -1260,9 +1247,9 @@ function parseComments(data) { var textMatch = x.match(/([^\u2603]*)<\/text>/m); if (!textMatch || !textMatch[1]) return; // a comment may contain an empty text tag. var rt = parse_si(textMatch[1]); - comment.raw = rt.raw; - comment.t = rt.t; comment.r = rt.r; + comment.t = rt.t; + comment.h = rt.h; commentList.push(comment); }); return commentList; @@ -1306,7 +1293,7 @@ function insertCommentsIntoSheet(sheetName, sheet, comments) { if (!cell.c) { cell.c = []; } - cell.c.push({a: comment.author, t: comment.t, raw: comment.raw, r: comment.r}); + cell.c.push({a: comment.author, t: comment.t, r: comment.r, h: comment.h}); }); } @@ -1339,7 +1326,7 @@ function parse_worksheet(data) { /* 18.3.1.4 c CT_Cell */ var cells = x.substr(x.indexOf('>')+1).split(/