1
I need to keep just a few properties of the style attribute in tags present in a string of an html document, they will be placed in a Whitelist, everything else will be removed. In the example below:
<TD class=xl76 style="BORDER-TOP: windowtext 0.5pt solid; HEIGHT: 15pt; BORDER-RIGHT: windowtext 0.5pt solid; WIDTH: 883pt; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent" height=20 width=1177 colSpan=25><FONT face=Calibri><STRONG>INDICADORES DO MÊS DE ABRIL DE 2016</STRONG></FONT></TD>
Would only keep the border and background and delete the rest of the column style:
<TD style="BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: red"><FONT face=Calibri><STRONG>INDICADORES DO MÊS DE ABRIL DE 2016</STRONG></FONT></TD>
I can isolate the style content with the following regex:
/(style=")([\s\S])(")/gi
But how to remove, maintain css?
Your answers with JS always surprise me, learning a lot from them :D
– Guilherme Lautert