Skip to content

Commit f104adb

Browse files
committed
Fixed few subscripts which does not have Unicode for them.
1 parent 2b6a876 commit f104adb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

convertHTML2UTF.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
return result;
1818
};
1919

20-
var subScriptArray = new Array('8320', '8321', '8322', '8323', '8324', '8325', '8326', '8327', '8328', '8329', '8330', '8331', '8332', '8333', '8334', '8336', '8337', '8338', '8339', '8341', '8342', '8343', '8344', '8345', '8346', '8347', '8348');
20+
var subScriptArray = new Array('8320', '8321', '8322', '8323', '8324', '8325', '8326', '8327', '8328', '8329', '8330', '8331', '8332', '8333', '8334', '8336', '8337', '8338', '8339', '8340', 'k', 'i', 'm', 'n', 'p', 's', 't');
2121

2222
var superScriptArray = new Array('8304;', '¹', '²', '³', '8308', '8309', '8310', '8311', '8312', '8313', '8314', '8315', '8316', '8317', '8318', 'a', 'e', 'o', 'x', 'h', 'k', 'i', 'm', '8319', 'p', 's', 't');
2323

2424
var scriptText = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-', '=', '(', ')', 'a', 'e', 'o', 'x', 'h', 'k', 'i', 'm', 'n', 'p', 's', 't');
2525

2626
$.convertHTML2UTF = function(param) {
2727
var refinedStr = '';
28-
param.split(/(<sub>.*?<\/sub>)|(<sup>.*?<\/sup>)/).map(function(val){
28+
$.map(param.split(/(<sub>.*?<\/sub>)|(<sup>.*?<\/sup>)/), function(val){
2929
if (val !== undefined) {
3030
if (val.indexOf('<sub>')!=-1) {
3131
val = $.trim(val.replace(/<\/?sub>/g,''));
@@ -38,7 +38,9 @@
3838
if (c != -1) {
3939
tempValue = '';
4040
c = subScriptArray[c];
41-
c = String.fromCharCode(c);
41+
if ($.isNumeric(c)) {
42+
c = String.fromCharCode(c);
43+
}
4244
tempValue = tempValue + c;
4345
};
4446
}
@@ -53,12 +55,10 @@
5355
c = scriptText.indexOf(c);
5456
if (c != -1) {
5557
tempValue = '';
56-
if (c != 1 & c != 2 & c!= 3) {
57-
c = superScriptArray[c];
58+
c = superScriptArray[c];
59+
if ($.isNumeric(c)) {
5860
c = String.fromCharCode(c);
59-
}else{
60-
c = superScriptArray[c];
61-
};
61+
}
6262
tempValue = tempValue + c;
6363
};
6464
}

0 commit comments

Comments
 (0)