mkdocs_bibtex/plugin.py
def on_page_markdown(self, markdown, page, config, files):
        """
        Parses the markdown for each page, extracting the bibtex references
        If a local reference list is requested, this will render that list where requested

        1. Finds all cite keys
        2. Convert all the corresponding bib entries into citations
        3. Insert the ordered citation numbers into the markdown text
        4. Insert the bibliography into the markdown
        5. Insert the full bibliograph into the markdown
        """

        # 1. Grab all the cited keys in the markdown
        cite_keys = self.cite_regex.findall(markdown)
        citations = [
            (cite_key, self.bib_data.entries[cite_key])
            for cite_key in cite_keys
            if cite_key in self.bib_data.entries
        ]

        # 2. Convert all the citations to text references
        references = self.format_citations(citations)

        # 3. Insert in numbers into the main markdown and build bibliography
        full_bibliography_page = self.config.get("full_bib_page")
        anchor = "<a href='" + full_bibliography_page + "#{}'>[{}]</a>"
        bibliography = []
        for number, key in enumerate(references.keys()):
            formatted_anchor = anchor.format(key, number + 1)
            markdown = re.sub(
                self.insert_regex.format(key), formatted_anchor, markdown
            )
            bibliography_text = "[{}]: {}".format(number + 1, references[key])
            bibliography.append(bibliography_text)

        # 4. Insert in the bibliopgrahy text into the markdown
        bibliography = "\n\n".join(bibliography)
        markdown = re.sub(
            re.escape(self.config.get("bib_command", "\\bibliography")),
            bibliography,
            markdown,
        )

        # 5. Build the full Bibliography and insert into the text
        markdown = re.sub(
            re.escape(self.config.get("full_bib_command", "\\full_bibliography")),
            self.full_bibliography,
            markdown,
        )

        return markdown

        Parses the markdown for each page, extracting the bibtex references
        If a local reference list is requested, this will render that list where requested

        1. Finds all cite keys
        2. Convert all the corresponding bib entries into citations
        3. Insert the ordered citation numbers into the markdown text
        4. Insert the bibliography into the markdown
        5. Insert the full bibliograph into the markdown
        
Parses the markdown for each page, extracting the bibtex references
If a local reference list is requested, this will render that list where requested

1. Finds all cite keys
2. Convert all the corresponding bib entries into citations
3. Insert the ordered citation numbers into the markdown text
4. Insert the bibliography into the markdown
5. Insert the full bibliograph into the markdown
Parses the markdown for each page extracting the bibtex references If a local reference list is requested this will render that list where requested 1 . Finds all cite keys 2 . Convert all the corresponding bib entries into citations 3 . Insert the ordered citation numbers into the markdown text 4 . Insert the bibliography into the markdown 5 . Insert the full bibliograph into the markdown
def on_page_markdown(self, markdown, page, config, files):
        cite_keys = self.cite_regex.findall(markdown)
        citations = [
            (cite_key, self.bib_data.entries[cite_key])
            for cite_key in cite_keys
            if cite_key in self.bib_data.entries
        ]
        references = self.format_citations(citations)
        full_bibliography_page = self.config.get("full_bib_page")
        anchor = "<a href='" + full_bibliography_page + "#{}'>[{}]</a>"
        bibliography = []
        for number, key in enumerate(references.keys()):
            formatted_anchor = anchor.format(key, number + 1)
            markdown = re.sub(
                self.insert_regex.format(key), formatted_anchor, markdown
            )
            bibliography_text = "[{}]: {}".format(number + 1, references[key])
            bibliography.append(bibliography_text)
        bibliography = "\n\n".join(bibliography)
        markdown = re.sub(
            re.escape(self.config.get("bib_command", "\\bibliography")),
            bibliography,
            markdown,
        )
        markdown = re.sub(
            re.escape(self.config.get("full_bib_command", "\\full_bibliography")),
            self.full_bibliography,
            markdown,
        )
        return markdown
def on_page_markdown ( self , markdown , page , config , files ) : cite_keys = self . cite_regex . findall ( markdown ) citations = [ ( cite_key , self . bib_data . entries [ cite_key ] ) for cite_key in cite_keys if cite_key in self . bib_data . entries ] references = self . format_citations ( citations ) full_bibliography_page = self . config . get ( "full_bib_page" ) anchor = "<a href='" + full_bibliography_page + "#{}'>[{}]</a>" bibliography = [ ] for number , key in enumerate ( references . keys ( ) ) : formatted_anchor = anchor . format ( key , number + 1 ) markdown = re . sub ( self . insert_regex . format ( key ) , formatted_anchor , markdown ) bibliography_text = "[{}]: {}" . format ( number + 1 , references [ key ] ) bibliography . append ( bibliography_text ) bibliography = "\n\n" . join ( bibliography ) markdown = re . sub ( re . escape ( self . config . get ( "bib_command" , "\\bibliography" ) ) , bibliography , markdown , ) markdown = re . sub ( re . escape ( self . config . get ( "full_bib_command" , "\\full_bibliography" ) ) , self . full_bibliography , markdown , ) return markdown
Parses the markdown for each page, extracting the bibtex references
If a local reference list is requested, this will render that list where requested
Parses the markdown for each page extracting the bibtex references If a local reference list is requested this will render that list where requested
"""
        Parses the markdown for each page, extracting the bibtex references
        If a local reference list is requested, this will render that list where requested

        1. Finds all cite keys
        2. Convert all the corresponding bib entries into citations
        3. Insert the ordered citation numbers into the markdown text
        4. Insert the bibliography into the markdown
        5. Insert the full bibliograph into the markdown
        """ # 1. Grab all the cited keys in the markdown # 2. Convert all the citations to text references # 3. Insert in numbers into the main markdown and build bibliography # 4. Insert in the bibliopgrahy text into the markdown # 5. Build the full Bibliography and insert into the text
self
markdown
page
config
files