From 6c206e86ec8e18ccf5d67b1fc796c70764ba0297 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 31 Mar 2017 15:41:32 +0200 Subject: Use OSCOLA with no ibid as citation style. --- Makefile | 1 + oscola-no-ibid.csl | 683 +++++++++++++++++++++++++++++++++++++++++++++++++++++ pandoc-cs1 | 32 +++ 3 files changed, 716 insertions(+) create mode 100644 oscola-no-ibid.csl diff --git a/Makefile b/Makefile index 3912400..b2178d7 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ args_meta += -V subtitle="$(subtitle)" args_meta += -M author="Carlo Piana, Ulf Öberg" args_meta += -V author="Carlo Piana" -V author="Ulf Öberg" args_meta += -V date="" +args_meta += -M csl=oscola-no-ibid.csl args_latex += --template=template.tex --latex-engine=xelatex args_latex += -H header.tex -B before.tex -A after.tex args_latex += -V mainfont="Lora" -V sansfont="Quattrocento Sans" -V monofont="Inconsolata" diff --git a/oscola-no-ibid.csl b/oscola-no-ibid.csl new file mode 100644 index 0000000..1fe428a --- /dev/null +++ b/oscola-no-ibid.csl @@ -0,0 +1,683 @@ + + diff --git a/pandoc-cs1 b/pandoc-cs1 index 0eafbc3..e5620c9 100755 --- a/pandoc-cs1 +++ b/pandoc-cs1 @@ -35,6 +35,38 @@ pandoc_filter sub { '@'.$1.'{'.$id, @data, '}'); + if ( ! $bibdata->get('author') ) { + my @authors; + for ( my $i = 1;; $i++ ) { + my ( $first, $last ); + if ( $i == 1 and $bibdata->get('first') ) { + $first = $bibdata->get("first$i"); + $bibdata->delete("first$i"); + } elsif ( $bibdata->get("first$i") ) { + $first = $bibdata->get('first'); + $bibdata->delete('first'); + } + if ( $i == 1 and $bibdata->get('last') ) { + $last = $bibdata->get('last'); + $bibdata->delete('last'); + } elsif ( $bibdata->get("last$i") ) { + $last = $bibdata->get("last$i"); + $bibdata->delete("last$i"); + } + if ( $first and $last ) { + push @authors, "$first {$last}"; + } elsif ($first) { + push @authors, $first; + } elsif ($last) { + push @authors, $last; + } else { + last; + } + } + if ( @authors > 0 ) { + $bibdata->set( 'author', join ( ' and ', @authors ) ); + }; + }; if ( $bibdata->type =~ /web/i ) { $bibdata->set_type('online'); if ( my $urldate = $bibdata->get('accessdate') ) { -- cgit v1.2.3