Skip to content

Commit 9b2479b

Browse files
authored
Merge pull request #1 from jroettenbacher/add-custom-style
Add custom style functionality. Updated pixi infrastructure.
2 parents 1c35cc7 + b403c9f commit 9b2479b

11 files changed

Lines changed: 3850 additions & 4809 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ jobs:
1919
retry: true
2020
linksToSkip: https://pypi.org/project/pelican-pybtex/
2121
- name: Setup pixi
22-
uses: prefix-dev/setup-pixi@v0.8.1
22+
uses: prefix-dev/setup-pixi@v0.9.4
2323
with:
24-
pixi-version: v0.35.0
24+
pixi-version: v0.65.0
2525
cache: true
26-
auth-host: prefix.dev
27-
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
2826
- name: Run qa
2927
run: pixi run -e qa qa
3028
test:
@@ -43,12 +41,10 @@ jobs:
4341
steps:
4442
- uses: actions/checkout@v4
4543
- name: Set up Python ${{ matrix.python-version }} & Pixi
46-
uses: prefix-dev/setup-pixi@v0.8.1
44+
uses: prefix-dev/setup-pixi@v0.9.4
4745
with:
48-
pixi-version: v0.35.0
46+
pixi-version: v0.65.0
4947
cache: true
50-
auth-host: prefix.dev
51-
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
5248
- name: Run tests
5349
run: pixi run -e test${{ matrix.python-version }} test-ci
5450
env:
@@ -97,12 +93,10 @@ jobs:
9793
fetch-depth: 0
9894
fetch-tags: true
9995
- name: Setup pixi
100-
uses: prefix-dev/setup-pixi@v0.8.1
96+
uses: prefix-dev/setup-pixi@v0.9.4
10197
with:
102-
pixi-version: v0.35.0
98+
pixi-version: v0.65.0
10399
cache: true
104-
auth-host: prefix.dev
105-
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
106100
- name: Build a binary wheel and a source tarball
107101
run: pixi run -e build build
108102
- name: Check distribution

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,20 @@ PYBTEX_ADD_ENTRY_FIELDS = ["url", "pdf", "slides", "poster"]
7676
### Formatting style
7777

7878
By default, `PYBTEX_FORMAT_STYLE` is set to `plain`. You may further customize this
79-
setting to one of the biobliography formatting styles supported by pybtex (currently
79+
setting to one of the bibliography formatting styles supported by pybtex (currently
8080
"plain", "alpha", "unsrt", and "unsrtalpha"). You may check the formatting style of
81-
these BibTeX styles [on this
82-
reference](https://www.overleaf.com/learn/latex/Bibtex_bibliography_styles). We
83-
currently do not support custom bibliographic styles. Create an issue if you would like
84-
to work on this.
81+
these BibTeX styles [on this reference](https://www.overleaf.com/learn/latex/Bibtex_bibliography_styles).
82+
83+
#### Custom formatting styles
84+
85+
You can [write your own pybtex formatting style](https://docs.pybtex.org/api/styles.html#style-api), save it in your projects top level directory (or any other directory included in your `PYTHONPATH`) and tell `pelican-pybtex` to use it by setting:
86+
87+
```python
88+
PYBTEX_FORMAT_STYLE = "my_custom_style.CustomStyle"
89+
```
90+
in your `pelicanconf.py`.
91+
`my_custom_style` is the python file with your `CustomStyle` class in it.
92+
Since writing those custom styles is not straight forward, you can take a look at `custom_bibtex_style.py` in the test directory for some inspiration.
8593

8694
### Publications page
8795

@@ -141,7 +149,7 @@ resolution. For example, to add a short introductory text, we could override th
141149
### Local bibliography in articles and pages
142150
143151
You may use markers such as `[@bibkey]` or `[@@bibkey]` on your articles and pages in
144-
restructuredtext or markdown formats, to refer to bibliography entries from the
152+
RestructuredText or Markdown formats, to refer to bibliography entries from the
145153
`PYBTEX_SOURCES`. This process is similar to using BibTeX database entries in your
146154
LaTeX sources by using the `\cite{bibkey}` command. In this case, this plugin will
147155
replace these citations with links to a bibliography database *injected* at the end of
@@ -150,7 +158,7 @@ the article or post.
150158
The global `PYBTEX_FORMAT_STYLE` is respected while formatting bibliographies. You may
151159
override the style for the current article or page using the metadata entry
152160
`pybtex_format_style`. The same mechanism is available for `PYBTEX_ADD_ENTRY_FIELDS`,
153-
which can be locally overriden by `pybtex_add_entry_fields` metadata entry.
161+
which can be locally overridden by `pybtex_add_entry_fields` metadata entry.
154162
155163
You may also add further enrich article or page metadata defining a specific
156164
`pybtex_sources`. In such a case, these files will be loaded respecting the same rules
@@ -161,12 +169,12 @@ looking at entries in the local `pybtex_sources`, and then on the global
161169
`PYBTEX_SOURCES` entry in `pelicanconf.py`.
162170
163171
Be aware that in case repeated citation keys are found across all bibliography
164-
databases, **the last occurence is used** while resolving local bibliography for
165-
articles an pages.
172+
databases, **the last occurrence is used** while resolving local bibliography for
173+
articles and pages.
166174
167175
Finally, local bibliography formatting is controlled by the [default
168176
`bibliography.html`](src/pelican/plugins/pybtex/templates/bibliography.html) template
169-
that is shipped with this package. This templates defines the contents of the
177+
that is shipped with this package. This template defines the contents of the
170178
*injected* bibliography section on articles and pages. You may override this template in
171179
a similar way to what was explained above for the global `publications.html` template,
172180
by setting the `THEME_TEMPLATES_OVERRIDES` Pelican variable.

0 commit comments

Comments
 (0)