]> git.llucax.com Git - z.facultad/75.00/informe.git/commitdiff
Ordenar alfabéticamente las referencias
authorLeandro Lucarella <llucax@gmail.com>
Tue, 12 Oct 2010 00:37:59 +0000 (21:37 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Tue, 12 Oct 2010 00:37:59 +0000 (21:37 -0300)
Makefile
bibsort.py [new file with mode: 0755]

index 5613fcb43740cf7413442d06d5ffad125ea1e9cd..59120265a80e23d8a0aec40b415a8eec8b38dff9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@ latex:
        @sed -i 's/, \\py@release//' build/latex/sphinx.sty
        @sed -i '/-makeindex/d' build/latex/Makefile
        @cp manual.cls build/latex/
+       @./bibsort.py
        @echo
        @echo "Build finished; the LaTeX files are in build/latex."
        @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
diff --git a/bibsort.py b/bibsort.py
new file mode 100755 (executable)
index 0000000..547a0b1
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import re
+
+fname = 'build/latex/tesis.tex'
+
+bib_re = re.compile(r'(\\begin{thebibliography}{[^}]+})'
+               r'(.*)'
+               r'(\\end{thebibliography})',
+               re.S)
+
+text = file(fname).read()
+
+head, body, foot = bib_re.findall(text)[0]
+
+body = '\n'.join(
+               sorted(
+                       body
+                               .replace('\n', '')
+                               .replace('\\bibitem', '\n\\bibitem')
+                               .splitlines()
+               )
+       )
+
+text = bib_re.sub('\n'.join((head, body, foot)).replace('\\', '\\\\'), text)
+
+#print text
+file(fname, 'w').write(text)
+