Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   Linux insert <br> utility? (http://www.velocityreviews.com/forums/t162061-linux-insert-br-utility.html)

wcb 06-18-2005 10:44 AM

Linux insert <br> utility?
 
I am using Linux and Bluefish.
I have a lot of long documents I want html-ize.
I am looking for some sort of little Linux utility
where I could insert <br>'s into an existing file.

Thus a long
dreary,
dusty,
document,
...
Like this,

Would be changed to

Thus a long<br>
dreary,<br>
dusty,<br>
document<br>
...<br>
Like this,<br>
<br>

Is there such a quick and dirty beastie for Linux?
Most utilities I see seem to be for Windows.
I am looking for something that can do batch
processing if possible, doing an entire folder
at one shot.


--

When I shake my killfile, I can hear them buzzing!

Cheerful Charlie

Lauri Raittila 06-18-2005 10:50 AM

Re: Linux insert <br> utility?
 
in alt.html, wcb wrote:
> I am using Linux and Bluefish.
> I have a lot of long documents I want html-ize.


Learn perl.

> I am looking for some sort of little Linux utility
> where I could insert <br>'s into an existing file.


> Is there such a quick and dirty beastie for Linux?


sed
man sed

> Most utilities I see seem to be for Windows.


Because nobody needs any *extra* utilies for something that simple in
linux... there is some other tool as well, even more simple, but I don't
recall what it is called...

> I am looking for something that can do batch
> processing if possible, doing an entire folder
> at one shot.


sed -i 's/$/<br>/g;' *.html
(if I got it right...)

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Support me, buy Opera:
https://secure.bmtmicro.com/opera/bu...tml?AID=882173

David Dorward 06-18-2005 10:58 AM

Re: Linux insert <br> utility?
 
wcb wrote:

> I am looking for some sort of little Linux utility
> where I could insert <br>'s into an existing file.


> Is there such a quick and dirty beastie for Linux?


perl -i.bak -p -n -e 's/\n/<br>\n/' myTextFile

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

wcb 06-18-2005 11:47 AM

Re: Linux insert <br> utility?
 
David Dorward wrote:

> wcb wrote:
>
>> I am looking for some sort of little Linux utility
>> where I could insert <br>'s into an existing file.

>
>> Is there such a quick and dirty beastie for Linux?

>
> perl -i.bak -p -n -e 's/\n/<br>\n/' myTextFile
>


Thank you.

--

When I shake my killfile, I can hear them buzzing!

Cheerful Charlie

Dan 06-18-2005 12:59 PM

Re: Linux insert <br> utility?
 
wcb wrote:
> I am using Linux and Bluefish.
> I have a lot of long documents I want html-ize.
> I am looking for some sort of little Linux utility
> where I could insert <br>'s into an existing file.


Though, if you're looking for a more logically structured final
document, you might prefer to use other tags, such as <p>, where
appropriate, so the paragraphs and other structural elements are
properly marked.

--
Dan


wcb 06-18-2005 01:25 PM

Re: Linux insert <br> utility?
 
David Dorward wrote:

> wcb wrote:
>
>> I am looking for some sort of little Linux utility
>> where I could insert <br>'s into an existing file.

>
>> Is there such a quick and dirty beastie for Linux?

>
> perl -i.bak -p -n -e 's/\n/<br>\n/' myTextFile
>


OK, this didn't quite work.

I rewrote it perl -p -e 's/\n/<br>\n/' myfile > myfile.br
Which does. It slaps <br> like I wanted and pipes it to
a new file with a .br on the end of the file's name.

But if I try * > *.br in a directory with numerous files,
it does not work, perl does not understand *. What's the
magic tickle for perl here that would allow a batch process?
What does perl use instead of "*" ? "Learning Perl" does not
have wild card in the index.




--

When I shake my killfile, I can hear them buzzing!

Cheerful Charlie

wcb 06-18-2005 04:47 PM

Re: Linux insert <br> utility?
 
Dan wrote:

> wcb wrote:
>> I am using Linux and Bluefish.
>> I have a lot of long documents I want html-ize.
>> I am looking for some sort of little Linux utility
>> where I could insert <br>'s into an existing file.

>
> Though, if you're looking for a more logically structured final
> document, you might prefer to use other tags, such as <p>, where
> appropriate, so the paragraphs and other structural elements are
> properly marked.
>


They're are already formatted, and I really need to get the <br>
tags in first. I want to keep most of it formated as is. There
are a lot of long files.
But with 300+ lines that's a lot of <br>ing to do by hand.
I may later have to tweak a few, but if I can get the bulk done
by batch processing it will save me a massive amount of work.

Each doc will be a html file and I'll use CSS to do most of
the rest.

It might be nice to give them better structure, but that
won't happen most likely until I can figure out enough Perl
to let Perl do most the heavy lifting.

I have my hands full figuring out HTML, CSS and HTML editors.
Three battles at a time is enough for now.







--

When I shake my killfile, I can hear them buzzing!

Cheerful Charlie

David Dorward 06-18-2005 07:05 PM

Re: Linux insert <br> utility?
 
wcb wrote:

>> perl -i.bak -p -n -e 's/\n/<br>\n/' myTextFile


> OK, this didn't quite work.


It did when I tested it. It modifies myTextFile, and creates a copy of the
original at myTextFile.bak.

> I rewrote it perl -p -e 's/\n/<br>\n/' myfile > myfile.br
> Which does. It slaps <br> like I wanted and pipes it to
> a new file with a .br on the end of the file's name.


> But if I try * > *.br in a directory with numerous files,
> it does not work, perl does not understand *.


perl doesn't even see * - it is expanded by the shell before it gets to
perl. Using my original code:

perl -i.bak -p -n -e 's/\n/<br>\n/' *

.... works fine.

Using yours, the easiest way would probably be to wrap it in a shell script:

for x in *
do perl -p -e 's/\n/<br>\n/' $x > $x.br
done

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

David Dorward 06-18-2005 07:07 PM

Re: Linux insert <br> utility?
 
wcb wrote:

> It might be nice to give them better structure, but that
> won't happen most likely until I can figure out enough Perl
> to let Perl do most the heavy lifting.


You might want to take a look at Markdown. There probably isn't any need to
reinvent the wheel.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

David Dorward 06-19-2005 11:47 AM

Re: Linux insert <br> utility?
 
WCB wrote:

>> You might want to take a look at Markdown.


> Thanks but it seems to be Apple software.


No, its just Perl. The author uses OS X, that's all.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


All times are GMT. The time now is 12:54 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.