Selecting the first genre from a list of them is a bit complicated. We must first be sure that we know what "first" means. You probably mean it to be the first displayed, so we need to sort the list (list_sort) because inside calibre its sort order isn't defined. We then must extract the first tag from the sorted list (sublist), and finally extract the last item from that first tag (list_item).
The following template in
template program mode should work
Code:
{#genre:'list_item(sublist(list_sort($, 0, ','), 0, 1, ','), -1, '.')'}
We need to use template program mode because we are using the output of one function as the input for another, something that cannot be done in the simpler
single function mode.