Add custom style functionality - #1
Conversation
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.
|
Short reminder 😀 |
|
Thanks for this patch, @jroettenbacher - I've been busy, but will look into this shortly. |
|
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. |
|
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.
|
Hey @anjos, ==================================================== tests coverage ==================================================== Name Stmts Miss Cover Missing src/pelican/plugins/pybtex/__init__.py 17 0 100% 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 |
|
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)? |
|
It seems the workflow does not find the secret PREFIX_DEV_TOKEN. 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. |
|
Short reminder |
|
All looks merry here after a few updates -- thanks @jroettenbacher! |
|
Tagged as v1.0.2. |
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 thepelicanconf.pyfile 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