Tuesday, March 20, 2012

Good Bye Latex ? Hello WeasyPrint ...

Latex, is my main way of producing reports and scientific works. Usually these are formed as PDF before being actually printed. Latex is AWESOME. I love writing documents with latex. That said, although I am not a beginner with latex, when I want to deviate from normal good old latex patterns things become a bit rough.
Despite using the Latex language for almost 5 years, I still don't fully understand the syntax of writing packages, although mostly a long enough search will yield some solution which does not require me to hack on my own. Never the less this is a bit tiresome sometimes.
Enter WeasyPrint. This project seems really cool because it allows anyone with basic knowledge of HTML and CSS to produce good looking PDFs. Further more, I can really think of a simple work flow once a template is made:
Write your documents  with Markdown, use something like Jekyll to convert your easy to understand Markdown to HTML with some Jinja or CSS and finally convert your pages to good looking PDF's.
I think this is more or less what Sphinx does (except that Sphinx uses RST instead of Markdown). I never really mastered CSS or HTML, but this seems like a good opportunity to start mastering both

Besides, consider this:

MarkDown + Convert to HTML +  WeasyPrint  = Sphinx from Scratch.

Besides being a very cool educational project, a project like this can allow people with CSS + HTML knowledge to produce some great looking PDF. It also allowed a lot of flexibility if you are good at both. 

Never the less, Latex has still one big advantage: Latex is well designed to produce good looking documents even though you are not an expert on typography and page layout. Additionally it is thousands of ready made packages and kind community that can help solving many existing problems. So maybe after all, Latex is not going away so fast!

Friday, March 16, 2012

The weired Indexing in Perl

I am learning Perl. I am doing it with a lot of a resentment, but I am slowly learning it.
Normal people count from 1. Computer Scientist count from 0. Perl developers count from -1?

WTF?

oz@server ~ $ test.pl test
num of args 0 
oz@server ~ $ test.pl test test
num of args 1 
0
test
1
test
oz@server ~ $ test.pl          
num of args -1 
No arguments!
oz@server ~ $ 
My Code, just in case I am totally wrong about this here, :
$ cat test.pl 
#!/usr/local/bin/perl -w


print "num of args $#ARGV \n";
if ( $#ARGV > 0   ){

   for ( my $i = 0 ; $i <= $#ARGV  ; ++$i  ) {

   print "$i\n";
   print "$ARGV[$i]\n";
   }
}
if ( @ARGV > 0 )
{
  print "Number of arguments: " . scalar @ARGV . "\n";
}
else
{
print "No arguments!\n";
}