diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-08-19 15:50:13 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-08-19 15:50:13 +0000 |
commit | 54ed3d6ce1c54797a006549c784cbebdff6a4024 (patch) | |
tree | a19508c5353fdcfb2d01b76e6ebabfbd76f0af7f /www/txt2plain.pl | |
parent | 4d52ba710a622a5f561fbad0a47e08bfba28f33d (diff) | |
download | rockbox-54ed3d6ce1c54797a006549c784cbebdff6a4024.tar.gz rockbox-54ed3d6ce1c54797a006549c784cbebdff6a4024.zip |
fix links within A-sections too and improve the parser somewhat
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1808 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'www/txt2plain.pl')
-rwxr-xr-x | www/txt2plain.pl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/www/txt2plain.pl b/www/txt2plain.pl index ec49adbcdb..72640522b6 100755 --- a/www/txt2plain.pl +++ b/www/txt2plain.pl | |||
@@ -2,22 +2,28 @@ | |||
2 | 2 | ||
3 | # this is really a faq2html and should only be used for this purpose | 3 | # this is really a faq2html and should only be used for this purpose |
4 | 4 | ||
5 | while(<STDIN>) { | 5 | sub fixline { |
6 | |||
7 | $_ =~ s/\</</g; | 6 | $_ =~ s/\</</g; |
8 | $_ =~ s/\>/>/g; | 7 | $_ =~ s/\>/>/g; |
9 | 8 | ||
10 | $_ =~ s/(http:\/\/([a-zA-Z0-9_.\/-]*)[^\).])/\<a href=\"$1\"\>$1\<\/a\>/g; | 9 | $_ =~ s/(http:\/\/([a-zA-Z0-9_.\/-]*)[^\) .\n])/\<a href=\"$1\"\>$1\<\/a\>/g; |
11 | 10 | ||
12 | $_ =~ s/^$/\ /g; # empty lines are nbsp | 11 | $_ =~ s/^$/\ /g; # empty lines are nbsp |
13 | $_ =~ s/(\\|\/)$/$1 /g; # clobber backslash on end of line | 12 | $_ =~ s/(\\|\/)$/$1 /g; # clobber backslash on end of line |
13 | } | ||
14 | 14 | ||
15 | while(<STDIN>) { | ||
16 | |||
17 | fixline($_); | ||
15 | 18 | ||
16 | # detect and mark Q-sections | 19 | # detect and mark Q-sections |
17 | if( $_ =~ /^Q(\d*)/) { | 20 | if( $_ =~ /^Q(\d*)/) { |
18 | print "</pre>\n<a name=\"$1\"></a><p class=\"faqq\">$_"; | 21 | print "</pre>\n<a name=\"$1\"></a><p class=\"faqq\">$_"; |
19 | my $line; | 22 | my $line; |
20 | while(<STDIN>) { | 23 | while(<STDIN>) { |
24 | |||
25 | fixline($_); | ||
26 | |||
21 | $line = $_; | 27 | $line = $_; |
22 | if($_ !~ /^A/) { | 28 | if($_ !~ /^A/) { |
23 | print "$_"; | 29 | print "$_"; |