67 lines
2.3 KiB
Bash
Executable File
67 lines
2.3 KiB
Bash
Executable File
#!/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"
|
||
echo "$inlineBaseText $iCit (\\$ref)[$ref]" >> "$OUTPUT_FILE"
|
||
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"
|
||
echo "" >> "$OUTPUT_FILE"
|
||
echo "Plusieurs $locator dans la même page que le précédent[$ref, {p. 4}, ${locator}9-10]" >> "$OUTPUT_FILE"
|
||
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"
|
||
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)"
|