Save html file with escaped text

32 views
Skip to first unread message

fernando....@gmail.com

unread,
May 22, 2018, 6:25:00 AM5/22/18
to jsdom
Hello,

I need to edit some html files kept in a database. I'm doing a script using node.js to get the files, then I use jsdom and jquery to do the editions I need.
Finally I need to save the files back to the database, however, all text should use HTML entities.

So, for instance, this page:

<html>
 
<header>
 
<title>Título da página</title>
 
</heade>
 
<body>
 
<h1> Aqui também há acentos </h1>
 
</body>
</html>

Should be saved as:

<html>
 
<header>
 
<title>T&#xED;tulo da p&#xE1;gina</title>
 
</heade>
 
<body>
 
<h1> Aqui tamb&#xE9;m h&#xE1; acentos </h1>
 
</body>
</html>

It doens't seem JSDOM API has this option, but I'm having a hard time finding all text elements with jquery also.
Any suggestion?

Thanks,
Reply all
Reply to author
Forward
0 new messages