text to html

Jozsi Avadkan jozsi.avadkan at gmail.com
Sat Jul 3 17:14:38 UTC 2010

Thank you!!

> On Sat, Jul 3, 2010 at 2:07 AM, Jozsi Avadkan
> <jozsi.avadkan at gmail.com> wrote:
>         input:
>         http://pastebin.com/raw.php?i=MqPXZwc3
>         output:
>         http://pastebin.com/raw.php?i=8QCkp4yv
>         it will be a long day.. :D
>         could someone please help with it?
>         i have to make a "one liner" that get's the input, and gives
>         the
>         mentioned output.
> First, I'm not really sure you want the exact output you posted.
> 1)  The second and third href="..." elements after "netbsd" seem to be
> different from all the other multi-line groups.  Could this be a typo?
> 2)  The pipe symbol ("|") at the end of most groups also seems a bit
> odd.  I would guess the last of each group
> would not want one, as is the case with the first group.
> Second, perl is my tool of choice for this sort of thing, and if you
> can tolerate longer lines than usual, it can be made a one-liner.
> This version puts pipe ("|") after all links, but does not treat
> netbsd specially.  I'm assuming that your shell is BASH. The quoting
> might need to be different in other shells.
> perl -n -e '$od=qq+/+; while (<>) { chomp; ($dir, $stuff)=split /\//,
> $_, 2; @all = split /\//, $_; $thing = $all[$#all]; $thing =~ s/\.html
> $//; if ($dir ne $od) { print qq+<br>\n+ if $od ne qq+/+; $od = $dir;
> print qq+<br><font size=4>$dir</font><br>\n+; } print qq:<a
> href="$dir/$stuff">$thing</a> | \n: } print qq+\n+;'
> This really is a one-liner, so I've also attached it as a file in case
> mail software creates line breaks.  If you can tolerate it as a
> separate script, a multi-line version would be much more readable.
> I still use Perl a lot for short things like this, even though it's
> one of the less-readable languages I know.  I've moved on to Python
> for most of the stuff I used to use Perl for, because I can read the
> code a year later.
> -- 
> Kevin O'Gorman, PhD

More information about the ubuntu-users mailing list