From 116318f1f5b38b4007c1f83cdb7f0501ae725a2d Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 9 Feb 2018 09:30:41 +0100 Subject: [PATCH] Added small script to process bibtex files --- src/Makefile.am | 1 + src/filters/rclbibtex.sh | 23 +++++++++++++++++++++++ src/sampleconf/mimeconf | 3 +++ src/sampleconf/mimemap | 1 + 4 files changed, 28 insertions(+) create mode 100755 src/filters/rclbibtex.sh diff --git a/src/Makefile.am b/src/Makefile.am index e337b4bf..5aa1aea4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -589,6 +589,7 @@ filters/rcl7z \ filters/rclabw \ filters/rclaptosidman \ filters/rclaudio \ +filters/rclbibtex.sh \ filters/rclcheckneedretry.sh \ filters/rclchm \ filters/rcldia \ diff --git a/src/filters/rclbibtex.sh b/src/filters/rclbibtex.sh new file mode 100755 index 00000000..4360354b --- /dev/null +++ b/src/filters/rclbibtex.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Remove unwanted data from bibtex file by deleting "bad" lines and +# cleaning "good" ones. + +if test "X$RECOLL_FILTER_FORPREVIEW" = "Xyes" ; then + sed \ + -e '/^$/N;/^\n$/D' \ + -e '/(bibdsk.*|month|bibsource|crossref|ee|groups|owner|pages|timestamp|url|file|price|citeulike.*|markedentry|posted-at)[[:space:]=]*/I d' \ + -e '/@[^{]*{/ d' \ + \ + -e 's/{//g' \ + -e 's/},\?$//g' \ + -e 's/^[ ]*//' \ + < $1 +else + sed -e '/(bibdsk.*|month|bibsource|crossref|ee|groups|owner|pages|timestamp|url|file|price|citeulike.*|markedentry|posted-at)[[:space:]=]*/I d' \ + -e '/@[^{]*{/ d' \ + \ + -e 's/^[^{]*{//g' \ + -e 's/},\?$//g' \ + -e 's/({|}|=)//g' \ + < $1 +fi diff --git a/src/sampleconf/mimeconf b/src/sampleconf/mimeconf index 432a6646..d3532322 100644 --- a/src/sampleconf/mimeconf +++ b/src/sampleconf/mimeconf @@ -166,6 +166,7 @@ text/x-c+ = internal text/x-csharp = internal text/plain text/css = internal text/plain application/javascript = internal text/plain +text/x-bibtex = exec rclbibtex.sh ; mimetype = text/plain text/x-csv = internal text/plain text/x-fictionbook = exec rclfb2 text/x-gaim-log = exec rclgaim @@ -284,6 +285,7 @@ text/x-fictionbook = document text/x-html-aptosid-man = aptosid-book text/x-html-sidux-man = sidux-book text/x-ini = txt +text/x-bibtex = txt text/x-lua = source text/x-java = source text/x-mail = message @@ -348,6 +350,7 @@ text = \ text/html \ text/plain \ text/rtf \ + text/x-bibtex \ text/x-c \ text/x-c++ \ text/x-c+ \ diff --git a/src/sampleconf/mimemap b/src/sampleconf/mimemap index 70b8d5c8..69b61ef5 100644 --- a/src/sampleconf/mimemap +++ b/src/sampleconf/mimemap @@ -10,6 +10,7 @@ .srt = text/x-srt .ini = text/x-ini .csv = text/x-csv +.bib = text/x-bibtex # Source files. # Defining them with specific types allows using a specific ext viewer (in