mathiasbynens / he

A robust HTML entity encoder/decoder written in JavaScript.
https://mths.be/he
MIT License
3.45k stars 254 forks source link

He.decode : keep some part encoded #54

Closed mvuidev closed 7 years ago

mvuidev commented 7 years ago

Hi,

Using he.decode, I need to keep a part of the code encoded. Is it possible ?

For example, I do he.encode on :

<h1>Title</h1>
<pre>
<p>Code</p>
</pre>

So I get :

&lt;h1&gt;Title&lt;/h1&gt;
&lt;pre&gt;
&lt;p&gt;Code&lt;/p&gt;
&lt;/pre&gt;

And here is what I need to get doing a he.decode :

<h1>Title</h1>
<pre>
&lt;p&gt;Code&lt;/p&gt;
</pre>
mathiasbynens commented 7 years ago

You’ll have to handle that yourself, outside of he. Parse the HTML and only encode/decode the parts you’re interested in.