Skip to content

Add custom style functionality - #1

Merged
anjos merged 16 commits into
anjos:mainfrom
jroettenbacher:add-custom-style
Mar 6, 2026
Merged

Add custom style functionality#1
anjos merged 16 commits into
anjos:mainfrom
jroettenbacher:add-custom-style

Conversation

@jroettenbacher

Copy link
Copy Markdown
Contributor

Hi there and thank you for providing this amazing plugin to pelican.

I was in need of using a custom formatting style and adapted the code slightly. Maybe you can have a look and if you think this is worth adding, tell me what to do next? I would also include an example and maybe more documentation (where? only in the README or somewhere else as well?).

Here's my idea behind the new function:

A user can provide their own formatting style for bibliography entries with a script containing a new style, which is based upon one of pybtex default classes.

Using PYBTEX_FORMAT_STYLE = 'myscriptname.MyCustomStyle' in the pelicanconf.py file then allows pelican-pybtex to use this style.

The function first checks if a default styles is used, then tries to import the custom style and falls back to plain if everything fails.

Best Johannes

A user can provide their own formatting style for bibliography entries with a script containing a new Style, which is based upon one of pybtex default classes.

Using PYBTEX_FORMAT_STYLE = 'myscriptname.MyCustomStyle' in the pelicanconf.py file then allows pelican-pybtex to use this style.

The function first checks if a default styles is used, then tries to import the custom style and falls back to plain if everything fails.
@jroettenbacher

Copy link
Copy Markdown
Contributor Author

Short reminder 😀

@anjos

anjos commented Oct 19, 2025

Copy link
Copy Markdown
Owner

Thanks for this patch, @jroettenbacher - I've been busy, but will look into this shortly.

@anjos

anjos commented Oct 23, 2025

Copy link
Copy Markdown
Owner

Thanks for this patch, and apologies you had to wait so long for a reply.

The patch looks sane. There are a couple of places you'd want to have more information:

a) The README: as you already spotted, this file is the documentation. There is a section about styling. Can you please update it to account for this new way to define a style?

b) Tests: we have test units. It would be best to have units covering the use of an external custom style, so we can maintain this in the long term.

@jroettenbacher

Copy link
Copy Markdown
Contributor Author

Hi @anjos, thanks for the reply. I will look into test covering and adapt the documentation. Will be a few days

The custom style highlights some author names by setting them bold, thus, we are looking for the bold names.

Keep the error and message check.
- publications.bib with two real bibtex entries containing the same name in different formats
- pelicanconf.py with the custom style setting
File with the custom bibliography style as usable by pybtex. It has to be placed in a directory in the PYTHONPATH. Thus, it is placed in the test folder and not in the custom-style folder.
pelican-pybtex falls back to the plain formatting style if it can't find the custom format.

It gives out two error messages in that case. Check for them.
@jroettenbacher

jroettenbacher commented Jan 28, 2026

Copy link
Copy Markdown
Contributor Author

Hey @anjos,
Happy new year! I finally came around doing this.
I also ran all the linting (if that is what it's called).
pre-commits were enabled as well and I checked the coverage, which looks good for the new stuff

==================================================== tests coverage ====================================================
___________________________________ coverage: platform linux, python 3.14.2-final-0 ____________________________________

Name Stmts Miss Cover Missing

src/pelican/plugins/pybtex/__init__.py 17 0 100%
src/pelican/plugins/pybtex/generator.py 47 5 89% 51-55, 107-109
src/pelican/plugins/pybtex/injector.py 61 5 92% 55, 74, 101-102, 114
src/pelican/plugins/pybtex/signals.py 2 0 100%
src/pelican/plugins/pybtex/style.py 30 0 100%
src/pelican/plugins/pybtex/utils.py 67 3 96% 38, 79-80

TOTAL 224 13 94%

I'm sure it needs more documentation but I can't really think of what to add more to the README.md

Happy to hear back from you.

Best Johannes

@anjos

anjos commented Jan 28, 2026

Copy link
Copy Markdown
Owner

Great work, @jroettenbacher -- I'm letting the workflow run and you shall get some feedback from the tests. Can you please fix issues (if any)?

@jroettenbacher

Copy link
Copy Markdown
Contributor Author

It seems the workflow does not find the secret PREFIX_DEV_TOKEN.
Also while I was working on it with a newer version of pixi (0.63.2) it complained that the project field is deprecated and one should use workspace instead

 WARN Encountered 1 warning while parsing the manifest:
  ⚠ The `project` field is deprecated. Use `workspace` instead.
    ╭─[/home/jr/projects/pelican-pybtex/pyproject.toml:44:1]
 43 │     
 44 │ ╭─▶ [tool.pixi.project]
 45 │ │   channels = ["conda-forge"]
 46 │ ├─▶ platforms = ["linux-64", "osx-arm64"]
    · ╰──── replace this with 'workspace'
 47 │     
    ╰────

We could update this and the pixi version used in the workflow in another PR.

@jroettenbacher

Copy link
Copy Markdown
Contributor Author

Short reminder

@anjos

anjos commented Mar 6, 2026

Copy link
Copy Markdown
Owner

All looks merry here after a few updates -- thanks @jroettenbacher!

@anjos
anjos merged commit 9b2479b into anjos:main Mar 6, 2026
11 checks passed
@anjos

anjos commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Tagged as v1.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants