From 3cb839de7a7681ad7eba170a4eadc36386a6caed Mon Sep 17 00:00:00 2001 From: ackman678 Date: Sat, 29 May 2021 08:19:30 -0400 Subject: [PATCH] changes --- reveal.sh | 10 +++++----- sbib | 60 +++++++++++++++++++++++++++---------------------------- spdf.sh | 4 ++-- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/reveal.sh b/reveal.sh index 85f6752..673953f 100755 --- a/reveal.sh +++ b/reveal.sh @@ -13,8 +13,7 @@ fi set -e -# appPath="$HOME/projects/dev/reveal.js" -appPath="$HOME/projects/archive/external/reveal.js" +appPath="$HOME/projects/dev/reveal.js" portNumber=${2:-8000} if [[ ! -d $appPath ]]; then @@ -25,11 +24,12 @@ else fi fn=$1 #markdown document to render e.g. neuroanatomy1.md -if [[ ! -e $fn ]]; then - ln -s $fn $(basename $fn) +basefn=$(basename $fn) +if [[ ! -e $basefn ]]; then + ln -s $fn $basefn fi #add markdown filename to reveal placeholder start file -sed -i -E "s|(
$tmpName -outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $tmpName --citeproc --csl $cslFile | tail -n +3) -rm $tmpName + #method2 + #need to use a temporary bib file as input to pandoc because parsing a large bib file is too slow, but json input would be faster + #and because pandoc expects a file input for bibliography + tmpName=$(mktemp --suffix=.bib) + str3=$(grep -A 30 $citeKey $bibdFile) + echo $str3 | sed -E "s|(.+\} ?\}).+|\1|" > $tmpName + outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $tmpName --citeproc --csl $cslFile | tail -n +3) + rm $tmpName -#tail -n +61 $fn | sed -E "s#(.+\}\})#\1#" -# fzf --preview="head {}" --preview-window=up:30% -# fzf --preview="file {}" --preview-window=down:1 -echo $outCitation -echo $outCitation | wl-copy + #tail -n +61 $fn | sed -E "s#(.+\}\})#\1#" + # fzf --preview="head {}" --preview-window=up:30% + # fzf --preview="file {}" --preview-window=down:1 + echo $outCitation + echo $outCitation | wl-copy } view_json() { -# export citeKey=$1 -# doiStr=$(jq -r '.[] | select(.id==env.citeKey).DOI' $bibdFile) -# urlStr=$(jq -r '.[] | select(.id==env.citeKey).URL' $bibdFile) + # export citeKey=$1 + # doiStr=$(jq -r '.[] | select(.id==env.citeKey).DOI' $bibdFile) + # urlStr=$(jq -r '.[] | select(.id==env.citeKey).URL' $bibdFile) -#actually this is the good one, opens pdfs quickly -jq -r '.[] | [.id, .title, .abstract, .keyword, .DOI, .PMID, .author[]?.family, .issued[]?[0]?[0], .["container-title"], .URL] | join(" ")' $bibdFile | fzf --preview 'echo {}' --preview-window=:up:70%:wrap --bind "enter:execute-silent(zathura {-1} &)" + #actually this is the good one, opens pdfs quickly + jq -r '.[] | [.id, .title, .abstract, .keyword, .DOI, .PMID, .author[]?.family, .issued[]?[0]?[0], .["container-title"], .URL] | join(" ")' $bibdFile | fzf --preview 'echo {}' --preview-window=:up:70%:wrap --bind "enter:execute-silent(zathura {-1} &)" } diff --git a/spdf.sh b/spdf.sh index 9d72a81..8aa2bb9 100755 --- a/spdf.sh +++ b/spdf.sh @@ -1,10 +1,10 @@ #!/bin/bash if [ "$1" == "-h" ] ; then echo " - pdf2bib - search for a doi within a pdf, query pubmed, and append bibtex entry with pdf to your local bib database file. Last two steps are identical to sdoi.sh + spdf - search for a doi within a pdf. If found, use sdoi.sh to query pubmed, and append bibtex entry with the pdf to your local bib database file usage: - pdf2bib.sh file.pdf + spdf.sh file.pdf depends: pdftotext - from ghostscript or poppler or texlive ?