changes
This commit is contained in:
10
reveal.sh
10
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|(<section data-markdown=\")[A-Za-z0-9\.-]*(\" )|\1$fn\2|" index.html
|
||||
sed -i -E "s|(<section data-markdown=\")[A-Za-z0-9\.-]*(\" )|\1$basefn\2|" index.html
|
||||
npm start -- --port=$portNumber
|
||||
# npm start
|
||||
|
||||
60
sbib
60
sbib
@@ -39,47 +39,47 @@ set -e #exit if an error
|
||||
|
||||
|
||||
view_bib() {
|
||||
# Use fzf to search citation
|
||||
# Initial scroll offset is set to the line number of each line
|
||||
# of git grep output *minus* 5 lines (-5)
|
||||
# str=$(cat $fn | fzf)
|
||||
# Use fzf to search citation
|
||||
# Initial scroll offset is set to the line number of each line
|
||||
# of git grep output *minus* 5 lines (-5)
|
||||
# str=$(cat $fn | fzf)
|
||||
|
||||
# str=$(git grep -E --line-number $sPattern $bibdFile | fzf --delimiter : --preview 'nl {1} --body-numbering=a' --preview-window=:up:70%:+{2}-5)
|
||||
# str=$(git grep -E --line-number $sPattern $bibdFile | fzf --delimiter : --preview 'less {1}' --preview-window=:up:70%:+{2}-5)
|
||||
str=$(git grep -E --line-number $sPattern $bibdFile | fzf --delimiter : --preview 'bat --color=always --style=numbers --line-range=:500 {1}' --preview-window=:up:70%:+{2}-5)
|
||||
# str=$(git grep -E --line-number $sPattern $bibdFile | fzf --delimiter : --preview 'nl {1} --body-numbering=a' --preview-window=:up:70%:+{2}-5)
|
||||
# str=$(git grep -E --line-number $sPattern $bibdFile | fzf --delimiter : --preview 'less {1}' --preview-window=:up:70%:+{2}-5)
|
||||
str=$(git grep -E --line-number $sPattern $bibdFile | fzf --delimiter : --preview 'bat --color=always --style=numbers --line-range=:500 {1}' --preview-window=:up:70%:+{2}-5)
|
||||
|
||||
|
||||
# extract citation key from the fzf string
|
||||
citeKey=$(echo $str | sed -E "s|$(basename $bibdFile):[0-9]+:@[a-zA-Z]+\{(.+),|\1|")
|
||||
# extract citation key from the fzf string
|
||||
citeKey=$(echo $str | sed -E "s|$(basename $bibdFile):[0-9]+:@[a-zA-Z]+\{(.+),|\1|")
|
||||
|
||||
#method1
|
||||
#todo: use json with jq
|
||||
# outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $bibdFile --citeproc --csl $cslFile | tail -n +3)
|
||||
#method1
|
||||
#todo: use json with jq
|
||||
# outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $bibdFile --citeproc --csl $cslFile | tail -n +3)
|
||||
|
||||
#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
|
||||
#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} &)"
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
spdf.sh
4
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 ?
|
||||
|
||||
Reference in New Issue
Block a user