Commit b841d81b authored by User expired's avatar User expired
Browse files

Maximal 4 journal letters in citation key and filename

parent a58c0d36
Pipeline #28116 passed with stage
in 1 minute and 32 seconds
......@@ -205,14 +205,17 @@ function updatekeys() { # updatekeys bibfile skipj bibfile [letter]
sub(":", "", letter)
}
# Create citation key.
citekey = fauthor year letter ":" tolower(journal)
# Drop remaining non ascii characters.
gsub("[^" ALLOWED_CHARS "]", "", citekey)
gsub("[^" ALLOWED_CHARS "]", "", fauthor)
gsub("[^" ALLOWED_CHARS "]", "", journal)
gsub("[^" ALLOWED_CHARS "]", "", year)
# Merge dashes.
gsub("---*", "-", citekey)
gsub("---*", "-", fauthor)
gsub("---*", "-", journal)
# Create citation key (journal: maximum four lower case letters).
citekey = fauthor year letter ":" tolower(substr(journal,1,4))
# Drop trailing dash or colon.
sub("[-:]$", "", citekey)
......
......@@ -94,6 +94,7 @@ do
else
journal=$(getvalue Journal "$bibfile")
fi
longjournal=$(echo "$journal" | bib-convu)
if [ $SKIPJ -eq 0 ]
then
......@@ -105,7 +106,6 @@ do
-e 's/[,:].*//;s/OF //;s/\<[Tt][Hh][Ee]\>//' \
-e 's/([A-Za-z]+) */\1/g;s/[a-z. ]//g' \
-e 's/ *[[({].*//')
longjournal=$(getvalue Journal "$bibfile" | bib-convu)
year=$(getvalue Year "$bibfile")
......@@ -118,10 +118,15 @@ do
letter="${letter#:}" # Remove preceding colon.
fi
# Only keep allowed characters and merge dashes.
fauthor=$(sed "s/[^$ALLOWED_CHARS]//g;s/---*/-/g" <<< "$fauthor")
journal=$(sed "s/[^$ALLOWED_CHARS]//g;s/---*/-/g" <<< "$journal")
# Keep only the first four letters for the journal.
journal=$(echo "$journal" | sed 's/^\(....\).*/\1/')
# New file names.
newpdfname="${fauthor}_${year}${letter}_${journal}"
# Only keep allowed characters and merge dashes.
newpdfname=$(sed "s/[^$ALLOWED_CHARS]//g;s/---*/-/g" <<< "$newpdfname")
# Add path prefix and file suffixes.
newbibname="$(dirname "$bibfile")/${newpdfname}.pdf.bib"
newpdfname="$(dirname "$bibfile")/${newpdfname}.pdf"
......
......@@ -98,9 +98,9 @@ testJournalLongName() {
assertEquals ':zp' "$(bib-keyinsert -s $fileOne | getkey)"
}
testJournalLetters() {
testJournalMaxFourLetters() {
echo -e '@Article{,\nJournal = {Proc. Natl. Acad. Sci. U.S.A.},' > $fileOne
assertEquals ':pnasusa' "$(bib-keyinsert $fileOne | getkey)"
assertEquals ':pnas' "$(bib-keyinsert $fileOne | getkey)"
}
testJournalAmpersand() {
......
......@@ -71,9 +71,9 @@ testJournalLongName() {
assertEquals '__ZP' "$(bib-name -n -s $fileOne | getname)"
}
testJournalLetters() {
testJournalMaxFourLetters() {
echo -e '@Article{,\nJournal = {Proc. Natl. Acad. Sci. U.S.A.},' > $fileOne
assertEquals '__PNASUSA' "$(bib-name -n $fileOne | getname)"
assertEquals '__PNAS' "$(bib-name -n $fileOne | getname)"
}
testJournalAmpersand() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment