From 89db4fed7351ee289f63ea60f8baee7d1fd1cd87 Mon Sep 17 00:00:00 2001 From: Aston Zhang Date: Thu, 7 Jul 2022 07:34:05 +0000 Subject: [PATCH] Allow specification of bibtex bibfile --- d2lbook/config.py | 4 ++-- d2lbook/config_default.ini | 3 +++ d2lbook/sphinx.py | 1 + d2lbook/sphinx_template.py | 4 ++-- setup.py | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/d2lbook/config.py b/d2lbook/config.py index e7c6b16..4f95aff 100644 --- a/d2lbook/config.py +++ b/d2lbook/config.py @@ -76,9 +76,9 @@ def __init__(self, tab=None, config_fname='config.ini'): self.set_tab(self.tab) # Sanity checks. self.sanity_check() - + def _set_target(self): - # Some targets names. + # Some targets names. self.tex_fname = os.path.join(self.pdf_dir, self.project['name']+'.tex') self.pkg_fname = os.path.join(self.tgt_dir, self.project['name']+'.zip') diff --git a/d2lbook/config_default.ini b/d2lbook/config_default.ini index 56417ae..dc3d855 100644 --- a/d2lbook/config_default.ini +++ b/d2lbook/config_default.ini @@ -133,6 +133,9 @@ post_latex = # The filename of the latex logo latex_logo = +# Bibtext bibfile +bibfile = + [library] diff --git a/d2lbook/sphinx.py b/d2lbook/sphinx.py index d8afa51..45e9094 100644 --- a/d2lbook/sphinx.py +++ b/d2lbook/sphinx.py @@ -29,6 +29,7 @@ def prepare_env(self): 'sphinx.ext.viewcode'] extensions.extend(self.config.build['sphinx_extensions'].split()) self._update_pyconf('extensions', ','.join('"'+ext+'"' for ext in extensions)) + self._update_pyconf('bibfile', self.config.pdf['bibfile']) for font in ['main_font', 'sans_font', 'mono_font']: font_value = '' if self.config.pdf[font]: diff --git a/d2lbook/sphinx_template.py b/d2lbook/sphinx_template.py index 7a3c6be..2235b83 100644 --- a/d2lbook/sphinx_template.py +++ b/d2lbook/sphinx_template.py @@ -52,7 +52,7 @@ rsvg_converter_args = ['-z', '0.8'] -bibtex_bibfiles = ['d2l.bib'] +bibtex_bibfiles = ["BIBFILE"] latex_engine = 'xelatex' # for utf-8 supports latex_show_pagerefs = True @@ -409,7 +409,7 @@ def setup(app): } .mdl-tabs__tab.is-active { - background: rgb(0,0,0,.09); + background: rgb(0,0,0,.09); } """ diff --git a/setup.py b/setup.py index b396191..f41e831 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ 'recommonmark', 'nbformat', 'nbconvert', - 'sphinxcontrib-bibtex', + 'sphinxcontrib-bibtex==2.4.2', # >=2.2 to enable citet and citep 'pybtex-apa-style', 'mu-notedown', 'mxtheme>=0.3.17',