This Perl script transforms a txt into html and ads the javscript for bookmarking lines. The script takes one argument as parameter, the name of the txt file (ex.: 8946-8.txt) and outputs a html file (ex.: 8946-8.html). This is not a program and so requires a Perl interpretor to be installed. $file = $ARGV[0]; open(IN, $file); @lines = <IN>; close(IN); $ARGV[0] =~ /(.*)\.(.*)/; $file = $1 . '.html'; open(OUT, ">$file"); print OUT '<html><head>'; print OUT "<script>function getCookie(NameOfCookie){if(document.cookie.length>0){var begin=document.cookie.indexOf(NameOfCookie+'=');if(begin!=-1){begin+=NameOfCookie.length+1;var end=document.cookie.indexOf(';',begin);if(end==-1)end=document.cookie.length;return unescape(document.cookie.substring(begin,end));}}return null;}function setCookie(NameOfCookie,value,expiredays){var ExpireDate=new Date();ExpireDate.setTime(ExpireDate.getTime()+(expiredays*24*3600*1000));document.cookie=NameOfCookie+'='+escape(value)+((expiredays==null)?'':'; expires='+ExpireDate.toGMTString());}var bookmark=0;function init(){bookmark=getCookie('bookmark');if(bookmark==null){bookmark=0;}var a=document.getElementById('bookmark');a.href='#'+bookmark;a=document.getElementById(bookmark);a.style.backgroundColor='lavender';}function highlight(e){var a=document.getElementById(bookmark);a.style.backgroundColor='white';bookmark=e.id;e.style.backgroundColor='lavender';setCookie('bookmark',e.name,365);a=document.getElementById('bookmark');a.href='#'+bookmark;}</script>"; print OUT '</head><body onload="init();">'; print OUT '<div><a id="bookmark" href="#0">bookmark</a></div><p>'; $i = 0; foreach $line (@lines) { if ($line eq "\n") { print OUT '</p><p>'; } else { print OUT '<a id="' . $i . '" ondblclick="highlight(this);" name="' . $i++ . '">' . $line . '</a>'; } } print OUT '</p></body></html>'; close(OUT);