inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.13k stars 101 forks source link

Query in which author appears at all, not necessarily first #249

Closed csaund closed 5 years ago

csaund commented 5 years ago

I'm trying to create a filtered bibliography by authors generated from a bibtex file, but I've found using the syntax {% bibliography --query @*[author^=Albert] %} only returns elements for which Albert is the first author. For instance, if my bibliography looks like:

---
---
Publications
==========

@article{testa,
  title={test1},
  author={Albert, Alex A and Booth, Brian and Cook, Cathy},
  journal={Irrelevant},
  year={2018}
}
@article{testb,
  title={test2},
  author={Booth, Brian and Albert, Alex and Cook, Cathy},
  journal={Irrelevant},
  year={2018}
}
@article{testc,
  title={test3},
  author={Cook, Cathy and Booth, Brian and Albert, Alex},
  journal={Irrelevant},
  year={2018}
}
@article{testd,
  title={test4},
  author={Done, Daniel},
  journal={Irrelevant},
  year={2018}
}

the query will only return the element for test1.

I am looking for a query for which all publications in which Albert is an author (test1, test2, test3) are returned. I've tried variants of the query, such as {% bibliography --query @*[author<=Albert] %}, and {% bibliography --query @*[author>=Albert] %} both of which return all items in the bibliography.

I've also tried the regex {% bibliography --query @*[author=\bAlbert\b] %} along with various combinations of >= and <= but no luck.

Is the functionality to return queries for which the author appears at all supported?

Thanks!

inukshuk commented 5 years ago

To convert the query to a regex please use ~= -- that should work for your example. In retrospect, it was a bad idea to add ^= at all, because it's misleading and not really necessary, as you could just do ~= ^xyz.

csaund commented 5 years ago

Works like a charm, thanks!