mirror of
https://github.com/Aviortheking/codestats-readme.git
synced 2025-04-22 10:42:08 +00:00
Merge pull request #178 from anuraghazra/fix-unicode
fix: weird unicode char
This commit is contained in:
commit
e32ab3f973
@ -1,4 +1,9 @@
|
||||
const { kFormatter, getCardColors, FlexLayout } = require("../src/utils");
|
||||
const {
|
||||
kFormatter,
|
||||
getCardColors,
|
||||
FlexLayout,
|
||||
encodeHTML,
|
||||
} = require("../src/utils");
|
||||
const getStyles = require("./getStyles");
|
||||
const icons = require("./icons");
|
||||
|
||||
@ -128,7 +133,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
|
||||
const apostrophe = ["x", "s"].includes(name.slice(-1)) ? "" : "s";
|
||||
const title = hide_title
|
||||
? ""
|
||||
: `<text x="25" y="35" class="header">${name}'${apostrophe} GitHub Stats</text>`;
|
||||
: `<text x="25" y="35" class="header">${encodeHTML(name)}'${apostrophe} GitHub Stats</text>`;
|
||||
|
||||
const border = `
|
||||
<rect
|
||||
|
@ -17,9 +17,11 @@ const renderError = (message) => {
|
||||
|
||||
// https://stackoverflow.com/a/48073476/10629172
|
||||
function encodeHTML(str) {
|
||||
return str.replace(/[\u00A0-\u9999<>&](?!#)/gim, function (i) {
|
||||
return "&#" + i.charCodeAt(0) + ";";
|
||||
});
|
||||
return str
|
||||
.replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
|
||||
return "&#" + i.charCodeAt(0) + ";";
|
||||
})
|
||||
.replace(/\u0008/gim, "");
|
||||
}
|
||||
|
||||
function kFormatter(num) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user