diff --git a/bits/22_xmlutils.js b/bits/22_xmlutils.js index 0718876..fd14702 100644 --- a/bits/22_xmlutils.js +++ b/bits/22_xmlutils.js @@ -238,6 +238,17 @@ function write_vt(s, xlsx/*:?boolean*/)/*:string*/ { throw new Error("Unable to serialize " + s); } +function xlml_normalize(d)/*:string*/ { + if(has_buf &&/*::typeof Buffer !== "undefined" && d != null && d instanceof Buffer &&*/ Buffer.isBuffer(d)) return d.toString('utf8'); + if(typeof d === 'string') return d; + /* duktape */ + if(typeof Uint8Array !== 'undefined' && d instanceof Uint8Array) return utf8read(a2s(ab2a(d))); + throw new Error("Bad input format: expected Buffer or string"); +} +/* UOS uses CJK in tags */ +var xlmlregex = /<(\/?)([^\s?>:\/]+)(?:[\s?:\/][^>]*)?>/mg; +//var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg; + var XMLNS = ({ 'dc': 'http://purl.org/dc/elements/1.1/', 'dcterms': 'http://purl.org/dc/terms/', diff --git a/bits/75_xlml.js b/bits/75_xlml.js index 229042c..5d64aed 100644 --- a/bits/75_xlml.js +++ b/bits/75_xlml.js @@ -162,18 +162,7 @@ function xlml_clean_comment(comment/*:any*/) { comment.v = comment.w = comment.ixfe = undefined; } -function xlml_normalize(d)/*:string*/ { - if(has_buf &&/*::typeof Buffer !== "undefined" && d != null && d instanceof Buffer &&*/ Buffer.isBuffer(d)) return d.toString('utf8'); - if(typeof d === 'string') return d; - /* duktape */ - if(typeof Uint8Array !== 'undefined' && d instanceof Uint8Array) return utf8read(a2s(ab2a(d))); - throw new Error("Bad input format: expected Buffer or string"); -} - /* TODO: Everything */ -/* UOS uses CJK in tags */ -var xlmlregex = /<(\/?)([^\s?>:\/]+)(?:[\s?:\/][^>]*)?>/mg; -//var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg; function parse_xlml_xml(d, _opts)/*:Workbook*/ { var opts = _opts || {}; make_ssf(SSF); diff --git a/bits/79_html.js b/bits/79_html.js index 92b1884..4867930 100644 --- a/bits/79_html.js +++ b/bits/79_html.js @@ -59,7 +59,7 @@ var HTML_ = (function() { return ws; } function html_to_book(str/*:string*/, opts)/*:Workbook*/ { - var mtch = str.match(/
0){if(n[n.l]===42){n.l+=u;continue}++n.l;a[++b]=[];w=0;for(w=0;w!=d.length;++w){var k=n.slice(n.l,n.l+d[w].len);n.l+=d[w].len;Qr(k,0);var E=cptable.utils.decode(h,k);switch(d[w].type){case"C":if(E.trim().length)a[b][w]=E.replace(/\s+$/,"");break;case"D":if(E.length===8)a[b][w]=new Date(+E.slice(0,4),+E.slice(4,6)-1,+E.slice(6,8));else a[b][w]=E;break;case"F":a[b][w]=parseFloat(E.trim());break;case"+":;case"I":a[b][w]=l?k._R(-4,"i")^2147483648:k._R(4,"i");break;case"L":switch(E.trim().toUpperCase()){case"Y":;case"T":a[b][w]=true;break;case"N":;case"F":a[b][w]=false;break;case"":;case"?":break;default:throw new Error("DBF Unrecognized L:|"+E+"|");}break;case"M":if(!s)throw new Error("DBF Unexpected MEMO for type "+i.toString(16));a[b][w]="##MEMO##"+(l?parseInt(E.trim(),10):k._R(4));break;case"N":E=E.replace(/\u0000/g,"").trim();if(E&&E!=".")a[b][w]=+E||0;break;case"@":a[b][w]=new Date(k._R(-8,"f")-621356832e5);break;case"T":a[b][w]=new Date((k._R(4)-2440588)*864e5+k._R(4));break;case"Y":a[b][w]=k._R(4,"i")/1e4;break;case"O":a[b][w]=-k._R(-8,"f");break;case"B":if(f&&d[w].len==8){a[b][w]=k._R(8,"f");break};case"G":;case"P":k.l+=d[w].len;break;case"0":if(d[w].name==="_NullFlags")break;default:throw new Error("DBF Unsupported data type "+d[w].type);}}}if(i!=2)if(n.l":r.strike=1;break;case"":break;case"":;case"":r.u=1;break;case"":break;case"":;case"":r.b=1;break;case"":break;case"":;case"":r.i=1;break;case"":break;case"");t.push("")}var n=e.valign||"";if(n=="superscript"||n=="super")n="sup";else if(n=="subscript")n="sub";if(n!=""){r.push("<"+n+">");t.push(""+n+">")}t.push("");return e}function t(t){var a=[[],t.v,[]];if(!t.v)return"";if(t.s)r(t.s,a[0],a[2]);return a[0].join("")+a[1].replace(e,"
")+a[2].join("")}return function a(e){return e.map(t).join("")}}();var Tf=/<(?:\w+:)?t[^>]*>([^<]*)<\/(?:\w+:)?t>/g,_f=/<(?:\w+:)?r>/;var xf=/<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;function Af(e,r){var t=r?r.cellHTML:true;var a={};if(!e)return{t:""};if(e.match(/^\s*<(?:\w+:)?t[^>]*>/)){a.t=We(qe(e.slice(e.indexOf(">")+1).split(/<\/(?:\w+:)?t>/)[0]||""));a.r=qe(e);if(t)a.h=je(a.t)}else if(e.match(_f)){a.r=qe(e);a.t=We(qe((e.replace(xf,"").match(Tf)||[]).join("").replace(De,"")));if(t)a.h=yf(Cf(a.r))}return a}var Rf=/<(?:\w+:)?sst([^>]*)>([\s\S]*)<\/(?:\w+:)?sst>/;var Ff=/<(?:\w+:)?(?:si|sstItem)>/g;var If=/<\/(?:\w+:)?(?:si|sstItem)>/;function Df(e,r){var t=[],a="";if(!e)return t;var n=e.match(Rf);if(n){a=n[2].replace(Ff,"").split(If);for(var i=0;i!=a.length;++i){var s=Af(a[i].trim(),r);if(s!=null)t[t.length]=s}n=Ne(n[1]);t.Count=n.count;t.Unique=n.uniqueCount}return t}Ha.SST="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";var Pf=/^\s|\s$|[\t\n\r]/;function Of(e,r){if(!r.bookSST)return"";var t=[Fe];t[t.length]=ur("sst",null,{xmlns:vr.main[0],count:e.Count,uniqueCount:e.Unique});for(var a=0;a!=e.length;++a){if(e[a]==null)continue;var n=e[a];var i="":n.strike=1;break;case""+s+"
");a.push(Kp(i,r,e,t));return a.join("")}function em(e,r){if(!r)r={};if(!e.SSF)e.SSF=P.get_table();if(e.SSF){O(P);P.load_table(e.SSF);r.revssf=Q(e.SSF);r.revssf[e.SSF[65535]]=0;r.ssf=e.SSF;r.cellXfs=[];Th(r.cellXfs,{},{revssf:{General:0}})}var t=[];t.push(Xp(e,r));t.push(Vp(e,r));t.push("");t.push("");for(var a=0;a