diff --git a/book/_ext/apastyle.py b/book/_ext/apastyle.py new file mode 100644 index 0000000..16828fe --- /dev/null +++ b/book/_ext/apastyle.py @@ -0,0 +1,17 @@ + +# from pybtex.style.formatting.unsrt import Style +from pybtexapastyle.formatting.apa import APAStyle +from pybtexapastyle.labels.apa import LabelStyle as APALabelStyle +from pybtex.plugin import register_plugin +# from pybtex.style.template import names, sentence + +class MyAPALabelStyle(APALabelStyle): + def format_label(self, entry): + return APALabelStyle.format_label(self, entry) + +class MyAPAStyle(APAStyle): + default_label_style = 'myapa' + +def setup(app): + register_plugin('pybtex.style.labels', 'myapa', MyAPALabelStyle) + register_plugin('pybtex.style.formatting', 'myapastyle', MyAPAStyle) \ No newline at end of file diff --git a/book/_ext/bracket_citation_style.py b/book/_ext/bracket_citation_style.py new file mode 100644 index 0000000..cab10f3 --- /dev/null +++ b/book/_ext/bracket_citation_style.py @@ -0,0 +1,27 @@ +from dataclasses import dataclass, field +import sphinxcontrib.bibtex.plugin + +from sphinxcontrib.bibtex.style.referencing import BracketStyle +from sphinxcontrib.bibtex.style.referencing.author_year import AuthorYearReferenceStyle + + +def bracket_style() -> BracketStyle: + return BracketStyle( + left='(', + right=')', + ) + + +@dataclass +class MyReferenceStyle(AuthorYearReferenceStyle): + bracket_parenthetical: BracketStyle = field(default_factory=bracket_style) + bracket_textual: BracketStyle = field(default_factory=bracket_style) + bracket_author: BracketStyle = field(default_factory=bracket_style) + bracket_label: BracketStyle = field(default_factory=bracket_style) + bracket_year: BracketStyle = field(default_factory=bracket_style) + + +def setup(app): + sphinxcontrib.bibtex.plugin.register_plugin( + 'sphinxcontrib.bibtex.style.referencing', + 'author_year_round', MyReferenceStyle) \ No newline at end of file