blob: 2d5532055f024433a2f307a599847e12bcd09a15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/perl
# Copyright (C) 2019 Sean Whitton
#
# This file is part of pandoc-citeproc-preamble.
#
# pandoc-citeproc-preamble is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# pandoc-citeproc-preamble is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pandoc-citeproc-preamble. If not, see
# <http://www.gnu.org/licenses/>.
use 5.028;
use strict;
use warnings;
use File::Basename qw(dirname);
use File::Spec::Functions qw(rel2abs);
our $output = "output.tex";
our $pcp = "../dist/build/pandoc-citeproc-preamble/pandoc-citeproc-preamble";
chdir(dirname(rel2abs(__FILE__)));
die "need to build before testing\n" unless -e $pcp;
unlink $output if -e $output;
print "testing with " . (`pandoc --version`)[0];
system "pandoc -s --filter pandoc-citeproc --bibliography=test.bib"
. " --filter $pcp -M citeproc-preamble=../examples/default.latex"
. " test.mdwn -f markdown -o $output";
# simple finite state machine to check that the preamble was inserted
# in the right place
open my $fh, '<', $output;
my $preamble = 0;
while (<$fh>) {
if ($_ eq "\\section*{References}\n") {
if ($preamble) {
die "preamble inserted twice!\n";
} else {
$preamble = 1;
}
} elsif (/A Book/) {
if ($preamble) {
say "success: citeproc preamble inserted as expected";
exit 0;
} else {
die "references inserted before/without preamble!\n";
}
}
}
if ($preamble) {
die "preamble without references!\n";
} else {
die "neither preamble nor references found!\n";
}
|