Date: Sun, 20 Jul 2008 01:17:30 -0700 From: Gary Kline <kline@thought.org> To: Walt Pawley <walt@wump.org> Cc: FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG> Subject: Re: How to divide up? Message-ID: <20080720081730.GD21826@thought.org> In-Reply-To: <p062408b5c4a87bc6df50@[10.0.0.10]> References: <20080720002345.GA9173@thought.org> <p062408b5c4a87bc6df50@[10.0.0.10]>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jul 19, 2008 at 10:23:09PM -0700, Walt Pawley wrote: > At 5:23 PM -0700 7/19/08, Gary Kline wrote: > >Guys, > > > >Is there an easyy way of splitting yp these tags into one-per-line? > >I'm not obcessive [[?, :)]], but for what I've got in mind, the tags and stuff > >would look better to my eyes? ....the outcome of this will go ino a special > >database, not html . > > > >is there some clever perl one-liner that would help me turn > > > ><CENTER><FONT face="Times" size="3"><FONT color="#333366">Realization<BR> > > > >into > > > ><CENTER> > ><FONT face="Times" size="3"> > ><FONT color="#333366"> > >Realization > ><BR> > > I've been using this ... > > #!/usr/bin/perl > # Process HTML data on STDIN into one tag per line form on STDOUT > while (<>) { > s/\r/\n/gs; > s/</\n</gs; > s/>/>\n/gs; > s/\n\s*/\n/gs; > s/^\s*//; > print "$_" > } > > ... for quite some time under the name "tag1". It's come in very handy. thanks much, walt --- and everyone else whose ideas helped my shoulder. i have your tag1 in my ~/bin file on my www server it works as adveertised. a note here to rollland smith: i was originally thinking of [[ i tried using ]] tr => tr ">" to \n. Among other things. your idea of using gsed gave me the idea of putting the \n aftter the ">" followed bt a \n. of course this addded in *annnoying* newlines. BUT ``grep -v "^$" axes newlines, so using grit.php, here cut down to spare spamming or wasting resources is the before after: // old, after tidy: # t grit.php <CENTER><FONT face="Times" size="3"><FONT color="#333366">Grit <BR><BR> Patience wears the granite face of wisdom,<BR> discovering the truth of humility and joy.<BR> Hope and faith stand in its silence.<BR> </FONT></FONT></CENTER> using roland's gsed and a pipe that axes \n's: // fixed, MUCH easier to read: # gsed -e "s/>/>\n/g" <grit.php| grep -v "^$" <CENTER> <FONT face="Times" size="3"> <FONT color="#333366"> Grit <BR> <BR> Patience wears the granite face of wisdom,<BR> discovering the truth of humility and joy.<BR> Hope and faith stand in its silence.<BR> </FONT> </FONT> </CENTER> I've been meeaning to get around to this for years, and thr time is now. this is just a tiny example of the superiority of the unix smalll-is-beautiful model. [ blah**3] gary > -- > > Walter M. Pawley <walt@wump.org> > Wump Research & Company > 676 River Bend Road, Roseburg, OR 97470 > 541-672-8975 -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080720081730.GD21826>