aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rwxr-xr-xbin/biblatex-tidy.sh16
2 files changed, 18 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 0fa7b03..2ffbbe7 100644
--- a/Makefile
+++ b/Makefile
@@ -99,9 +99,8 @@ lint-markdown:
tidy: tidy-bibtex tidy-perl
-tidy-bibtex:
- bibclean -max-width 0 ref.bib > ref.bib~
- mv ref.bib~ ref.bib
+tidy-bibtex: ref.bib
+ bin/biblatex-tidy.sh $<
tidy-perl:
perltidy -b -bext='/' --profile=.perltidyrc $(PERL_FILES)
diff --git a/bin/biblatex-tidy.sh b/bin/biblatex-tidy.sh
new file mode 100755
index 0000000..a29632d
--- /dev/null
+++ b/bin/biblatex-tidy.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# tidy BibLaTeX file
+
+# Depends: bibclean
+
+set -eu
+
+INFILE=$1
+
+# workaround: strip JabRef comment that bibclean chokes on
+perl -gpe 's/^\@Comment\{jabref-meta: databaseType:biblatex;\}$//m' < $INFILE > $INFILE~
+bibclean -max-width 0 $INFILE~ > $INFILE~~
+printf '\n%s\n' '@Comment{jabref-meta: databaseType:biblatex;}' >> $INFILE~~
+mv -f $INFILE~~ $INFILE
+rm -f $INFILE~