218 lines
8.3 KiB
JavaScript
218 lines
8.3 KiB
JavaScript
'use strict';
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
var Discode = function () {
|
||
function Discode() {
|
||
_classCallCheck(this, Discode);
|
||
}
|
||
|
||
_createClass(Discode, [{
|
||
key: 'strNumDiscode',
|
||
value: function strNumDiscode(str) {
|
||
str = str.replace(/∀/g, '∀');
|
||
str = str.replace(/∂/g, '∂');
|
||
str = str.replace(/&exists;/g, '∃');
|
||
str = str.replace(/∅/g, '∅');
|
||
str = str.replace(/∇/g, '∇');
|
||
str = str.replace(/∈/g, '∈');
|
||
str = str.replace(/∉/g, '∉');
|
||
str = str.replace(/∋/g, '∋');
|
||
str = str.replace(/∏/g, '∏');
|
||
str = str.replace(/∑/g, '∑');
|
||
str = str.replace(/−/g, '−');
|
||
str = str.replace(/∗/g, '∗');
|
||
str = str.replace(/√/g, '√');
|
||
str = str.replace(/∝/g, '∝');
|
||
str = str.replace(/∞/g, '∞');
|
||
str = str.replace(/∠/g, '∠');
|
||
str = str.replace(/∧/g, '∧');
|
||
str = str.replace(/∨/g, '∨');
|
||
str = str.replace(/∩/g, '∩');
|
||
str = str.replace(/∩/g, '∪');
|
||
str = str.replace(/∫/g, '∫');
|
||
str = str.replace(/∴/g, '∴');
|
||
str = str.replace(/∼/g, '∼');
|
||
str = str.replace(/≅/g, '≅');
|
||
str = str.replace(/≈/g, '≈');
|
||
str = str.replace(/≠/g, '≠');
|
||
str = str.replace(/≤/g, '≤');
|
||
str = str.replace(/≥/g, '≥');
|
||
str = str.replace(/⊂/g, '⊂');
|
||
str = str.replace(/⊃/g, '⊃');
|
||
str = str.replace(/⊄/g, '⊄');
|
||
str = str.replace(/⊆/g, '⊆');
|
||
str = str.replace(/⊇/g, '⊇');
|
||
str = str.replace(/⊕/g, '⊕');
|
||
str = str.replace(/⊗/g, '⊗');
|
||
str = str.replace(/⊥/g, '⊥');
|
||
str = str.replace(/⋅/g, '⋅');
|
||
return str;
|
||
}
|
||
}, {
|
||
key: 'strGreeceDiscode',
|
||
value: function strGreeceDiscode(str) {
|
||
str = str.replace(/Α/g, 'Α');
|
||
str = str.replace(/Β/g, 'Β');
|
||
str = str.replace(/Γ/g, 'Γ');
|
||
str = str.replace(/Δ/g, 'Δ');
|
||
str = str.replace(/Ε/g, 'Ε');
|
||
str = str.replace(/Ζ/g, 'Ζ');
|
||
str = str.replace(/Η/g, 'Η');
|
||
str = str.replace(/Θ/g, 'Θ');
|
||
str = str.replace(/Ι/g, 'Ι');
|
||
str = str.replace(/Κ/g, 'Κ');
|
||
str = str.replace(/Λ/g, 'Λ');
|
||
str = str.replace(/Μ/g, 'Μ');
|
||
str = str.replace(/Ν/g, 'Ν');
|
||
str = str.replace(/Ξ/g, 'Ν');
|
||
str = str.replace(/Ο/g, 'Ο');
|
||
str = str.replace(/Π/g, 'Π');
|
||
str = str.replace(/Ρ/g, 'Ρ');
|
||
str = str.replace(/Σ/g, 'Σ');
|
||
str = str.replace(/Τ/g, 'Τ');
|
||
str = str.replace(/Υ/g, 'Υ');
|
||
str = str.replace(/Φ/g, 'Φ');
|
||
str = str.replace(/Χ/g, 'Χ');
|
||
str = str.replace(/Ψ/g, 'Ψ');
|
||
str = str.replace(/Ω/g, 'Ω');
|
||
str = str.replace(/α/g, 'α');
|
||
str = str.replace(/β/g, 'β');
|
||
str = str.replace(/γ/g, 'γ');
|
||
str = str.replace(/δ/g, 'δ');
|
||
str = str.replace(/ε/g, 'ε');
|
||
str = str.replace(/ζ/g, 'ζ');
|
||
str = str.replace(/η/g, 'η');
|
||
str = str.replace(/θ/g, 'θ');
|
||
str = str.replace(/ι/g, 'ι');
|
||
str = str.replace(/κ/g, 'κ');
|
||
str = str.replace(/λ/g, 'λ');
|
||
str = str.replace(/μ/g, 'μ');
|
||
str = str.replace(/ν/g, 'ν');
|
||
str = str.replace(/ξ/g, 'ξ');
|
||
str = str.replace(/ο/g, 'ο');
|
||
str = str.replace(/π/g, 'π');
|
||
str = str.replace(/ρ/g, 'ρ');
|
||
str = str.replace(/ς/g, 'ς');
|
||
str = str.replace(/σ/g, 'σ');
|
||
str = str.replace(/τ/g, 'τ');
|
||
str = str.replace(/υ/g, 'υ');
|
||
str = str.replace(/φ/g, 'φ');
|
||
str = str.replace(/χ/g, 'χ');
|
||
str = str.replace(/ψ/g, 'ψ');
|
||
str = str.replace(/ω/g, 'ω');
|
||
str = str.replace(/ϑ/g, 'ϑ');
|
||
str = str.replace(/ϒ/g, 'ϒ');
|
||
str = str.replace(/ϖ/g, 'ϖ');
|
||
str = str.replace(/·/g, '·');
|
||
return str;
|
||
}
|
||
}, {
|
||
key: 'strcharacterDiscode',
|
||
value: function strcharacterDiscode(str) {
|
||
// 加入常用解析
|
||
str = str.replace(/ /g, ' ');
|
||
str = str.replace(/"/g, "'");
|
||
str = str.replace(/&/g, '&');
|
||
str = str.replace(/</g, '<');
|
||
str = str.replace(/>/g, '>');
|
||
str = str.replace(/•/g, '•');
|
||
return str;
|
||
}
|
||
}, {
|
||
key: 'strOtherDiscode',
|
||
value: function strOtherDiscode(str) {
|
||
str = str.replace(/Œ/g, 'Œ');
|
||
str = str.replace(/œ/g, 'œ');
|
||
str = str.replace(/Š/g, 'Š');
|
||
str = str.replace(/š/g, 'š');
|
||
str = str.replace(/Ÿ/g, 'Ÿ');
|
||
str = str.replace(/ƒ/g, 'ƒ');
|
||
str = str.replace(/ˆ/g, 'ˆ');
|
||
str = str.replace(/˜/g, '˜');
|
||
str = str.replace(/ /g, '');
|
||
str = str.replace(/ /g, '');
|
||
str = str.replace(/ /g, '');
|
||
str = str.replace(/‌/g, '');
|
||
str = str.replace(/‍/g, '');
|
||
str = str.replace(/‎/g, '');
|
||
str = str.replace(/‏/g, '');
|
||
str = str.replace(/–/g, '–');
|
||
str = str.replace(/—/g, '—');
|
||
str = str.replace(/‘/g, '‘');
|
||
str = str.replace(/’/g, '’');
|
||
str = str.replace(/‚/g, '‚');
|
||
str = str.replace(/“/g, '“');
|
||
str = str.replace(/”/g, '”');
|
||
str = str.replace(/„/g, '„');
|
||
str = str.replace(/†/g, '†');
|
||
str = str.replace(/‡/g, '‡');
|
||
str = str.replace(/•/g, '•');
|
||
str = str.replace(/…/g, '…');
|
||
str = str.replace(/‰/g, '‰');
|
||
str = str.replace(/′/g, '′');
|
||
str = str.replace(/″/g, '″');
|
||
str = str.replace(/‹/g, '‹');
|
||
str = str.replace(/›/g, '›');
|
||
str = str.replace(/‾/g, '‾');
|
||
str = str.replace(/€/g, '€');
|
||
str = str.replace(/™/g, '™');
|
||
str = str.replace(/←/g, '←');
|
||
str = str.replace(/↑/g, '↑');
|
||
str = str.replace(/→/g, '→');
|
||
str = str.replace(/↓/g, '↓');
|
||
str = str.replace(/↔/g, '↔');
|
||
str = str.replace(/↵/g, '↵');
|
||
str = str.replace(/⌈/g, '⌈');
|
||
str = str.replace(/⌉/g, '⌉');
|
||
str = str.replace(/⌊/g, '⌊');
|
||
str = str.replace(/⌋/g, '⌋');
|
||
str = str.replace(/◊/g, '◊');
|
||
str = str.replace(/♠/g, '♠');
|
||
str = str.replace(/♣/g, '♣');
|
||
str = str.replace(/♥/g, '♥');
|
||
str = str.replace(/♦/g, '♦');
|
||
str = str.replace(/'/g, '\'');
|
||
return str;
|
||
}
|
||
}, {
|
||
key: 'strMoreDiscode',
|
||
value: function strMoreDiscode(str) {
|
||
str = str.replace(/\r\n/g, '');
|
||
str = str.replace(/\n/g, '');
|
||
str = str.replace(/code/g, 'wxxxcode-style');
|
||
return str;
|
||
}
|
||
}, {
|
||
key: 'strDiscode',
|
||
value: function strDiscode(str) {
|
||
str = this.strNumDiscode(str);
|
||
str = this.strGreeceDiscode(str);
|
||
str = this.strcharacterDiscode(str);
|
||
str = this.strOtherDiscode(str);
|
||
str = this.strMoreDiscode(str);
|
||
return str;
|
||
}
|
||
}, {
|
||
key: 'urlToHttpUrl',
|
||
value: function urlToHttpUrl(url, rep) {
|
||
var patt1 = new RegExp('^//');
|
||
var result = patt1.test(url);
|
||
if (result) {
|
||
url = rep + ':' + url;
|
||
}
|
||
return url;
|
||
}
|
||
}]);
|
||
|
||
return Discode;
|
||
}();
|
||
|
||
var disCode = new Discode();
|
||
exports.default = disCode; |