Re: text to html

2010-07-03 Thread Sam Sharpe
On 3 July 2010 10:07, Jozsi Avadkan jozsi.avad...@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.

Can I ask why you need to do this before I provide the answer, which
took me about 5 minutes to write in bash script.

I only ask because this seems to me like some kind of elementary
homework assignment on bash scripting and I don't want to be involved
in doing someone's homework for them.

-- 
Sam
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Jozsi Avadkan
it will be a site, were i put my notes

2010. 07. 3, szombat keltezéssel 10.58-kor Sam Sharpe ezt írta:
 On 3 July 2010 10:07, Jozsi Avadkan jozsi.avad...@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.
 
 Can I ask why you need to do this before I provide the answer, which
 took me about 5 minutes to write in bash script.
 
 I only ask because this seems to me like some kind of elementary
 homework assignment on bash scripting and I don't want to be involved
 in doing someone's homework for them.
 
 -- 
 Sam

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Sam Sharpe
On 3 July 2010 11:09, Jozsi Avadkan jozsi.avad...@gmail.com wrote:
 it will be a site, were i put my notes

I'll give you the benefit of the doubt based on the fact a quick
Google search says you ask questions a lot and they don't all look
like homework ;o)

If you have the filenames in a file, you can do this:

cat list.txt | ( function title { echo brfont
size=4$1/fontbr ; } ; function ending { echo br ; };
function link { LINK=$1 ; LINKFILE=${LINK##*/} ;
LINKNAME=${LINKFILE%.html} ; echo a href=\$LINK\$LINKNAME/a |
; } ; PREVTITLE= ; TITLE= ; while read line; do
TITLE=${line%%/*} ; if [ $TITLE != $PREVTITLE ]; then if [
$PREVTITLE != x ]; then ending  ; fi ; title $TITLE ;
PREVTITLE=$TITLE ; fi ; link $line ; done ; )

 If you have a tree of links, you could replace cat list.txt with
find ./ -type f

The pretty version looks like this:

##
#!/bin/bash

function title {
   echo brfont size=4$1/fontbr
}

function ending {
   echo br
}

function link {
   # prints out the link template given the path to link to
   LINK=$1
   # delete the longest match of */ from the left side of the path, to
give the filename (equivalent to running `basename $LINK`)
   LINKFILE=${LINK##*/}
   # delete the shortest match of .html from the right of the
filename, to give the name of the link (equivalent to `echo $LINKNAME
| sed -e 's/\.html//g'`
   LINKNAME=${LINKFILE%.html}
   echo a href=\$LINK\$LINKNAME/a |
}

# set the variables to detect a title change
PREVTITLE=
TITLE=

# start processing STDIN
while read line;
do
#  deletes the longest match of /* from the right of the path, to
generate the category title, equivalent to `echo $link | cut -d/ -f1`
TITLE=${line%%/*}
   if [ $TITLE != $PREVTITLE ]; then
  if [ $PREVTITLE !=  ]; then
 # only print the br on title change and not at start of loop.
 ending
  fi
  title $TITLE
  PREVTITLE=$TITLE
   fi
   link $line
done
###


-- 
Sam
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Kwan Lowe
On Sat, Jul 3, 2010 at 5:07 AM, Jozsi Avadkan jozsi.avad...@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.

It's a rather simple bash script, but not a one-liner unless you don't
count semicolons..

In p-code:

OLD_FOO=DUMMY

for each line in the input file
   FOO=dirname
   BAR=basename
   IF FOO != OLD_FOO print a header

   print HREF line

   OLD_FOO=foo
endfor
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Sam Sharpe
n 3 July 2010 11:25, Sam Sharpe lists.red...@samsharpe.net wrote:
 On 3 July 2010 11:09, Jozsi Avadkan jozsi.avad...@gmail.com wrote:
 it will be a site, were i put my notes

 I'll give you the benefit of the doubt based on the fact a quick
 Google search says you ask questions a lot and they don't all look
 like homework ;o)

 If you have the filenames in a file, you can do this:

snip

   # delete the longest match of */ from the left side of the path, to
 give the filename (equivalent to running `basename $LINK`)

That didn't line-wrap very well... here is the pastebin version:

http://pastebin.com/83r7zh35

-- 
Sam
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Rodolfo Alcazar Portillo
On Sat, 2010-07-03 at 11:07 +0200, Jozsi Avadkan wrote:
 input:
 http://pastebin.com/raw.php?i=MqPXZwc3
 
 output:
 http://pastebin.com/raw.php?i=8QCkp4yv
 
 it will be a long day.. :D

Not likely. Obviously, you must replace lynx with cat file.  

lynx -dump http://pastebin.com/raw.php?i=MqPXZwc3|sed -r 
's/([^\/]*)\/(.*)\.html/brfont size=4\1\/fontbr\na 
href=\1\/\2.html\2\/a |/g'

Understood? I'll not be available during football matches.

Regards.
--
Rodolfo Alcazar Portillo - nosp...@gmail.com
otbits.blogspot.com / counter.li.org: #367962
--
- Bother, said Pooh, Eeyore, ready two photon torpedoes and lock
phasers on the Heffalump, Piglet, meet me in transporter room three.
Robert Billing


-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Sam Sharpe
On 3 July 2010 14:16, Rodolfo Alcazar Portillo nosp...@gmail.com wrote:
 On Sat, 2010-07-03 at 11:07 +0200, Jozsi Avadkan wrote:
 input:
 http://pastebin.com/raw.php?i=MqPXZwc3

 output:
 http://pastebin.com/raw.php?i=8QCkp4yv

 it will be a long day.. :D

 Not likely. Obviously, you must replace lynx with cat file.

 lynx -dump http://pastebin.com/raw.php?i=MqPXZwc3|sed -r 
 's/([^\/]*)\/(.*)\.html/brfont size=4\1\/fontbr\na 
 href=\1\/\2.html\2\/a |/g'


I'm afraid that's a fail - it doesn't match the desired output.

It's quite cool, however:

1) It needs to place a br\n before everything except the initial
header line with the font tag.
2) It repeats the header above each link. Jozsi wanted the header only
above the first occurrence to group the links.

-- 
Sam
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: text to html

2010-07-03 Thread Jozsi Avadkan
my own solution: http://pastebin.com/raw.php?i=kqQXCpD5

 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.
 

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines