mkdocs_bibtex/plugin.py
def on_config(self, config):
        """
        Loads bibliography on load of config
        """
        config_path = os.path.dirname(config.config_file_path)

        bibfiles = []

        if self.config.get("bib_file", None) is not None:
            bibfiles.append(get_path(self.config["bib_file"], config_path))
        elif self.config.get("bib_dir", None) is not None:
            bibfiles.extend(
                glob.glob(
                    get_path(os.path.join(self.config["bib_dir"], "*.bib"), config_path)
                )
            )
        else:
            raise Exception("Must supply a bibtex file or directory for bibtex files")

        # load bibliography data
        refs = {}
        for bibfile in bibfiles:
            bibfile = get_path(bibfile, config_path)
            bibdata = parse_file(bibfile)
            refs.update(bibdata.entries)

        self.bib_data = BibliographyData(entries=refs)

        cite_style = config.get("cite_style", "pandoc")
        # Decide on how citations are entered into the markdown text
        if cite_style == "plain":
            self.cite_regex = re.compile(r"\@(\w+)")
            self.insert_regex = r"\@{}"
        elif cite_style == "pandoc":
            self.cite_regex = re.compile(r"\[\@(\w+)\]")
            self.insert_regex = r"\[@{}\]"
        else:
            raise Exception("Invalid citation style: {}".format(cite_style))

        self.csl_file = config.get("csl_file", None)

        return config

        Loads bibliography on load of config
        
Loads bibliography on load of config
Loads bibliography on load of config
def on_config(self, config):
        config_path = os.path.dirname(config.config_file_path)
        bibfiles = []
        if self.config.get("bib_file", None) is not None:
            bibfiles.append(get_path(self.config["bib_file"], config_path))
        elif self.config.get("bib_dir", None) is not None:
            bibfiles.extend(
                glob.glob(
                    get_path(os.path.join(self.config["bib_dir"], "*.bib"), config_path)
                )
            )
        else:
            raise Exception("Must supply a bibtex file or directory for bibtex files")
        refs = {}
        for bibfile in bibfiles:
            bibfile = get_path(bibfile, config_path)
            bibdata = parse_file(bibfile)
            refs.update(bibdata.entries)
        self.bib_data = BibliographyData(entries=refs)
        cite_style = config.get("cite_style", "pandoc")
        if cite_style == "plain":
            self.cite_regex = re.compile(r"\@(\w+)")
            self.insert_regex = r"\@{}"
        elif cite_style == "pandoc":
            self.cite_regex = re.compile(r"\[\@(\w+)\]")
            self.insert_regex = r"\[@{}\]"
        else:
            raise Exception("Invalid citation style: {}".format(cite_style))
        self.csl_file = config.get("csl_file", None)
        return config
def on_config ( self , config ) : config_path = os . path . dirname ( config . config_file_path ) bibfiles = [ ] if self . config . get ( "bib_file" , None ) is not None : bibfiles . append ( get_path ( self . config [ "bib_file" ] , config_path ) ) elif self . config . get ( "bib_dir" , None ) is not None : bibfiles . extend ( glob . glob ( get_path ( os . path . join ( self . config [ "bib_dir" ] , "*.bib" ) , config_path ) ) ) else : raise Exception ( "Must supply a bibtex file or directory for bibtex files" ) refs = { } for bibfile in bibfiles : bibfile = get_path ( bibfile , config_path ) bibdata = parse_file ( bibfile ) refs . update ( bibdata . entries ) self . bib_data = BibliographyData ( entries = refs ) cite_style = config . get ( "cite_style" , "pandoc" ) if cite_style == "plain" : self . cite_regex = re . compile ( r"\@(\w+)" ) self . insert_regex = r"\@{}" elif cite_style == "pandoc" : self . cite_regex = re . compile ( r"\[\@(\w+)\]" ) self . insert_regex = r"\[@{}\]" else : raise Exception ( "Invalid citation style: {}" . format ( cite_style ) ) self . csl_file = config . get ( "csl_file" , None ) return config
Loads bibliography on load of config
Loads bibliography on load of config
"""
        Loads bibliography on load of config
        """ # load bibliography data # Decide on how citations are entered into the markdown text
self
config