mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 8f1ab3afbdcb045ea3f67ab0a524a6e076565219
parent 6212033e4ba32c5dcfecf6c0849eaf4703de7a8b
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Thu, 26 Sep 2013 23:03:58 +0200

fixes

Diffstat:
shorthand.pl | 59+++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 20 deletions(-)

diff --git a/shorthand.pl b/shorthand.pl @@ -9,7 +9,7 @@ my @envd = qw(); my $subsecneeded = 0; my $header = <<END; \\documentclass{beamer} -\\usepackage[utf8]{inputenc} +\\usepackage{fontspec} \\usepackage{graphicx, verbatim, array, xspace, booktabs, tikz, url, etoolbox,multirow,tabularx,minibox,tikz-qtree,minted} \\usetheme{Frankfurt} \\usecolortheme{beaver} @@ -22,8 +22,6 @@ my $header = <<END; \\end{center} \\end{figure} } -\\DeclareUnicodeCharacter{0169}{\\~u} -\\DeclareUnicodeCharacter{0144}{\'n} \\setbeamertemplate{navigation symbols}{} \\makeatletter \\setbeamertemplate{footline} @@ -44,6 +42,13 @@ my $header = <<END; \\item[]}{\\end{list}} END +sub reformat() +{ + my $ll = $_[0]; + $ll =~ s/\*([^*]+)\*/\\textcolor{red}{$1}/g; + $ll =~ s/\`([^`]+)\`/\\texttt{$1}/g; + $ll; +} my $header2 = <<END; \\AtBeginSection[] @@ -76,14 +81,14 @@ print $header2; while (<>) { my $l = $_; if ($escaping) { - if ($l =~ /\?>/) { + if ($l =~ /^\?>$/) { $escaping = 0; } else { print $l; } next; } - if ($l =~ /<\?/) { + if ($l =~ /^<\?$/) { $escaping = 1; next; } @@ -91,22 +96,24 @@ while (<>) { print "\\end{frame}\n\n" if ($in_frame == 1); print "\\subsection\{\}\n" if ($subsecneeded == 1); $subsecneeded = 0; + $tit = &reformat($2); if ($1 eq "!f") { - print "\\begin{frame}[fragile]\{$2\}\n"; + # TODO: do this automatically + print "\\begin{frame}[fragile]\{$tit\}\n"; } else { - print "\\begin{frame}\{$2\}\n"; + print "\\begin{frame}\{$tit\}\n"; } $in_frame = 1; next; } - if ($l =~ /^(=+) (.*) (=+)$/) { + if ($l =~ /^(=+) (.*) (=+)(!?)$/) { print "\\end{frame}\n\n" if ($in_frame == 1); $in_frame = 0; my $nest = length($1); my $level; if ($nest == 2) { $level = "section"; - $subsecneeded = 1; + $subsecneeded = 1 if ($4 eq ""); } if ($nest == 3) { $level = "subsection"; @@ -135,33 +142,45 @@ while (<>) { my $ed = pop @envd; print "\\end{$e}\n\n"; } - if (@envd == 0 or $indent > $envd[-1]) { - $e = "itemize" if ($2 eq "-"); - $e = "description" if ($2 eq "["); - print "\\begin\{$e\}\n"; - push (@env, $e); - push (@envd, $indent); - } my $key = ""; if ($2 eq "[") { if ($3 =~ /([^]]*)\](.*)/) { - $l = "$2\n"; + $l = "$2"; $key = $1; } } else { if ($2 eq "=>") { $key = "\$\\Rightarrow\$"; } - $l = "$3\n"; + $l = "$3"; + } + if (@envd == 0 or $indent > $envd[-1]) { + my $symb = $2; + if ($symb eq "[") { + $e = "description"; + } else { + $e = "itemize"; + } + push (@env, $e); + push (@envd, $indent); + if ($l =~ /^ *$/ and $symb eq "[") { + # TODO: do this automatically + print "\\begin\{$e\}\[$key\]\n"; + next; + } else { + print "\\begin\{$e\}\n"; + } } + $key = &reformat($key); if (length($key) > 0) { print "\\item[$key] "; } else { print "\\item "; } + $l = "$l\n"; } - $l =~ s/\*([^*]+)\*/\\textcolor{red}{$1}/g; - print "$l"; + $l = &reformat($l); + print $l; } print "\\end{frame}\n\n" if ($in_frame == 1);