changes
This commit is contained in:
10
reveal.sh
10
reveal.sh
@@ -13,8 +13,7 @@ fi
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# appPath="$HOME/projects/dev/reveal.js"
|
appPath="$HOME/projects/dev/reveal.js"
|
||||||
appPath="$HOME/projects/archive/external/reveal.js"
|
|
||||||
portNumber=${2:-8000}
|
portNumber=${2:-8000}
|
||||||
|
|
||||||
if [[ ! -d $appPath ]]; then
|
if [[ ! -d $appPath ]]; then
|
||||||
@@ -25,11 +24,12 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
fn=$1 #markdown document to render e.g. neuroanatomy1.md
|
fn=$1 #markdown document to render e.g. neuroanatomy1.md
|
||||||
if [[ ! -e $fn ]]; then
|
basefn=$(basename $fn)
|
||||||
ln -s $fn $(basename $fn)
|
if [[ ! -e $basefn ]]; then
|
||||||
|
ln -s $fn $basefn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#add markdown filename to reveal placeholder start file
|
#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 -- --port=$portNumber
|
||||||
# npm start
|
# npm start
|
||||||
|
|||||||
60
sbib
60
sbib
@@ -39,47 +39,47 @@ set -e #exit if an error
|
|||||||
|
|
||||||
|
|
||||||
view_bib() {
|
view_bib() {
|
||||||
# Use fzf to search citation
|
# Use fzf to search citation
|
||||||
# Initial scroll offset is set to the line number of each line
|
# Initial scroll offset is set to the line number of each line
|
||||||
# of git grep output *minus* 5 lines (-5)
|
# of git grep output *minus* 5 lines (-5)
|
||||||
# str=$(cat $fn | fzf)
|
# 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 '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 '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 'bat --color=always --style=numbers --line-range=:500 {1}' --preview-window=:up:70%:+{2}-5)
|
||||||
|
|
||||||
|
|
||||||
# extract citation key from the fzf string
|
# extract citation key from the fzf string
|
||||||
citeKey=$(echo $str | sed -E "s|$(basename $bibdFile):[0-9]+:@[a-zA-Z]+\{(.+),|\1|")
|
citeKey=$(echo $str | sed -E "s|$(basename $bibdFile):[0-9]+:@[a-zA-Z]+\{(.+),|\1|")
|
||||||
|
|
||||||
#method1
|
#method1
|
||||||
#todo: use json with jq
|
#todo: use json with jq
|
||||||
# outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $bibdFile --citeproc --csl $cslFile | tail -n +3)
|
# outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $bibdFile --citeproc --csl $cslFile | tail -n +3)
|
||||||
|
|
||||||
#method2
|
#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
|
#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
|
#and because pandoc expects a file input for bibliography
|
||||||
tmpName=$(mktemp --suffix=.bib)
|
tmpName=$(mktemp --suffix=.bib)
|
||||||
str3=$(grep -A 30 $citeKey $bibdFile)
|
str3=$(grep -A 30 $citeKey $bibdFile)
|
||||||
echo $str3 | sed -E "s|(.+\} ?\}).+|\1|" > $tmpName
|
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)
|
outCitation=$(pandoc -f latex <(echo "\cite{$citeKey}") -t plain -o - --bibliography $tmpName --citeproc --csl $cslFile | tail -n +3)
|
||||||
rm $tmpName
|
rm $tmpName
|
||||||
|
|
||||||
#tail -n +61 $fn | sed -E "s#(.+\}\})#\1#"
|
#tail -n +61 $fn | sed -E "s#(.+\}\})#\1#"
|
||||||
# fzf --preview="head {}" --preview-window=up:30%
|
# fzf --preview="head {}" --preview-window=up:30%
|
||||||
# fzf --preview="file {}" --preview-window=down:1
|
# fzf --preview="file {}" --preview-window=down:1
|
||||||
echo $outCitation
|
echo $outCitation
|
||||||
echo $outCitation | wl-copy
|
echo $outCitation | wl-copy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
view_json() {
|
view_json() {
|
||||||
# export citeKey=$1
|
# export citeKey=$1
|
||||||
# doiStr=$(jq -r '.[] | select(.id==env.citeKey).DOI' $bibdFile)
|
# doiStr=$(jq -r '.[] | select(.id==env.citeKey).DOI' $bibdFile)
|
||||||
# urlStr=$(jq -r '.[] | select(.id==env.citeKey).URL' $bibdFile)
|
# urlStr=$(jq -r '.[] | select(.id==env.citeKey).URL' $bibdFile)
|
||||||
|
|
||||||
#actually this is the good one, opens pdfs quickly
|
#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} &)"
|
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
|
#!/bin/bash
|
||||||
if [ "$1" == "-h" ] ; then
|
if [ "$1" == "-h" ] ; then
|
||||||
echo "
|
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:
|
usage:
|
||||||
pdf2bib.sh file.pdf
|
spdf.sh file.pdf
|
||||||
|
|
||||||
depends:
|
depends:
|
||||||
pdftotext - from ghostscript or poppler or texlive ?
|
pdftotext - from ghostscript or poppler or texlive ?
|
||||||
|
|||||||
Reference in New Issue
Block a user