mirror of
https://github.com/ItsVipra/ProToots
synced 2025-02-16 12:38:23 +00:00
add htmlDecode() to unescape special characters
This commit is contained in:
parent
a8904497c0
commit
42b954f209
1 changed files with 10 additions and 0 deletions
|
@ -85,3 +85,13 @@ export function insertAfter(insertion, target) {
|
|||
//docs: https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore#example_2
|
||||
target.parentElement.insertBefore(insertion, target.nextSibling);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns HTML text into human-readable text
|
||||
* @param {string} input HTML Text
|
||||
* @returns {string}
|
||||
*/
|
||||
export function htmlDecode(input) {
|
||||
const doc = new DOMParser().parseFromString(input, "text/html");
|
||||
return doc.documentElement.textContent;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue