head 1.13; access; symbols SYSADMIN_FORWARD:1.12; locks; strict; comment @# @; 1.13 date 2003.01.19.11.15.16; author rse; state Exp; branches; next 1.12; 1.12 date 2002.04.05.22.06.08; author rse; state Exp; branches; next 1.11; 1.11 date 2002.04.05.21.24.30; author rse; state Exp; branches; next 1.10; 1.10 date 2002.04.05.13.19.33; author rse; state Exp; branches; next 1.9; 1.9 date 2002.04.03.14.39.44; author rse; state Exp; branches; next 1.8; 1.8 date 2002.04.02.14.07.30; author rse; state Exp; branches; next 1.7; 1.7 date 2002.04.01.11.35.52; author rse; state Exp; branches; next 1.6; 1.6 date 2002.03.28.21.16.49; author rse; state Exp; branches; next 1.5; 1.5 date 2002.03.28.21.02.08; author rse; state Exp; branches; next 1.4; 1.4 date 2002.03.28.20.55.44; author rse; state Exp; branches; next 1.3; 1.3 date 2002.03.28.14.13.08; author rse; state Exp; branches; next 1.2; 1.2 date 2002.03.28.12.53.06; author rse; state Exp; branches; next 1.1; 1.1 date 2002.03.28.12.38.10; author rse; state Exp; branches; next ; desc @@ 1.13 log @update article to reflect OpenPKG 1.2 @ text @#!/usr/bin/perl ## ## article.txt2html.pl -- Convert original article into HTML preview ## # read original article text print STDOUT "++ reading article.txt\n"; open(FP, "); close(FP); # start by escaping my $html = $txt; $html =~ s|&|&|sg; $html =~ s|<|<|sg; $html =~ s|>|>|sg; # split into text and attachment parts $html =~ m|^(.+)\n_____+\n(.+)$|s; my ($html1, $html2) = ($1, $2); # translate the text part $html1 =~ s|C<(.+?)>|$1|sg; $html1 =~ s|I<(.+?)>|$1|sg; $html1 =~ s|U<(.+?)>|$1|sg; $html1 =~ s|\n([^\n]+)\n==+\s*\n|\n

$1

\n|sg; $html1 =~ s|\n([^\n]+)\n~~+\s*\n|\n

$1

\n|sg; $html1 =~ s|\n([^\n]+)\n--+\s*\n|\n

$1

\n|sg; $html1 =~ s|\n\n+|\n

\n|sg; $html1 =~ s/((Ralf|Thomas|Michael|Christoph).+?\S+\@@[^\n]+)/$1<\/font><\/i>/sg; $html1 =~ s/((Listing|Table|Figure)_(\d+))/$2 $3<\/a>/sg; # translate the attachment parts $html2 =~ s;\n((?:Table|Listing)[^\n]+)\n-{78}\s*\n(.+?\n)-{78}; \n

$1
$2

;sg; $html2 =~ s;\n(Figure[^\n]+)\n-{78}\s*\n\s*(.+?)\s*\n-{78}; \n

$1

;sg; $html2 =~ s||&doimg($1)|sge; $html2 =~ s/((Listing|Table|Figure)_(\d+))/$2 $3<\/a>/sg; sub doimg { my ($src) = @@_; $src =~ s|^\s+||s; $src =~ s|\s+$||s; my ($base, $ext) = ($src =~ m|^(.+?)\.([^.]+)$|); if ($ext eq 'fig') { if (not -f "$base.png") { print STDOUT "++ creating $base.png\n"; system("fig2dev -L png -m 1.0 $base.fig $base.png"); } $src = "\"\""; } return $src; } # join together again and surround with HTML environment my ($html1a, $html1b) = ($html1 =~ m|^(.+?)(Regarding configuration.+)$|s); $html = "\n" . "\n" . "\n" . "\n" . "OpenPKG: SysAdmin magazine article\n" . "\n" . "\n" . "" . "" . "" . "" . "
\n" . "\"\"

\n" . $html1a . "

" . "  " . "\n" . $html1b . "
\n" . "

\n" . "
\n" . $html2 . "
\n" . "\n" . "\n"; # write to HTML preview file print STDOUT "++ creating article.html\n"; open(FP, ">article.html") || die; print FP $html; close(FP); @ 1.12 log @polish About authors section @ text @d67 1 a67 1 my ($html1a, $html1b) = ($html1 =~ m|^(.+?)(Most sections.+)$|s); @ 1.11 log @polish layouting @ text @d31 1 a31 1 $html1 =~ s/((Ralf|Thomas|Christoph).+?\S+\@@[^\n]+)/$1<\/font><\/i>/sg; @ 1.10 log @use no magnification @ text @d67 1 a67 1 my ($html1a, $html1b) = ($html1 =~ m|^(.+?)(The rc command.+)$|s); d73 2 a74 1 "H1,H2,H3 { font-family: tahoma,helvetica,lucida,arial,sans-serif; margin-bottom: 6px; }\n" . @ 1.9 log @more polishing @ text @d59 1 a59 1 system("fig2dev -L png -m 1.5 $base.fig $base.png"); @ 1.8 log @fix images @ text @d32 1 d50 1 d61 1 a61 1 $src = " alt=\"\""; d67 1 a67 1 my ($html1a, $html1b) = ($html1 =~ m|^(.+)(

OpenPKG RPM.+)$|s); @ 1.7 log @fix markup @ text @d48 1 a48 1 $html2 =~ s||&doimg($1)|sge; @ 1.6 log @resemble original magazine layouting even a little bit more @ text @d45 1 a45 1 d59 1 a59 1 $src = ""; d66 2 a67 1 $html = "\n" . d73 1 d78 1 a78 1 "

\n" . @ 1.5 log @break into more readable paragraphs @ text @d31 1 @ 1.4 log @use a two-column layout for better resembling the magazine @ text @d69 1 a69 1 "H1,H2,H3 { font-family: tahoma,helvetica,lucida,arial,sans-serif; margin-bottom: 4px; }\n" . @ 1.3 log @add logo proposal @ text @d64 1 d73 2 a74 1 "
\n" . d76 9 a84 2 $html1 . "
\n" . @ 1.2 log @polishing @ text @d73 1 d84 1 a84 1 print STDOUT "++ creating article,html\n"; @ 1.1 log @No, no, no, the article.txt has to be the file which we finally send to SysAdmin magazine, so we cannot clutter this with too much markup, friends! We cannot see any longer the forrest because of too much trees. The idea of a HTML preview version is certainly great, but, guys, real hackers do this by investigating an hours and hacking together a small Perl script which generates such a preview version out of the original on-the-fly. I've done this now for us. Run "make" and you get the preview in article.html. Think a little bit longer next time before starting to implement great ideas with bad solutions, please. Thanks. @ text @d2 7 a8 1 d10 2 a11 1 $txt .= $_ while (); d13 1 a14 1 d19 1 d23 1 d32 1 d39 1 a39 3

;sg; d46 1 a46 2

;sg; d55 1 d63 1 d82 5 a86 1 print STDOUT $html; @