Created
September 18, 2010 14:27
-
-
Save unhammer/585718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Endre desse variablane: | |
W2LJAR=/home/brukar/latex/writer2latex.jar | |
CONFIG=/home/brukar/latex/zotero.xml | |
BIB=/home/brukar/latex/minbibliografi # utan .bib til slutt | |
STYLE=apalike | |
## Du skal ikkje trenge endre noko under denne linja | |
if [ "$#" -ne 1 ]; then echo "Bruk: sh odt-to-lyx.sh dokument.odt"; exit 1; fi | |
ODT="$1" | |
TEX=$(echo "${ODT}" | sed 's/\.odt$/.tex/') | |
LYX=$(echo "${ODT}" | sed 's/\.odt$/.lyx/') | |
rm -f "${TEX}" | |
java -jar ${W2LJAR} -latex -config=${CONFIG} "${ODT}" "${TEX}" | |
# Java unfortunately doesn't give any helpful exit codes, so we just | |
# check if the file was created: | |
if [ -f "${TEX}" ]; then | |
# Insert our bibliography, writer2latex can't do this: | |
sed -i".tmp" "s%\\\\end{document}%\n\\\\bibliographystyle{${STYLE}}\n\\\\bibliography{${BIB}}\n\\\\end{document}%g" "${TEX}" | |
rm -f "${TEX}.tmp" | |
# Make a backup of any existing LyX file, just in case: | |
if [ -f "${LYX}" ]; then | |
LYXBAK=$(mktemp "${LYX}.gammal.XXXXX") | |
mv "${LYX}" "${LYXBAK}" | |
fi | |
tex2lyx "${TEX}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment