* tests: fix float problems and PAT problem * extend CONTRIBUTING.md * extend build documentation, add GH action, fix build on MacOS * fix build on Vercel * update .gitignore and CONTRIBUTING.md * feat: begin work on monorepo * chore(actions/basic-build): use pnpm * fix: vercel-deploy * docs: updates with new folders * chore: apply PR review comments --------- Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com>
20 lines
389 B
JavaScript
20 lines
389 B
JavaScript
// @ts-check
|
|
|
|
/**
|
|
* Encode string as HTML.
|
|
*
|
|
* @see https://stackoverflow.com/a/48073476/10629172
|
|
*
|
|
* @param {string} str String to encode.
|
|
* @returns {string} Encoded string.
|
|
*/
|
|
const encodeHTML = (str) => {
|
|
return str
|
|
.replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
|
|
return "&#" + i.charCodeAt(0) + ";";
|
|
})
|
|
.replace(/\u0008/gim, "");
|
|
};
|
|
|
|
export { encodeHTML };
|