The issue is that now I need to check every citation for new show rules that I should add to my Typst source. In practice, I’m going to miss some of them and end up with poorly formatted references. Including all show rules needed for all references in my (potentially large) bibliography seems hacky and requires syncing data in two different files, never a pleasant prospect.
Is there a way to record this formatting information within the Hayagriva (or BibTeX) file?
Hey @Mathieu, welcome to the forum! I’ve changed your post’s title to a question in order to better fit our guidelines, feel free to adjust it further if needed: How to post in the Questions category
You can try using $math mode content$ in your bibliography file as that is usually preserved by Hayagriva. Otherwise, you’ll need show rules. Per-citation show rules are not currently possible, although there are some ongoing community efforts to make this possible.
You could use eval and show rules to achieve this. For example,
bibfile.yml
title: Breathing in myeval(O#sub[2]) releases CO2
document.typ
@breathing
#show bibliography: it => {
let reg = regex("myeval\((.*)\)")
show reg: r => {
eval(r.text.replace(reg, m => {
m.captures.first()
}), mode: "markup")
}
it
}
#bibliography("bibfile.yml")
I have recently come across this issue and aarnent’s solution is the best that I have found yet, but it does have two easily fixable problems.
First, it fails when ‘myeval’ is upcased to ‘Myval’ by the title casing mechanisms.
Second, it fails when there is more than one markup string in the bibliography entry. The regex starts with the beginning of the first and does not stop until the end of the last, attempting to transform the whole of the captured text.
The correction to these is to use the line
let reg = regex("Myeval\((.*?)\)")
(note the added ?, which makes the match non-greedy) and to use Myeval instead of myeval.
The inability to properly specify an article title like “Revenge for Honour: Date, Authorship and Sources" is a real issue in many fields. (Or a publisher field of sine nomine or …
A better solution, in my opinion, is to accept basic LaTeX formatting commands in bib(la)tex files and convert them on-the-fly for internal use. Like it or not, such formatting is embedded in bibliographies and other processing software.
Typst markup should be accepted directly in Hayagriva yaml files.