diff options
author | grubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-02-22 10:44:35 +0000 |
---|---|---|
committer | grubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-02-22 10:44:35 +0000 |
commit | 9ba327a01ea980ae2cefda5800fc3088690c57a9 (patch) | |
tree | 94f1b548aed7ca23cc28d1d173cd4ebbadceae94 | |
parent | 1b046ab3741f3381787f26677d4e21b20cb02dd6 (diff) | |
download | docutils-9ba327a01ea980ae2cefda5800fc3088690c57a9.tar.gz |
New option ``--use-bibtex=style,db1,db2``.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4928 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r-- | HISTORY.txt | 1 | ||||
-rw-r--r-- | docutils/writers/latex2e/__init__.py | 32 |
2 files changed, 23 insertions, 10 deletions
diff --git a/HISTORY.txt b/HISTORY.txt index 7ffb3106d..fe0e30861 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -107,6 +107,7 @@ Changes Since 0.4 * docutils/writers/latex2e/__init__.py: + - New option ``--use-bibtex=style,db1,db2``. - New option ``--reference-label`` to allow usage of LaTeX ref for labels in section references. - Add a label after every section to support sectionnumbers as reference diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py index 8438e210f..d646d7776 100644 --- a/docutils/writers/latex2e/__init__.py +++ b/docutils/writers/latex2e/__init__.py @@ -140,6 +140,10 @@ class Writer(writers.Writer): 'number or the page number.', ['--reference-label'], {'default': None, }), + ('Specify style and database for bibtex, for example ' + '"--use-bibtex=mystyle,mydb1,mydb2".', + ['--use-bibtex'], + {'default': None, }), ),) settings_defaults = {'output_encoding': 'latin-1'} @@ -587,6 +591,10 @@ class LaTeXTranslator(nodes.NodeVisitor): else: self.colorlinks = 'true' + if self.settings.use_bibtex: + self.bibtex = self.settings.use_bibtex.split(",",1) + else: + self.bibtex = None # language: labels, bibliographic_fields, and author_separators. # to allow writing labes for specific languages. self.language = languages.get_language(settings.language_code) @@ -1219,16 +1227,20 @@ class LaTeXTranslator(nodes.NodeVisitor): def depart_document(self, node): # TODO insertion point of bibliography should none automatic. if self._use_latex_citations and len(self._bibitems)>0: - widest_label = "" - for bi in self._bibitems: - if len(widest_label)<len(bi[0]): - widest_label = bi[0] - self.body.append('\n\\begin{thebibliography}{%s}\n'%widest_label) - for bi in self._bibitems: - # cite_key: underscores must not be escaped - cite_key = bi[0].replace(r"{\_}","_") - self.body.append('\\bibitem[%s]{%s}{%s}\n' % (bi[0], cite_key, bi[1])) - self.body.append('\\end{thebibliography}\n') + if not self.bibtex: + widest_label = "" + for bi in self._bibitems: + if len(widest_label)<len(bi[0]): + widest_label = bi[0] + self.body.append('\n\\begin{thebibliography}{%s}\n'%widest_label) + for bi in self._bibitems: + # cite_key: underscores must not be escaped + cite_key = bi[0].replace(r"{\_}","_") + self.body.append('\\bibitem[%s]{%s}{%s}\n' % (bi[0], cite_key, bi[1])) + self.body.append('\\end{thebibliography}\n') + else: + self.body.append('\n\\bibliographystyle{%s}\n' % self.bibtex[0]) + self.body.append('\\bibliography{%s}\n' % self.bibtex[1]) self.body_suffix.append('\\end{document}\n') |