webdevRefinery Forum: Convert html to its entity version in node?? - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

User is offline Wyatt 

  • Group: Members
  • Posts: 290
  • Joined: 08-March 10
  • LocationCANADA!!
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 04 February 2012 - 06:25 PM (#1)

Convert html to its entity version in node??


Is there a nodejs function to convert html to its entity version? Or should I just replace < and > with &lt; and &rt; ?
HTML | CSS | PHP | JavaScript | SQL
If someone helped you or said something useful +1 them.
0


User is offline Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3038
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,SQL

Posted 04 February 2012 - 06:47 PM (#2)

I don't think there's a built in JavaScript function... Maybe there's a library for Node.js.
Anyways you just need to replace these:

& to &amp;
< to &lt;
> to &gt;
" to &quot;

Make sure you do & first (before < > and "), otherwise &lt; will become &amp;lt; which is not what you want.

EDIT: Take a look at these for functions that are more comprehensive:
http://phpjs.org/fun...pecialchars:426
http://phpjs.org/fun...hars_decode:427
Daniel15! :D
Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

javascript:alert((''+[][[]])[!+[]+!+[]]+(![]+[])[+!+[]]+(''+!+[]/[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(''+!![])[+!+[]+!![]+!![]]+(![]+[])[!+[]+!+[]]+(+!+[])+(!+[]+!+[]+!+[]+!+[]+!+[]))

View PostKyek, on 16 November 2011 - 11:14 AM, said:

Daniel15 is ruining my life D:

View Postmorrison_levi, on 30 September 2011 - 04:10 PM, said:

They added more features to tables because. . . oh, yeah, they do have valid uses! Ever heard of data? We do still use that. :)
0


User is offline Wyatt 

  • Group: Members
  • Posts: 290
  • Joined: 08-March 10
  • LocationCANADA!!
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 04 February 2012 - 06:59 PM (#3)

Thanks
HTML | CSS | PHP | JavaScript | SQL
If someone helped you or said something useful +1 them.
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services