diff options
| author | Robert Hak <adiamas@rockbox.org> | 2002-08-22 03:34:09 +0000 |
|---|---|---|
| committer | Robert Hak <adiamas@rockbox.org> | 2002-08-22 03:34:09 +0000 |
| commit | 05256598779d10a331972941c80cf502770de44d (patch) | |
| tree | 64c7976cd7c17bc617d56aee816daa186aba9413 | |
| parent | d421f5b3729367f8345c268adea2b0f7b8e30777 (diff) | |
| download | rockbox-05256598779d10a331972941c80cf502770de44d.zip rockbox-05256598779d10a331972941c80cf502770de44d.tar.gz rockbox-05256598779d10a331972941c80cf502770de44d.tar.bz2 rockbox-05256598779d10a331972941c80cf502770de44d.tar.xz | |
renameing txt2plain.pl to faq2html.pl
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1911 a1c6a512-1295-4272-9138-f99709370657
| -rwxr-xr-x | www/faq2html.pl | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/www/faq2html.pl b/www/faq2html.pl new file mode 100755 index 0000000..47018fc --- /dev/null +++ b/www/faq2html.pl @@ -0,0 +1,99 @@ +#!/usr/bin/perl + +# this is really a faq2html and should only be used for this purpose + +sub fixline { + $_ =~ s/\</</g; + $_ =~ s/\>/>/g; + + $_ =~ s/(http:\/\/([a-zA-Z0-9_.\/-]*)[^\) .\n])/\<a href=\"$1\"\>$1\<\/a\>/g; + + $_ =~ s/(\\|\/)$/$1 /g; # clobber backslash on end of line +} + +sub show { + if(@q) { + print @q; + undef @q; + } + if(@a) { + print @a; + undef @a; + } + if(@p) { + print "<pre>\n"; + print @p; + print "</pre>\n"; + undef @p; + } +} + +while(<STDIN>) { + + fixline($_); + + # detect and mark Q-sections + if( $_ =~ /^(Q(\d*)[.:] )(.*)/) { + + show(); + + # collect the full Q + push @q, "<a name=\"$2\"></a><p class=\"faqq\">"; + push @q, "$2. $3"; + my $line; + + $indent = length($1); + $first = " " x $indent; + + #print "$indent|$first|$1|\n"; + + while(<STDIN>) { + + fixline($_); + + $line = $_; + + if($_ !~ /^A/) { + push @q, "$_"; + } + else { + last; + } + } + # first line of A + $line =~ s/^A(\d*)[.:] *//g; # cut off the "A[num]." + push @a, "<p class=\"faqa\">"; + push @a, $line; + + $prev='a'; + next; + } + # print "$_ matches '$first'?\n"; + + if($_ =~ /^$first(\S)/) { + + + if($prev ne 'a') { + show(); + push @a, "<p class=\"faqa\">"; + } + + push @a, $_; + $prev='a'; + } + else { + if($prev ne 'p') { + show(); + } + if(@p) { + # if we have data, we fix blank lines + $_ =~ s/^\s*$/\ \n/g; # empty lines are nbsp + push @p, $_; # add it + } + elsif($_ !~ /^\s*$/) { + # this is not a blank line, add it + push @p, $_; + } + $prev = 'p'; + } +} |