Changements dans la hiérarchie pour passer à CSL-Clio
This commit is contained in:
0
Utilitaires/.biblio.stamp
Normal file
0
Utilitaires/.biblio.stamp
Normal file
61
Utilitaires/Makefile
Normal file
61
Utilitaires/Makefile
Normal file
@ -0,0 +1,61 @@
|
||||
INPUT_DATA_DIR = ../Tests-Data
|
||||
BIBLIO_FILE = $(INPUT_DATA_DIR)/BIBLIO_CSL-Tests.json
|
||||
INPUT_FILE = $(INPUT_DATA_DIR)/CSL-Tests.md
|
||||
STYLESHEETS_DIR = ..
|
||||
VALIDATION_FILE_SUFFIX = _CSL-Validation.html
|
||||
OUTPUT_FILE_SUFFIX = _CSL-Tests.html
|
||||
CSL_FILE_SUFFIX = .csl
|
||||
JSON_BIBLIO_UTILITIES_DIR = /home/bdumont/Logiciels/Pandoc-utilities/FileModifiers-Pandoc
|
||||
VALIDATION_PROV_FILE = $(PROV_PREFIX)$(JOURNAL)$(VALIDATION_FILE_SUFFIX)
|
||||
CSL_FILE = $(STYLESHEETS_DIR)/$(JOURNAL)/$(JOURNAL)$(CSL_FILE_SUFFIX)
|
||||
VALIDATION_FILE = $(STYLESHEETS_DIR)/$(JOURNAL)/$(JOURNAL)$(VALIDATION_FILE_SUFFIX)
|
||||
OUTPUT_FILE = $(STYLESHEETS_DIR)/$(JOURNAL)/$(JOURNAL)$(OUTPUT_FILE_SUFFIX)
|
||||
FILTERS_FILE_FIRST = $(STYLESHEETS_DIR)/$(JOURNAL)/$(JOURNAL)_filters-first.txt
|
||||
FILTERS_LIST_FIRST != ./get-filters.sh $(FILTERS_FILE_FIRST)
|
||||
FILTERS_FILE_LAST = $(STYLESHEETS_DIR)/$(JOURNAL)/$(JOURNAL)_filters-last.txt
|
||||
FILTERS_LIST_LAST != ./get-filters.sh $(FILTERS_FILE_LAST)
|
||||
PANDOC_OPTIONS = -s \
|
||||
$(FILTERS_LIST_FIRST) \
|
||||
-C \
|
||||
--bibliography=$(BIBLIO_FILE) \
|
||||
--csl=$(CSL_FILE) \
|
||||
$(FILTERS_LIST_LAST)
|
||||
PROV_PREFIX = PROV_
|
||||
HTML-VIEWER = palemoon
|
||||
|
||||
test : $(CSL_FILE) \
|
||||
$(VALIDATION_FILE) \
|
||||
$(BIBLIO_FILE) \
|
||||
$(INPUT_FILE)
|
||||
pandoc $(PANDOC_OPTIONS) \
|
||||
$(INPUT_FILE) \
|
||||
-o $(OUTPUT_FILE)
|
||||
echo "Résultat de la comparaison"
|
||||
echo "============="
|
||||
diff -s -C 0 \
|
||||
$(OUTPUT_FILE) \
|
||||
$(VALIDATION_FILE)
|
||||
echo "============="
|
||||
|
||||
validation-prov: $(VALIDATION_PROV_FILE)
|
||||
$(HTML-VIEWER) $(VALIDATION_PROV_FILE)
|
||||
|
||||
$(VALIDATION_PROV_FILE): $(BIBLIO_FILE) $(CSL_FILE) $(INPUT_FILE)
|
||||
pandoc $(PANDOC_OPTIONS) \
|
||||
$(INPUT_FILE) \
|
||||
-o $(VALIDATION_PROV_FILE)
|
||||
|
||||
$(INPUT_FILE): $(BIBLIO_FILE)
|
||||
./generer-md-pour-citeproc.sh $(BIBLIO_FILE) $(INPUT_FILE)
|
||||
|
||||
$(BIBLIO_FILE): .biblio.stamp
|
||||
touch .biblio.stamp
|
||||
|
||||
.biblio.stamp:
|
||||
$(JSON_BIBLIO_UTILITIES_DIR)/correct-json $(BIBLIO_FILE)
|
||||
|
||||
install: $(VALIDATION_PROV_FILE)
|
||||
mv $(VALIDATION_PROV_FILE) $(VALIDATION_FILE)
|
||||
|
||||
clean:
|
||||
rm $(STYLESHEETS_DIR)/*/*$(OUTPUT_FILE_SUFFIX)
|
63
Utilitaires/generer-md-pour-citeproc.sh
Executable file
63
Utilitaires/generer-md-pour-citeproc.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/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]" >> "$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 "Plusieurs $locator dans la même page que le précédent[$ref, {p. 4}, ${locator}9-10]" >> "$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)"
|
12
Utilitaires/get-filters.sh
Executable file
12
Utilitaires/get-filters.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILTERS_FILE="$1"
|
||||
|
||||
while read -r filter ; do
|
||||
if [ "${filter##*.}" == lua ] ; then
|
||||
filterCall='-L'
|
||||
else
|
||||
filterCall='--filter'
|
||||
fi
|
||||
echo "$filterCall" "$filter"
|
||||
done < "$FILTERS_FILE"
|
Reference in New Issue
Block a user