Converting with sed...
Nov. 12th, 2003 08:37 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Turning stylesheet CSS to inline CSS:
sed 's/class="no"/style="background-color:#cc0000"/' blah.foo | sed 's/class="yes"/style="background-color:#00cc00"/' | sed 's/class="paid"/style="background-color:#cccc00"/' | sed 's/class="paidstylefeature"/style="background-color:#000066; color: #ffffff"/' | sed 's/class="allpaidfeature"/style="background-color:#aaaaff; color: #000000"/' | sed 's/class="freefeature"/style="background-color:#aaaaaa; color: #000000"/' | sed 's/td style="back/td style="border: solid 1px #000000; font-size: 11px; back/' | sed 's/td /td width="150px" height="50px" /' | sed 's/th class=".*"/th style="font-size:11px"/' > ~/public_html/blah3.htm
(result is the conversion of http://fweebles.callete.com/S2options.html (Happy Birthday Fweebzors!) to the HTML in http://www.livejournal.com/community/howto_userdoc/35177.html)
That is one monster sed command. For me, anyway. I should actually learn how to use regexs so I can do it smaller next time ;)
sed 's/class="no"/style="background-color:#cc0000"/' blah.foo | sed 's/class="yes"/style="background-color:#00cc00"/' | sed 's/class="paid"/style="background-color:#cccc00"/' | sed 's/class="paidstylefeature"/style="background-color:#000066; color: #ffffff"/' | sed 's/class="allpaidfeature"/style="background-color:#aaaaff; color: #000000"/' | sed 's/class="freefeature"/style="background-color:#aaaaaa; color: #000000"/' | sed 's/td style="back/td style="border: solid 1px #000000; font-size: 11px; back/' | sed 's/td /td width="150px" height="50px" /' | sed 's/th class=".*"/th style="font-size:11px"/' > ~/public_html/blah3.htm
(result is the conversion of http://fweebles.callete.com/S2options.html (Happy Birthday Fweebzors!) to the HTML in http://www.livejournal.com/community/howto_userdoc/35177.html)
That is one monster sed command. For me, anyway. I should actually learn how to use regexs so I can do it smaller next time ;)
sed
Date: 2003-11-12 06:58 am (UTC)sed -e 's///' -e 's///' -e 's///' ... -e 's///' blah.foo >blah3.htm
or probably also
sed -e 's///
s///
s///
s///' blah.foo >blah3.htm
Also, you could've saved yourselves some typing, since in CSS the colour #abc is the same as #aabbcc.
Re: sed
Date: 2003-11-12 07:22 am (UTC)I also just like pipes. I'm sure it would make things slower, but since this entire block took appoximately no time at all to do, I wasn't concerned about that.
The CSS I left, since I wasn't sure how older browsers treated the #abc type, and I have no idea what kind of browsers people will look at it with.
But this is the first time I've ever used sed, so the fact that it WORKED made me pretty happy :)