|
|
|
|
// HTML 支持的数学符号
|
|
|
|
|
function strNumDiscode(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, '⋅');
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HTML 支持的希腊字母
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function strcharacterDiscode(str) {
|
|
|
|
|
// 加入常用解析
|
|
|
|
|
|
|
|
|
|
// str = str.replace(/ | | /g, " ");
|
|
|
|
|
// str = str.replace(/ | | /g, ' ');
|
|
|
|
|
// str = str.replace(/ | /g, '<span class=\'spaceshow\'> </span>');
|
|
|
|
|
// 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, "<span class='spaceshow'> </span>");
|
|
|
|
|
str = str.replace(/ | | /g, '<span class=\'spaceshow\'> </span>');
|
|
|
|
|
str = str.replace(/ | /g, '<span class=\'spaceshow\'> </span>');
|
|
|
|
|
str = str.replace(/ | | /g, '<span class=\'spaceshow\'> </span>');
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HTML 支持的其他实体
|
|
|
|
|
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(/ |$#8201;| /g, '<span class=\'spaceshow\'> </span>');
|
|
|
|
|
str = str.replace(/‌|‌|‌/g, '<span class=\'spaceshow\'></span>');
|
|
|
|
|
str = str.replace(/‍|$#8205;|‍/g, '<span class=\'spaceshow\'></span>');
|
|
|
|
|
str = str.replace(/‎|$#8206;|‎/g, '<span class=\'spaceshow\'></span>');
|
|
|
|
|
str = str.replace(/‏|‏|‏/g, '<span class=\'spaceshow\'></span>');
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function strDiscode(str) {
|
|
|
|
|
str = strNumDiscode(str);
|
|
|
|
|
str = strGreeceDiscode(str);
|
|
|
|
|
str = strcharacterDiscode(str);
|
|
|
|
|
str = strOtherDiscode(str);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function urlToHttpUrl(url, domain) {
|
|
|
|
|
if (/^\/\//.test(url)) {
|
|
|
|
|
return `https:${url}`;
|
|
|
|
|
} else if (/^\//.test(url)) {
|
|
|
|
|
return `https://${domain}${url}`;
|
|
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
strDiscode,
|
|
|
|
|
urlToHttpUrl,
|
|
|
|
|
};
|