Skip to content

Commit cda2d48

Browse files
committed
Version 1.6.5
See changelog. Fix #14 and fix #15 .
1 parent a3cdb09 commit cda2d48

File tree

3 files changed

+57
-11
lines changed

3 files changed

+57
-11
lines changed

src/changelog.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ Legend
66
[#] Fixed
77
Dates use a YYYY/MM/DD format.
88

9+
Version 1.6.5 (2019/10/23)
10+
===========
11+
12+
| Note on this release :
13+
| Bug fixes, support for coloured diagonal line
14+
15+
LATEX EXPORT
16+
17+
[#] Bold, italized, underlined and coloured texts didn't work with multiple lines rows (#15)
18+
19+
LATEX IMPORT
20+
21+
[#] Comments were not parsed
22+
923
Version 1.6.4 (2019/03/09)
1024
===========
1125

src/js.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function $id(id) {
1414
/* ==== START CAMPAIGN INFO ==== */
1515

1616
var campaign = {
17-
start: new Date(2018,11,2),
18-
end: new Date(2018,11,17),
19-
year:2018
17+
start: new Date(2019,11,2),
18+
end: new Date(2019,11,17),
19+
year:2019
2020
},
2121
campaignUsed = localStorage.getItem("campaign") == campaign.year,
2222

@@ -109,7 +109,7 @@ function $id(id) {
109109
return "[rgb]{"+sep+"}";
110110
},
111111
table = new(function() {
112-
this.version = "1.6.4";
112+
this.version = "1.6.5";
113113
this.create = function(cols, rows) {
114114
rows = parseInt(rows, 10);
115115
cols = parseInt(cols, 10);
@@ -856,12 +856,35 @@ this.getHTML = (function(){
856856
for(var i=0;i<div.childNodes.length;i++){
857857
_eqHTML(div.childNodes[i], cont)
858858
}
859-
return cont.innerHTML.replace(/<\/(b|i)\s*>(\s*)<\s*(b|i)\s*>/gi, function(full, close, space, open){
859+
var html = cont.innerHTML.replace(/<\/(b|i)\s*>(\s*)<\s*(b|i)\s*>/gi, function(full, close, space, open){
860860
if(open.toLowerCase() == close.toLowerCase()){
861861
return space;
862862
}
863863
return full;
864864
}).replace(/\u200B/g,'');
865+
if(/<br[^a-z>]*>/i.test(html)){
866+
var opentags = [], html = html.replace(/<\s*(\/?)\s*(br|b|i|u|font\s+[^>]*)[^a-z>]*>/ig,function(full,close,tag){
867+
tag = tag.toLowerCase();
868+
if(tag == "br"){
869+
var str = "</";
870+
opentags.reverse();
871+
str += opentags.join("></")+"><br><";
872+
opentags.reverse();
873+
str += opentags.join("><")+">";
874+
str = str.replace(/<\/\s*font[^>]*>/gi,"</font>");
875+
return str;
876+
}
877+
else if(close){
878+
opentags.pop();
879+
return full;
880+
}
881+
else{
882+
opentags.push(tag);
883+
return full;
884+
}
885+
})
886+
}
887+
return html;
865888
}
866889
})();
867890
this.setHTML = function(cell, HTML) {
@@ -1621,7 +1644,7 @@ this.getHTML = (function(){
16211644
break;
16221645
}
16231646
}while(target = target.parentElement);
1624-
if(e.clipboardData && document.queryCommandEnabled("insertHTML")){
1647+
if(e.clipboardData && false && document.queryCommandEnabled("insertHTML")){
16251648
var d = document.createElement("div");
16261649
var plain = e.clipboardData.getData("text/plain");
16271650
console.log(plain);
@@ -3237,15 +3260,15 @@ console.dir(html);
32373260
var row = beautifyRows[i];
32383261
if (i === 0 && booktabs) {
32393262
if(borderNewLine){
3240-
border = "\n\\toprule";
3263+
border = " \n\\toprule";
32413264
}
32423265
else{
32433266
border = " \\toprule";
32443267
}
32453268
} else {
32463269
border = this.getBorder(i, rg);
32473270
if(borderNewLine){
3248-
border = border ? "\n" + border : ""
3271+
border = border ? " \n" + border : ""
32493272
}
32503273
else{
32513274
border = border ? " " + border : "";

src/latex-import.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ importTable = function(code){
229229

230230
xcolor.erase();
231231
xcolor.extract(code);
232-
233232
var tabularReg = /(?:\\(ctable)[\[\{])|(?:\\begin{((?:long|)tabu\*?|sidewaystable|wraptable|table\*?|xtabular|tabularht\*?|tabularhtx|tabularkv|longtable|mpxtabular|tabular[xy]?\*?)})/g;
234233
var tabular = tabularReg.exec(code);
235234
tabularReg.lastIndex = 0;
@@ -487,15 +486,25 @@ var tabular = tabularReg.exec(code);
487486
};
488487
var cellpos = 0, commandmode = false, otherseparator = "",
489488
table = [[]], cell = "", row = table[0], ignoreSpace = false, actuBorder="", borders = [],
490-
backgroundRow = [], actualXColorRowNumber = 1, xcolorRowNumbers = [];
489+
backgroundRow = [], actualXColorRowNumber = 1, xcolorRowNumbers = [], inComment = false;
491490
for(var i=0, c;i<code.length;i++){
492491
c = code.charAt(i);
493492
var sub = code.substring(i);
493+
if(inComment){
494+
if(c == "\n"){
495+
inComment = false;
496+
}
497+
continue;
498+
}
494499
if(ignoreSpace && /^\s$/.test(c)){
495500
continue;
496501
}
497502
ignoreSpace = false;
498-
if(c == "\\"){
503+
if(c == "%"){
504+
inComment = true;
505+
continue;
506+
}
507+
else if(c == "\\"){
499508
if(sub.lastIndexOf("\\begin{",0) === 0){
500509
var env = envirn(sub);
501510
cell += env.full;

0 commit comments

Comments
 (0)