Better aspect ratio of the blocks for the archos bitmap LCD (1.06:1 instead of 1...
[kugel-rb.git] / www / faq2html.pl
blob3417128ab9ffcf0f024c3f09556beda2f6bdfdc8
1 #!/usr/bin/perl
3 # this is really a faq2html and should only be used for this purpose
5 sub fixline {
6 $_ =~ s/\</&lt;/g;
7 $_ =~ s/\>/&gt;/g;
9 $_ =~ s/(http:\/\/([a-zA-Z0-9_.\#\/-]*)[^\) .\n])/\<a href=\"$1\"\>$1\<\/a\>/g;
11 $_ =~ s/(\\|\/)$/$1&nbsp;/g; # clobber backslash on end of line
14 sub show {
15 if(@q) {
16 print @q;
17 undef @q;
19 if(@a) {
20 print @a;
21 undef @a;
23 if(@p) {
24 print "<pre>\n";
25 print @p;
26 print "</pre>\n";
27 undef @p;
31 while(<STDIN>) {
33 fixline($_);
35 # detect and mark Q-sections
36 if( $_ =~ /^(Q(\d*)[.:] )(.*)/) {
38 show();
40 # collect the full Q
41 push @q, "<a name=\"$2\"></a><p class=\"faqq\">";
42 push @q, "$2. $3";
43 my $line;
45 $indent = length($1);
46 $first = " " x $indent;
48 #print "$indent|$first|$1|\n";
50 while(<STDIN>) {
52 fixline($_);
54 $line = $_;
56 if($_ !~ /^A/) {
57 push @q, "$_";
59 else {
60 last;
63 # first line of A
64 $line =~ s/^A(\d*)[.:] *//g; # cut off the "A[num]."
65 push @a, "<p class=\"faqa\">";
66 push @a, $line;
68 $prev='a';
69 next;
71 # print "$_ matches '$first'?\n";
73 if($_ =~ /^$first(\S)/) {
76 if($prev ne 'a') {
77 show();
78 push @a, "<p class=\"faqa\">";
81 push @a, $_;
82 $prev='a';
84 else {
85 if($prev ne 'p') {
86 show();
88 if(@p) {
89 # if we have data, we fix blank lines
90 $_ =~ s/^\s*$/\&nbsp;\n/g; # empty lines are nbsp
91 push @p, $_; # add it
93 elsif($_ !~ /^\s*$/) {
94 # this is not a blank line, add it
95 push @p, $_;
97 $prev = 'p';
100 show();