utils.citation¶
Warning
These are internal functions that you probably don't want to interact with directly.
Functions for generating citation references.
citation_styles
module-attribute
¶
citation_styles = CitationStyleDict()
Global object for accessing citeproc.CitationStylesStyle objects.
CitationStyleDict ¶
citeproc_render_html ¶
citeproc_render_html(citeproc_dict, style, link_title=True)
Render a bibliography entry with a given CSL style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
citeproc_dict
|
dict[str, Any]
|
A dictionary with publication metadata as expected by CiteProcJSON. |
required |
style
|
str | Path
|
A path to a CSL file. |
required |
link_title
|
bool
|
If True, wraps the title in a link to the entry's URL. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The bibliography entry as a single string with HTML markup. |
Note
The reason for returning a string is that this is what we get from citeproc-py's render_bibliography() function. If the result was parsed with LXML, we could turn it into a proper MarkupText object. However, since the most common use case of this function requires the HTML-ified string, we do not do this here as it would introduce unnecessary overhead in this case.
render_acl_citation ¶
render_acl_citation(paper)
Render a bibliography entry in ACL style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper
|
Paper
|
The paper for which to generate the bibliography entry. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The bibliography entry as a single string with HTML markup. |
Note
This function re-implements (parts of) the ACL citation style in pure Python, making it a much faster alternative to citeproc_render_html.