#!/usr/bin/perl undef $/; #$/=''; open(F,"|prel -a") or die; while(<>){ $_ = sp2tex($_); s{\n(=\.)(=+)[ \t]*(.*)}{\n$2 $3\n$1 $3}g; s{ \n=\.[ \t]*(.*) (\n(.|\n)*?) (?=\n(?:=|\d\.))} { my ($a,$b)=($1,$2); if($a){ if($b =~ /Verbatim/){ "\n\\begin{frame}[fragile]\\frametitle{$a}\n$b\\end{frame}\n"} else{ "\n\\begin{frame}\\frametitle{$a}\n$b\\end{frame}\n"}} else{ if($b =~ /Verbatim/){ "\n\\begin{frame}[fragile]\n$b\\end{frame}\n"} else{ "\n\\begin{frame}\n$b\\end{frame}\n"}} }xeg; s{\n=\.}{}g; s{\n(:\n[ \t]*\.)}{\\$1}g; print F $_; } # {\n\\begin{frame}[fragile]\n\\frametitle{$1} sub math2html{ my $f=shift; # $f =~ s/\&/\&/g; $f =~ s/-->/\\rightarrow /g; # a --> b $f =~ s/<--/\\leftarrow /g; # a <-- b $f =~ s!/\\!\\and !g; # a /\ b $f =~ s!\\/!\\vee !g; # a \/ b $f =~ s/==>/\\doublerightarrow /g; # a ==> b $f =~ s/<==/\\doubleleftarrow /g; # a <== b # $f =~ s//\>/g; $f; } sub txt2html{ my $f=shift; $f =~ s/\n +
*\n/\n---hr---\n/g; $f =~ s/\&/\\&/g; # $f =~ s//\>/g; $f =~ s/\n---hr---\n/\hrule\n/g; $f; } sub markLi{ my $a=shift; for($a){ s{\n\s*\.\d?(.*?)(?=(\n\s*\.|$))}{\\item $1}gs; } $a } sub sp2tex { my $pagina = shift; my %verb=(); my $n=0; my $orange="green"; if ($pagina) { for ($pagina) { s/\cM//g; s/[ \t]+\n/\n/g; # delete after __END__ s/\n__END__.*/\n/s; s/(\\end\{document\}).*/$1\n/s; #Verbatim paragraphs s{(\\begin\{Verbatim\}[^\n]*)(.*?)(\\end\{Verbatim\})}{ $verb{++$n}= $1.txt2html($2).$3; "\n\n\caMARCA\ca$n\n"}segi; #Verbatim paragraphs s{\n\n([ \t]+\S.*?)(?=\s*\n\S|$)}{ $verb{++$n}= "\\begin{Verbatim}\n".txt2html($1)."\n\\end{Verbatim}"; "\n\n\caMARCA\ca$n\n"}seg; # Hard rule s/(\n)---+[^\n+]*($|\n)/$1\\hrule\n/g; # bolds, italics, tts, wiki-like # s!__([^_]+)__!$1!g; s!_\((.+?)\)_!"\\color{$orange}\\(".math2html($1)."\\)\\color{black}"!eg; s!_\[(.+?)\]_!"\n\\color{$orange}\\(".math2html($1)."\\)\\color{black}\n"!eg; # s!==(.+?)==!"".txt2html($1).""!eg; s!\b_\B((?:[^_\n]|\B_\B)+)\B_\b!\\emph{$1}!g; s!\B=\b([^=\n]+)\b=\B!"\\texttt{".txt2html($1)."}"!eg; s!\*(\[|\b)([^*]+)(\]|\b)\*!\\color{$orange}$2\\color{black}!g; # Links... # s#\[!img\[(.+?)\]\]##g; # s#\[!wimg\[(.+?)\]\]##g; s/\n\x01MARCA\x01(\d+)\n/$verb{$1}/g; } return $pagina; } else { return ""; } } __END__ =head1 NAME brev2s - slide wiki... =head1 SYNOPSIS brev2s f =head1 DESCRIPTION = section title == subsection title =. slide title =.== slide title and section at the same time =head2 EXPORT =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut