2020-12-21 10:41:07 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# TODO : Ajouter bibliographie, citations avec localisateurs et citations multiples
|
|
|
|
|
|
|
|
|
|
BIBLIO_FILE="$1"
|
|
|
|
|
OUTPUT_FILE="$2"
|
|
|
|
|
|
|
|
|
|
printMetadata() {
|
|
|
|
|
echo '---' > "$OUTPUT_FILE"
|
|
|
|
|
echo "bibliography: $BIBLIO_FILE" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "csl: $(ls | grep -E '.csl$')" >> "$OUTPUT_FILE"
|
|
|
|
|
echo '---' >> "$OUTPUT_FILE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printReferences() {
|
|
|
|
|
inlineBaseText="$1"
|
|
|
|
|
refList="$2"
|
|
|
|
|
iCit=0
|
|
|
|
|
while read -r ref ; do
|
|
|
|
|
iCit=$(($iCit+1))
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
2020-12-24 10:58:57 +00:00
|
|
|
|
if [[ $(grep '_special' <<< "$ref") ]] ; then
|
|
|
|
|
case "$ref" in
|
|
|
|
|
*SourceWithInternalDivisions*) echo \
|
|
|
|
|
"Localisation dans une source dans une première citation par la référence \
|
|
|
|
|
aux divisions de la source et à la page dans la publication \
|
|
|
|
|
$iCit (\\$ref)[$ref, {section VI, 5, 4}, p. 57]" >> "$OUTPUT_FILE";;
|
2021-01-03 15:03:54 +00:00
|
|
|
|
*LivreMultivolumePourLocator*) echo \
|
|
|
|
|
"Localisation dans un ouvrage en plusieurs volumes \
|
|
|
|
|
$iCit (\\$ref)[$ref, {volume ii}, p. 56]" >> "$OUTPUT_FILE";;
|
2020-12-24 10:58:57 +00:00
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
echo "$inlineBaseText $iCit (\\$ref)[$ref]" >> "$OUTPUT_FILE"
|
|
|
|
|
fi
|
2020-12-21 10:41:07 +00:00
|
|
|
|
done <<< "$refList"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printLocators() {
|
|
|
|
|
ref="$1"
|
|
|
|
|
for locator in 'livre' 'chapitre' 'colonne' 'figure' 'folio' 'numéro' 'ligne' 'note' 'opus' 'page' 'paragraphe' 'partie' 'section' 'sub verbo' 'verset' 'volume' ; do
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Un $locator[$ref, $locator 3]" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Plusieurs $locator[$ref, $locator 3-5]" >> "$OUTPUT_FILE"
|
|
|
|
|
done
|
|
|
|
|
for locator in 'l. ' ; do
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Un $locator[$ref, {p. 3}, ${locator}3]" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Plusieurs $locator[$ref, {p. 4}, ${locator}3-5]" >> "$OUTPUT_FILE"
|
2020-12-23 16:09:44 +00:00
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
2020-12-21 10:41:07 +00:00
|
|
|
|
echo "Plusieurs $locator dans la même page que le précédent[$ref, {p. 4}, ${locator}9-10]" >> "$OUTPUT_FILE"
|
2020-12-23 16:09:44 +00:00
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Une source dont on indique la section où se trouve la citation[@SourceLivreSimple, {section VI, 5, 3}, p. 56]" >> "$OUTPUT_FILE"
|
2021-03-08 19:45:34 +00:00
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Même chose en _ibidem_[@SourceLivreSimple, {section VI, 5, 3}, p. 56]" >> "$OUTPUT_FILE"
|
2020-12-21 10:41:07 +00:00
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printMultipleCitations() {
|
|
|
|
|
ref1="$1"
|
|
|
|
|
ref2="$2"
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Citation multiple[$ref1; $ref2]" >> "$OUTPUT_FILE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [[ ! $# -eq 2 || "${BIBLIO_FILE##*.}" != json || "${OUTPUT_FILE##*.}" != md ]] ; then
|
|
|
|
|
echo 'Syntaxe : ./generer-md-pour-citeproc.sh fichierBiblio.json fichierCitations.md'
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
refList="$(while read -r rawRef ; do
|
|
|
|
|
echo @"$rawRef"
|
|
|
|
|
done <<< $(grep -oE '"id": "[^"]+"' < "$BIBLIO_FILE" | cut -d '"' -f 4))"
|
|
|
|
|
|
|
|
|
|
printMetadata
|
|
|
|
|
printReferences "Première citation" "$refList"
|
|
|
|
|
printReferences "Deuxième citation" "$refList"
|
|
|
|
|
printLocators "$(sed -n 1p <<< $refList)"
|
|
|
|
|
printMultipleCitations "$(sed -n 1p <<< $refList)" "$(sed -n 2p <<< $refList)"
|