Accept attributes in inline image syntax
[multimarkdown] / Utilities / cleancites.pl
1 #!/usr/bin/env perl
2 #
3 # $Id: cleancites.pl 482 2008-01-12 23:07:32Z fletcher $
4 #
5 # Adds some utilities for making fancier citations with natbib
6 #
7 # Copyright (c) 2006-2008 Fletcher T. Penney
8 #       <http://fletcherpenney.net/>
9 #
10 # MultiMarkdown Version 2.0.b5
11 #
12
13
14 undef $/;
15 $data = <>;
16
17 # Clean up strings of \cites into one citation
18
19 while ($data =~ s{
20         (\\cite[tp]?\*?)((?:\[(?:see|e\.g\.)\]\[\])?\{)(.*?)\}
21         \1\{(.*?)\}
22 }{
23         $1 . "$2$3, $4\}";      
24 }egmx) {
25         
26         
27 }
28
29
30 # And clean up custom cites that got escaped
31 # e.g. $\backslash$citeyearpar\{Dewey:1997\}
32
33 $data =~ s{
34         \$\\backslash\$(cite.*?)
35         \\\{(.*?)\\\}
36 }{
37         "\\" . $1 . "{$2}";
38 }egmx;
39
40 print $data;